This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "torture/ui.h"
#include "torture/torture.h"
#include "util/dlinklist.h"
+#include "auth/credentials/credentials.h"
/**
check that a wire string matches the flags specified
not 100% accurate, but close enough for testing
*/
-bool wire_bad_flags(struct smb_wire_string *str, int flags, struct smbcli_state *cli)
+bool wire_bad_flags(struct smb_wire_string *str, int flags, struct smbcli_transport *transport)
{
bool server_unicode;
int len;
len = strlen(str->s);
if (flags & STR_TERMINATE) len++;
- server_unicode = (cli->transport->negotiate.capabilities&CAP_UNICODE)?True:False;
+ server_unicode = (transport->negotiate.capabilities&CAP_UNICODE)?True:False;
if (getenv("CLI_FORCE_ASCII") || !lp_unicode()) {
server_unicode = False;
}
return NT_STATUS_EA_CORRUPT_ERROR;
}
-bool torture_open_connection_share(TALLOC_CTX *mem_ctx,
+_PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx,
struct smbcli_state **c,
const char *hostname,
const char *sharename,
return True;
}
-_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, int conn_index)
+_PUBLIC_ bool torture_get_conn_index(int conn_index,
+ TALLOC_CTX *mem_ctx,
+ char **host, char **share)
{
- const char *host = lp_parm_string(-1, "torture", "host");
- const char *share = lp_parm_string(-1, "torture", "share");
char **unc_list = NULL;
int num_unc_names = 0;
const char *p;
+
+ (*host) = talloc_strdup(mem_ctx, lp_parm_string(-1, "torture", "host"));
+ (*share) = talloc_strdup(mem_ctx, lp_parm_string(-1, "torture", "share"));
p = lp_parm_string(-1, "torture", "unclist");
- if (p) {
- char *h, *s;
- unc_list = file_lines_load(p, &num_unc_names, NULL);
- if (!unc_list || num_unc_names <= 0) {
- printf("Failed to load unc names list from '%s'\n", p);
- exit(1);
- }
+ if (!p) {
+ return True;
+ }
- if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names],
- NULL, &h, &s)) {
- printf("Failed to parse UNC name %s\n",
- unc_list[conn_index % num_unc_names]);
- exit(1);
- }
- host = h;
- share = s;
+ unc_list = file_lines_load(p, &num_unc_names, NULL);
+ if (!unc_list || num_unc_names <= 0) {
+ DEBUG(0,("Failed to load unc names list from '%s'\n", p));
+ return False;
}
- return torture_open_connection_share(NULL, c, host, share, NULL);
+ if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names],
+ mem_ctx, host, share)) {
+ DEBUG(0, ("Failed to parse UNC name %s\n",
+ unc_list[conn_index % num_unc_names]));
+ return False;
+ }
+
+ talloc_free(unc_list);
+ return True;
}
+
+
_PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c,
int conn_index,
struct event_context *ev)
{
- const char *host = lp_parm_string(-1, "torture", "host");
- const char *share = lp_parm_string(-1, "torture", "share");
- char **unc_list = NULL;
- int num_unc_names = 0;
- const char *p;
-
- p = lp_parm_string(-1, "torture", "unclist");
- if (p) {
- char *h, *s;
- unc_list = file_lines_load(p, &num_unc_names, NULL);
- if (!unc_list || num_unc_names <= 0) {
- printf("Failed to load unc names list from '%s'\n", p);
- exit(1);
- }
+ char *host, *share;
+ bool ret;
- if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names],
- NULL, &h, &s)) {
- printf("Failed to parse UNC name %s\n",
- unc_list[conn_index % num_unc_names]);
- exit(1);
- }
- host = h;
- share = s;
+ if (!torture_get_conn_index(conn_index, ev, &host, &share)) {
+ return False;
}
+ ret = torture_open_connection_share(NULL, c, host, share, ev);
+ talloc_free(host);
+ talloc_free(share);
+
+ return ret;
+}
- return torture_open_connection_share(NULL, c, host, share, ev);
+_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, int conn_index)
+{
+ return torture_open_connection_ev(c, conn_index,
+ cli_credentials_get_event_context(cmdline_credentials));
}
volatile bool *child_status_out;
int synccount;
int tries = 8;
+ int torture_nprocs = torture_setting_int(tctx, "nprocs", 4);
double start_time_limit = 10 + (torture_nprocs * 1.5);
struct timeval tv;