}
torture_comment(tctx, "Opening secondary connection\n");
- if (!torture_open_connection(&cli2, 1)) {
+ if (!torture_open_connection(&cli2, tctx, 1)) {
torture_comment(tctx, "Failed to open secondary connection\n");
correct = false;
}
goto fail;
}
- if (!torture_open_connection(&cli_nt, 0)) {
+ if (!torture_open_connection(&cli_nt, tctx, 0)) {
goto fail;
}
goto fail;
}
- if (!torture_open_connection(&cli_dos, 1)) {
+ if (!torture_open_connection(&cli_dos, tctx, 1)) {
goto fail;
}
struct smbcli_state *cli2;
bool correct = true;
- if (!torture_open_connection(&cli1, 0))
+ if (!torture_open_connection(&cli1, tctx, 0))
return false;
- if (!torture_open_connection(&cli2, 1))
+ if (!torture_open_connection(&cli2, tctx, 1))
return false;
del_clean_area(cli1, cli2);
fnum1 = -1;
- if (!torture_open_connection(&cli1, 0)) {
+ if (!torture_open_connection(&cli1, tctx, 0)) {
return false;
}
struct smbcli_state *cli1;
bool correct = true;
- if (!torture_open_connection(&cli1, 0))
+ if (!torture_open_connection(&cli1, tctx, 0))
return false;
smbcli_deltree(cli1->tree, dname);
mem_ctx = talloc_init("torture_raw_mux");
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
return false;
}
for (i=0;i<torture_numops;i++) {
ret &= test_disconnect_lock(cli, mem_ctx);
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
return false;
}
ret &= test_disconnect_open(cli, mem_ctx);
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
return false;
}
cli = malloc_array_p(struct smbcli_state *, torture_numops);
for (i=0;i<torture_numops;i++) {
- if (!torture_open_connection(&cli[i], i)) {
+ if (!torture_open_connection(&cli[i], tctx, i)) {
return false;
}
if (torture_setting_bool(tctx, "progress", true)) {
for (op=0x0;op<=0xFF;op++) {
if (op == SMBreadbraw) continue;
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
return false;
}
static unsigned long nb_max_retries;
#define NB_RETRY(op) \
- for (n=0;n<=nb_max_retries && !op;n++) do_reconnect(&cli, client)
+ for (n=0;n<=nb_max_retries && !op;n++) do_reconnect(&cli, tctx, client)
-static void do_reconnect(struct smbcli_state **cli, int client)
+static void do_reconnect(struct smbcli_state **cli, struct torture_context *tctx, int client)
{
int n;
printf("[%d] Reconnecting client %d\n", nbench_line_count, client);
for (n=0;n<nb_max_retries;n++) {
- if (nb_reconnect(cli, client)) {
+ if (nb_reconnect(cli, tctx, client)) {
printf("[%d] Reconnected client %d\n", nbench_line_count, client);
return;
}
}
if (torture_nprocs > 1) {
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
return false;
}
return true;
}
-bool nb_reconnect(struct smbcli_state **cli, int client)
+bool nb_reconnect(struct smbcli_state **cli, struct torture_context *tctx, int client)
{
children[client].connected = false;
talloc_free(*cli);
}
- if (!torture_open_connection(cli, client)) {
+ if (!torture_open_connection(cli, tctx, client)) {
printf("nb_reconnect: failed to connect\n");
*cli = NULL;
return false;
bool ret = true;
TALLOC_CTX *mem_ctx;
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
return false;
}
mem_ctx = talloc_init("torture_rap_scan");
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
return false;
}
struct smbcli_state *cli;
bool ret = true;
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
return false;
}
enum lock_stage {LOCK_INITIAL, LOCK_LOCK, LOCK_UNLOCK};
struct benchlock_state {
+ struct torture_context *tctx;
struct event_context *ev;
struct smbcli_tree *tree;
TALLOC_CTX *mem_ctx;
state->te = NULL;
- if (!torture_get_conn_index(state->client_num, state->mem_ctx, &host, &share)) {
+ if (!torture_get_conn_index(state->client_num, state->mem_ctx, state->tctx, &host, &share)) {
DEBUG(0,("Can't find host/share for reconnect?!\n"));
exit(1);
}
printf("Opening %d connections\n", nprocs);
for (i=0;i<nprocs;i++) {
+ state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
state[i].client_num = i;
state[i].ev = ev;
- if (!torture_open_connection_ev(&cli, i, ev)) {
+ if (!torture_open_connection_ev(&cli, i, torture, ev)) {
return false;
}
talloc_steal(mem_ctx, state);
/*
basic testing of change notifies followed by a tdis
*/
-static bool test_notify_tdis(TALLOC_CTX *mem_ctx)
+static bool test_notify_tdis(struct torture_context *tctx)
{
bool ret = true;
NTSTATUS status;
printf("TESTING CHANGE NOTIFY FOLLOWED BY TDIS\n");
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, tctx, 0)) {
return false;
}
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = BASEDIR;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_STATUS(status, NT_STATUS_OK);
cli->tree = NULL;
- status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
+ status = smb_raw_changenotify_recv(req, tctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VAL(notify.nttrans.out.num_changes, 0);
/*
basic testing of change notifies followed by a exit
*/
-static bool test_notify_exit(TALLOC_CTX *mem_ctx)
+static bool test_notify_exit(struct torture_context *tctx)
{
bool ret = true;
NTSTATUS status;
printf("TESTING CHANGE NOTIFY FOLLOWED BY EXIT\n");
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, tctx, 0)) {
return false;
}
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = BASEDIR;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
status = smb_raw_exit(cli->session);
CHECK_STATUS(status, NT_STATUS_OK);
- status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
+ status = smb_raw_changenotify_recv(req, tctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VAL(notify.nttrans.out.num_changes, 0);
/*
basic testing of change notifies followed by a ulogoff
*/
-static bool test_notify_ulogoff(TALLOC_CTX *mem_ctx)
+static bool test_notify_ulogoff(struct torture_context *tctx)
{
bool ret = true;
NTSTATUS status;
printf("TESTING CHANGE NOTIFY FOLLOWED BY ULOGOFF\n");
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, tctx, 0)) {
return false;
}
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = BASEDIR;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
status = smb_raw_ulogoff(cli->session);
CHECK_STATUS(status, NT_STATUS_OK);
- status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
+ status = smb_raw_changenotify_recv(req, tctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VAL(notify.nttrans.out.num_changes, 0);
/*
basic testing of change notifies followed by tcp disconnect
*/
-static bool test_notify_tcp_dis(TALLOC_CTX *mem_ctx)
+static bool test_notify_tcp_dis(struct torture_context *tctx)
{
bool ret = true;
NTSTATUS status;
printf("TESTING CHANGE NOTIFY FOLLOWED BY TCP DISCONNECT\n");
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, tctx, 0)) {
return false;
}
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = BASEDIR;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
smbcli_transport_idle_handler(cli->transport, tcp_dis_handler, 250, cli);
- status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
+ status = smb_raw_changenotify_recv(req, tctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_LOCAL_DISCONNECT);
done:
return false;
}
- if (!torture_open_connection_share(mem_ctx, &cli, host, share, ev)) {
+ if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, ev)) {
return false;
}
for (i=0; i<num_files; i++) {
if (!torture_open_connection_share(mem_ctx, &(clients[i]),
- host, share, ev)) {
+ tctx, host, share, ev)) {
DEBUG(0, ("Could not open %d'th connection\n", i));
return false;
}
static struct timed_event *report_te;
struct benchopen_state {
+ struct torture_context *tctx;
TALLOC_CTX *mem_ctx;
struct event_context *ev;
struct smbcli_state *cli;
state->te = NULL;
- if (!torture_get_conn_index(state->client_num, state->mem_ctx, &host, &share)) {
+ if (!torture_get_conn_index(state->client_num, state->mem_ctx, state->tctx, &host, &share)) {
DEBUG(0,("Can't find host/share for reconnect?!\n"));
exit(1);
}
printf("Opening %d connections\n", nprocs);
for (i=0;i<nprocs;i++) {
+ state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
state[i].client_num = i;
state[i].ev = ev;
- if (!torture_open_connection_ev(&state[i].cli, i, ev)) {
+ if (!torture_open_connection_ev(&state[i].cli, i, torture, ev)) {
return false;
}
talloc_steal(mem_ctx, state);
torture_comment(torture, "Opening %d connections\n", torture_nprocs);
for (i=0;i<torture_nprocs;i++) {
- if (!torture_open_connection_ev(&cli[i], i, ev)) {
+ if (!torture_open_connection_ev(&cli[i], i, torture, ev)) {
return false;
}
talloc_steal(mem_ctx, cli[i]);
do_writes = torture_setting_bool(torture, "write", false);
lock_timeout = torture_setting_int(torture, "lock_timeout", 100000);
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
DEBUG(0,("Could not open connection\n"));
return false;
}
struct smbcli_tree *hideunwrite;
if (!torture_open_connection_share(
- torture, &cli, torture_setting_string(torture, "host", NULL),
+ torture, &cli, torture, torture_setting_string(torture, "host", NULL),
torture_setting_string(torture, "share", NULL), NULL)) {
d_printf("torture_open_connection_share failed\n");
return false;
const char *fname = "closeerr.dir\\closerr.txt";
int fnum;
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, tctx, 0)) {
goto fail;
}
}
if (!torture_open_connection_share(
- torture, &cli, torture_setting_string(torture, "host", NULL),
+ torture, &cli, torture, torture_setting_string(torture, "host", NULL),
torture_setting_string(torture, "share", NULL), NULL)) {
d_printf("torture_open_connection_share failed\n");
ret = false;
goto fail;
}
- if (!torture_open_connection(&cli_nt, 0)) {
+ if (!torture_open_connection(&cli_nt, torture, 0)) {
goto fail;
}
goto fail;
}
- if (!torture_open_connection(&cli_dos, 1)) {
+ if (!torture_open_connection(&cli_dos, torture, 1)) {
goto fail;
}
return false;
}
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, torture, 0)) {
goto done;
}
struct smb_lock_entry lock_entry;
struct smbcli_request *req;
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, tctx, 0)) {
ret = false;
goto done;
}
const char *fname = "testfile";
bool ret = false;
- if (!torture_open_connection(&cli, 0)) {
+ if (!torture_open_connection(&cli, tctx, 0)) {
ret = false;
goto done;
}
static bool test_CreateDir(TALLOC_CTX *mem_ctx,
struct smbcli_state **cli,
+ struct torture_context *tctx,
const char *host,
const char *share,
const char *dir)
{
printf("Creating directory %s\n", dir);
- if (!torture_open_connection_share(mem_ctx, cli, host, share, NULL)) {
+ if (!torture_open_connection_share(mem_ctx, cli, tctx, host, share, NULL)) {
return false;
}
static void test_cleanup_stdroot(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
+ struct torture_context *tctx,
const char *host,
const char *sharename,
const char *dir)
test_RemoveStdRoot(p, mem_ctx, host, sharename);
test_NetShareDel(mem_ctx, host, sharename);
- torture_open_connection_share(mem_ctx, &cli, host, "C$", NULL);
+ torture_open_connection_share(mem_ctx, &cli, tctx, host, "C$", NULL);
test_DeleteDir(cli, dir);
torture_close_connection(cli);
}
static bool test_StdRoot(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
+ struct torture_context *tctx,
const char *host)
{
const char *sharename = SMBTORTURE_DFS_SHARENAME;
printf("Testing StdRoot\n");
- test_cleanup_stdroot(p, mem_ctx, host, sharename, dir);
+ test_cleanup_stdroot(p, mem_ctx, tctx, host, sharename, dir);
- ret &= test_CreateDir(mem_ctx, &cli, host, "C$", dir);
+ ret &= test_CreateDir(mem_ctx, &cli, tctx, host, "C$", dir);
ret &= test_NetShareAdd(mem_ctx, host, sharename, path);
ret &= test_AddStdRoot(p, mem_ctx, host, sharename);
ret &= test_RemoveStdRoot(p, mem_ctx, host, sharename);
ret &= test_ManagerInitialize(p, torture, host);
ret &= test_Enum(p, torture);
ret &= test_EnumEx(p, torture, host);
- ret &= test_StdRoot(p, torture, host);
+ ret &= test_StdRoot(p, torture, torture, host);
ret &= test_FtRoot(p, torture, host);
ret &= test_DcAddress(p, torture, host);
}
if (!(torture_open_connection_share(
- mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
+ mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
"IPC$", NULL))) {
talloc_free(mem_ctx);
return false;
if (!(torture_open_connection_share(
mem_ctx, &cli,
- torture_setting_string(torture, "host", NULL),
+ torture, torture_setting_string(torture, "host", NULL),
"IPC$", NULL))) {
d_printf("IPC$ connection failed\n");
goto done;
}
if (!(torture_open_connection_share(
- mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
+ mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
"IPC$", NULL))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
}
if (!(torture_open_connection_share(
- mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
+ mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
"IPC$", NULL))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
}
if (!(torture_open_connection_share(
- mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
+ mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
"IPC$", NULL))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
}
if (!(torture_open_connection_share(
- mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
+ mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
"IPC$", NULL))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
bool ret = false;
const char *comment = "Dummer Kommentar";
- if (!(torture_open_connection(&cli, 0))) {
+ if (!(torture_open_connection(&cli, torture, 0))) {
return false;
}
_PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx,
struct smbcli_state **c,
+ struct torture_context *tctx,
const char *hostname,
const char *sharename,
struct event_context *ev)
return false;
}
- (*c)->transport->options.use_oplocks = lp_parm_bool(global_loadparm, NULL, "torture",
- "use_oplocks", false);
- (*c)->transport->options.use_level2_oplocks = lp_parm_bool(global_loadparm, NULL, "torture",
- "use_level2_oplocks", false);
+ (*c)->transport->options.use_oplocks = torture_setting_bool(tctx, "use_oplocks", false);
+ (*c)->transport->options.use_level2_oplocks = torture_setting_bool(tctx, "use_level2_oplocks", false);
return true;
}
_PUBLIC_ bool torture_get_conn_index(int conn_index,
TALLOC_CTX *mem_ctx,
+ struct torture_context *tctx,
char **host, char **share)
{
char **unc_list = NULL;
int num_unc_names = 0;
const char *p;
- (*host) = talloc_strdup(mem_ctx, lp_parm_string(global_loadparm, NULL, "torture", "host"));
- (*share) = talloc_strdup(mem_ctx, lp_parm_string(global_loadparm, NULL, "torture", "share"));
+ (*host) = talloc_strdup(mem_ctx, torture_setting_string(tctx, "host", NULL));
+ (*share) = talloc_strdup(mem_ctx, torture_setting_string(tctx, "share", NULL));
- p = lp_parm_string(global_loadparm, NULL, "torture", "unclist");
+ p = torture_setting_string(tctx, "unclist", NULL);
if (!p) {
return true;
}
_PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c,
int conn_index,
+ struct torture_context *tctx,
struct event_context *ev)
{
char *host, *share;
bool ret;
- if (!torture_get_conn_index(conn_index, ev, &host, &share)) {
+ if (!torture_get_conn_index(conn_index, ev, tctx, &host, &share)) {
return false;
}
- ret = torture_open_connection_share(NULL, c, host, share, ev);
+ ret = torture_open_connection_share(NULL, c, tctx, host, share, ev);
talloc_free(host);
talloc_free(share);
return ret;
}
-_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, int conn_index)
+_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, struct torture_context *tctx, int conn_index)
{
- return torture_open_connection_ev(c, conn_index,
+ return torture_open_connection_ev(c, conn_index, tctx,
cli_credentials_get_event_context(cmdline_credentials));
}
while (1) {
- if (torture_open_connection(¤t_cli, i)) {
+ if (torture_open_connection(¤t_cli, tctx, i)) {
break;
}
if (tries-- == 0) {
struct smbcli_state *cli1, *cli2;
- if (!torture_open_connection(&cli1, 0) ||
- !torture_open_connection(&cli2, 1))
+ if (!torture_open_connection(&cli1, torture_ctx, 0) ||
+ !torture_open_connection(&cli2, torture_ctx, 1))
return false;
fn = test->fn;
struct smbcli_state *cli1;
- if (!torture_open_connection(&cli1, 0))
+ if (!torture_open_connection(&cli1, torture_ctx, 0))
return false;
fn = test->fn;
form DOMAIN/user into a domain and a user */
static bool parse_ntlm_auth_domain_user(const char *domuser, fstring domain,
- fstring user)
+ fstring user, char winbind_separator)
{
- char *p = strchr(domuser, *lp_winbind_separator(global_loadparm));
+ char *p = strchr(domuser, winbind_separator);
if (!p) {
return false;
if (!ev) {
exit(1);
}
- msg = messaging_client_init(state, lp_messaging_path(state, global_loadparm), ev);
+ msg = messaging_client_init(state, lp_messaging_path(state, lp_ctx), ev);
if (!msg) {
exit(1);
}
}
creds = cli_credentials_init(state->gensec_state);
- cli_credentials_set_conf(creds, global_loadparm);
+ cli_credentials_set_conf(creds, lp_ctx);
if (opt_username) {
cli_credentials_set_username(creds, opt_username, CRED_SPECIFIED);
}
reply_code = "AF";
reply_arg = talloc_asprintf(state->gensec_state,
"%s%s%s", session_info->server_info->domain_name,
- lp_winbind_separator(global_loadparm), session_info->server_info->account_name);
+ lp_winbind_separator(lp_ctx), session_info->server_info->account_name);
talloc_free(session_info);
}
} else if (state->gensec_state->gensec_role == GENSEC_CLIENT) {
fstring fstr_user;
fstring fstr_domain;
- if (!parse_ntlm_auth_domain_user(full_username, fstr_user, fstr_domain)) {
+ if (!parse_ntlm_auth_domain_user(full_username, fstr_user, fstr_domain,
+ *lp_winbind_separator(lp_ctx))) {
/* username might be 'tainted', don't print into our new-line deleimianted stream */
mux_printf(mux_id, "Error: Could not parse into domain and username\n");
}