1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

Pass options struct into session initialization functions rather than

using global_loadparm.
This commit is contained in:
Jelmer Vernooij 2008-09-30 01:29:53 +02:00
parent 21df9532f5
commit c8a19f0b83
9 changed files with 55 additions and 18 deletions

View File

@ -73,8 +73,12 @@ NTSTATUS smbcli_session_setup(struct smbcli_state *cli,
{
struct smb_composite_sesssetup setup;
NTSTATUS status;
struct smbcli_session_options options;
cli->session = smbcli_session_init(cli->transport, cli, true);
lp_smbcli_session_options(global_loadparm, &options);
cli->session = smbcli_session_init(cli->transport, cli, true,
options);
if (!cli->session) return NT_STATUS_UNSUCCESSFUL;
setup.in.sesskey = cli->transport->negotiate.sesskey;

View File

@ -35,7 +35,8 @@
Initialize the session context
****************************************************************************/
struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport,
TALLOC_CTX *parent_ctx, bool primary)
TALLOC_CTX *parent_ctx, bool primary,
struct smbcli_session_options options)
{
struct smbcli_session *session;
uint16_t flags2;
@ -53,9 +54,7 @@ struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport,
}
session->pid = (uint16_t)getpid();
session->vuid = UID_FIELD_INVALID;
session->options.lanman_auth = lp_client_lanman_auth(global_loadparm);
session->options.ntlmv2_auth = lp_client_ntlmv2_auth(global_loadparm);
session->options.plaintext_auth = lp_client_plaintext_auth(global_loadparm);
session->options = options;
capabilities = transport->negotiate.capabilities;

View File

@ -229,12 +229,15 @@ static NTSTATUS connect_negprot(struct composite_context *c,
{
struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
NTSTATUS status;
struct smbcli_session_options options;
lp_smbcli_session_options(global_loadparm, &options);
status = smb_raw_negotiate_recv(state->req);
NT_STATUS_NOT_OK_RETURN(status);
/* next step is a session setup */
state->session = smbcli_session_init(state->transport, state, true);
state->session = smbcli_session_init(state->transport, state, true, options);
NT_STATUS_HAVE_NO_MEMORY(state->session);
/* setup for a tconx (or at least have the structure ready to

View File

@ -2629,3 +2629,11 @@ void lp_smbcli_options(struct loadparm_context *lp_ctx,
options->use_oplocks = true;
options->use_level2_oplocks = true;
}
void lp_smbcli_session_options(struct loadparm_context *lp_ctx,
struct smbcli_session_options *options)
{
options->lanman_auth = lp_client_lanman_auth(lp_ctx);
options->ntlmv2_auth = lp_client_ntlmv2_auth(lp_ctx);
options->plaintext_auth = lp_client_plaintext_auth(lp_ctx);
}

View File

@ -60,6 +60,7 @@ enum announce_as {/* Types of machine we can announce as. */
struct loadparm_context;
struct loadparm_service;
struct smbcli_options;
struct smbcli_session_options;
void reload_charcnv(struct loadparm_context *lp_ctx);
@ -318,6 +319,8 @@ int lp_maxprintjobs(struct loadparm_service *service, struct loadparm_service *s
struct smb_iconv_convenience *lp_iconv_convenience(struct loadparm_context *lp_ctx);
void lp_smbcli_options(struct loadparm_context *lp_ctx,
struct smbcli_options *options);
void lp_smbcli_session_options(struct loadparm_context *lp_ctx,
struct smbcli_session_options *options);
/* The following definitions come from param/generic.c */

View File

@ -36,8 +36,11 @@ static bool try_failed_login(struct torture_context *tctx, struct smbcli_state *
NTSTATUS status;
struct smb_composite_sesssetup setup;
struct smbcli_session *session;
struct smbcli_session_options options;
session = smbcli_session_init(cli->transport, cli, false);
lp_smbcli_session_options(tctx->lp_ctx, &options);
session = smbcli_session_init(cli->transport, cli, false, options);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
setup.in.workgroup = lp_workgroup(tctx->lp_ctx);

View File

@ -81,6 +81,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx)
const char *fname = BASEDIR "\\test.txt";
uint8_t c = 1;
int i;
struct smbcli_session_options options;
printf("TESTING SESSION HANDLING\n");
@ -89,7 +90,10 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx)
}
printf("create a second security context on the same transport\n");
session = smbcli_session_init(cli->transport, tctx, false);
lp_smbcli_session_options(tctx->lp_ctx, &options);
session = smbcli_session_init(cli->transport, tctx, false, options);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
@ -103,7 +107,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx)
session->vuid = setup.out.vuid;
printf("create a third security context on the same transport, with vuid set\n");
session2 = smbcli_session_init(cli->transport, tctx, false);
session2 = smbcli_session_init(cli->transport, tctx, false, options);
session2->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
@ -130,7 +134,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx)
if (cli->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY) {
printf("create a fourth security context on the same transport, without extended security\n");
session3 = smbcli_session_init(cli->transport, tctx, false);
session3 = smbcli_session_init(cli->transport, tctx, false, options);
session3->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
@ -144,7 +148,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx)
CHECK_STATUS(status, NT_STATUS_LOGON_FAILURE);
printf("create a fouth anonymous security context on the same transport, without extended security\n");
session4 = smbcli_session_init(cli->transport, tctx, false);
session4 = smbcli_session_init(cli->transport, tctx, false, options);
session4->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
@ -230,7 +234,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx)
setups[i].in.credentials = cmdline_credentials;
sessions[i] = smbcli_session_init(cli->transport, tctx, false);
sessions[i] = smbcli_session_init(cli->transport, tctx, false, options);
composite_contexts[i] = smb_composite_sesssetup_send(sessions[i], &setups[i]);
}
@ -379,6 +383,7 @@ static bool test_tree_ulogoff(struct smbcli_state *cli, struct torture_context *
const char *fname1 = BASEDIR "\\test1.txt";
const char *fname2 = BASEDIR "\\test2.txt";
uint8_t c = 1;
struct smbcli_session_options options;
printf("TESTING TREE with ulogoff\n");
@ -389,8 +394,10 @@ static bool test_tree_ulogoff(struct smbcli_state *cli, struct torture_context *
share = torture_setting_string(tctx, "share", NULL);
host = torture_setting_string(tctx, "host", NULL);
lp_smbcli_session_options(tctx->lp_ctx, &options);
printf("create the first new sessions\n");
session1 = smbcli_session_init(cli->transport, tctx, false);
session1 = smbcli_session_init(cli->transport, tctx, false, options);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
@ -446,7 +453,7 @@ static bool test_tree_ulogoff(struct smbcli_state *cli, struct torture_context *
CHECK_STATUS(status, NT_STATUS_OK);
printf("create the second new sessions\n");
session2 = smbcli_session_init(cli->transport, tctx, false);
session2 = smbcli_session_init(cli->transport, tctx, false, options);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
@ -634,6 +641,7 @@ static bool test_pid_2sess(struct smbcli_state *cli, struct torture_context *tct
const char *fname = BASEDIR "\\test.txt";
uint8_t c = 1;
uint16_t vuid1, vuid2;
struct smbcli_session_options options;
printf("TESTING PID HANDLING WITH 2 SESSIONS\n");
@ -641,8 +649,10 @@ static bool test_pid_2sess(struct smbcli_state *cli, struct torture_context *tct
return false;
}
lp_smbcli_session_options(tctx->lp_ctx, &options);
printf("create a second security context on the same transport\n");
session = smbcli_session_init(cli->transport, tctx, false);
session = smbcli_session_init(cli->transport, tctx, false, options);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */

View File

@ -456,11 +456,14 @@ static bool test_async(struct torture_context *tctx,
const char *fname = BASEDIR "\\test.txt";
time_t t;
struct smbcli_request *req;
struct smbcli_session_options options;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
}
lp_smbcli_session_options(tctx->lp_ctx, &options);
printf("Testing LOCKING_ANDX_CANCEL_LOCK\n");
io.generic.level = RAW_LOCK_LOCKX;
@ -590,7 +593,7 @@ static bool test_async(struct torture_context *tctx,
}
printf("create a new sessions\n");
session = smbcli_session_init(cli->transport, tctx, false);
session = smbcli_session_init(cli->transport, tctx, false, options);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
setup.in.workgroup = lp_workgroup(tctx->lp_ctx);

View File

@ -74,6 +74,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
struct cli_credentials *anon_creds;
struct smb_composite_sesssetup setup;
struct smbcli_options options;
struct smbcli_session_options session_options;
mem_ctx = talloc_init("torture_bind_authcontext");
@ -83,6 +84,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
}
lp_smbcli_options(torture->lp_ctx, &options);
lp_smbcli_session_options(torture->lp_ctx, &session_options);
status = smbcli_full_connection(mem_ctx, &cli,
torture_setting_string(torture, "host", NULL),
@ -142,7 +144,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
goto done;
}
session2 = smbcli_session_init(cli->transport, mem_ctx, false);
session2 = smbcli_session_init(cli->transport, mem_ctx, false, session_options);
if (session2 == NULL) {
d_printf("smbcli_session_init failed\n");
goto done;
@ -1670,12 +1672,14 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
struct cli_credentials *user_creds;
char *domain_name;
struct smbcli_options options;
struct smbcli_session_options session_options;
if (!(mem_ctx = talloc_new(torture))) {
return false;
}
lp_smbcli_options(torture->lp_ctx, &options);
lp_smbcli_session_options(torture->lp_ctx, &session_options);
status = smbcli_full_connection(
mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
@ -1762,7 +1766,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
struct smb_composite_sesssetup setup;
struct smbcli_tree *tree;
session2 = smbcli_session_init(cli->transport, mem_ctx, false);
session2 = smbcli_session_init(cli->transport, mem_ctx, false, session_options);
if (session2 == NULL) {
d_printf("(%s) smbcli_session_init failed\n",
__location__);