From: Jelmer Vernooij Date: Sun, 2 Dec 2007 21:32:11 +0000 (+0100) Subject: r26236: Remove more uses of global_loadparm or specify loadparm_context explicitly. X-Git-Url: http://git.samba.org/samba.git/?p=jelmer%2Fsamba4-debian.git;a=commitdiff_plain;h=5b29ef7c03d9ae76b0ca909e9f03a58e1bad3521 r26236: Remove more uses of global_loadparm or specify loadparm_context explicitly. --- diff --git a/source/auth/auth_server.c b/source/auth/auth_server.c index d391793bd..900ca8d05 100644 --- a/source/auth/auth_server.c +++ b/source/auth/auth_server.c @@ -24,7 +24,7 @@ Support for server level security. ****************************************************************************/ -static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx, int maxprotocol) +static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx, bool unicode, int maxprotocol) { struct smbcli_state *cli = NULL; fstring desthost; @@ -92,7 +92,7 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx, int maxprotocol DEBUG(3,("got session\n")); - if (!smbcli_negprot(cli, maxprotocol)) { + if (!smbcli_negprot(cli, unicode, maxprotocol)) { DEBUG(1,("%s rejected the negprot\n",desthost)); release_server_mutex(); talloc_free(cli); @@ -215,7 +215,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context if (cli) { } else { - cli = server_cryptkey(mem_ctx, lp_cli_maxprotocol(auth_context->lp_ctx)); + cli = server_cryptkey(mem_ctx, lp_unicode(auth_context->lp_ctx), lp_cli_maxprotocol(auth_context->lp_ctx)); locally_made_cli = true; } diff --git a/source/auth/gensec/gensec_krb5.c b/source/auth/gensec/gensec_krb5.c index 1227a48ad..391d231f9 100644 --- a/source/auth/gensec/gensec_krb5.c +++ b/source/auth/gensec/gensec_krb5.c @@ -116,7 +116,7 @@ static NTSTATUS gensec_krb5_start(struct gensec_security *gensec_security) talloc_set_destructor(gensec_krb5_state, gensec_krb5_destroy); - if (cli_credentials_get_krb5_context(creds, &gensec_krb5_state->smb_krb5_context)) { + if (cli_credentials_get_krb5_context(creds, global_loadparm, &gensec_krb5_state->smb_krb5_context)) { talloc_free(gensec_krb5_state); return NT_STATUS_INTERNAL_ERROR; } diff --git a/source/client/smbmount.c b/source/client/smbmount.c index 1ac524dd0..34fb90fca 100644 --- a/source/client/smbmount.c +++ b/source/client/smbmount.c @@ -111,7 +111,7 @@ static void usr1_handler(int x) /***************************************************** return a connection to a server *******************************************************/ -static struct smbcli_state *do_connection(char *the_service, int maxprotocol) +static struct smbcli_state *do_connection(const char *the_service, bool unicode, int maxprotocol) { struct smbcli_state *c; struct nmb_name called, calling; @@ -181,7 +181,7 @@ static struct smbcli_state *do_connection(char *the_service, int maxprotocol) DEBUG(4,("%d: session request ok\n", sys_getpid())); - if (!smbcli_negprot(c, maxprotocol)) { + if (!smbcli_negprot(c, unicode, maxprotocol)) { DEBUG(0,("%d: protocol negotiation failed\n", sys_getpid())); talloc_free(c); return NULL; @@ -323,7 +323,7 @@ static void smb_umount(char *mount_point) * not exit after open_sockets() or send_login() errors, * as the smbfs mount would then have no way to recover. */ -static void send_fs_socket(char *the_service, char *mount_point, struct smbcli_state *c) +static void send_fs_socket(const char *the_service, char *mount_point, struct smbcli_state *c) { int fd, closed = 0, res = 1; pid_t parentpid = getppid(); @@ -406,7 +406,7 @@ static void send_fs_socket(char *the_service, char *mount_point, struct smbcli_s CatchSignal(SIGUSR1, &usr1_handler); pause(); DEBUG(2,("mount.smbfs[%d]: got signal, getting new socket\n", sys_getpid())); - c = do_connection(the_service); + c = do_connection(the_service, lp_unicode(global_loadparm), lp_cli_maxprotocol(global_loadparm)); } } @@ -434,7 +434,7 @@ static void init_mount(void) } - c = do_connection(service, lp_cli_maxprotocol(global_loadparm)); + c = do_connection(service, lp_unicode(global_loadparm), lp_cli_maxprotocol(global_loadparm)); if (!c) { fprintf(stderr,"SMB connection failed\n"); exit(1); diff --git a/source/lib/cmdline/popt_common.c b/source/lib/cmdline/popt_common.c index 41eb70094..1c96bf64c 100644 --- a/source/lib/cmdline/popt_common.c +++ b/source/lib/cmdline/popt_common.c @@ -47,6 +47,7 @@ static void popt_common_callback(poptContext con, const char *arg, const void *data) { const char *pname; + struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */ if (reason == POPT_CALLBACK_REASON_POST) { if (!lp_loaded()) { @@ -81,7 +82,7 @@ static void popt_common_callback(poptContext con, switch(opt->val) { case 'd': - lp_set_cmdline(global_loadparm, "log level", arg); + lp_set_cmdline(lp_ctx, "log level", arg); break; case OPT_DEBUG_STDERR: @@ -94,7 +95,7 @@ static void popt_common_callback(poptContext con, case 'O': if (arg) { - lp_set_cmdline(global_loadparm, "socket options", arg); + lp_set_cmdline(lp_ctx, "socket options", arg); } break; @@ -107,37 +108,37 @@ static void popt_common_callback(poptContext con, case 'l': if (arg) { char *new_logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname); - lp_set_cmdline(global_loadparm, "log file", new_logfile); + lp_set_cmdline(lp_ctx, "log file", new_logfile); talloc_free(new_logfile); } break; case 'W': - lp_set_cmdline(global_loadparm, "workgroup", arg); + lp_set_cmdline(lp_ctx, "workgroup", arg); break; case 'r': - lp_set_cmdline(global_loadparm, "realm", arg); + lp_set_cmdline(lp_ctx, "realm", arg); break; case 'n': - lp_set_cmdline(global_loadparm, "netbios name", arg); + lp_set_cmdline(lp_ctx, "netbios name", arg); break; case 'i': - lp_set_cmdline(global_loadparm, "netbios scope", arg); + lp_set_cmdline(lp_ctx, "netbios scope", arg); break; case 'm': - lp_set_cmdline(global_loadparm, "client max protocol", arg); + lp_set_cmdline(lp_ctx, "client max protocol", arg); break; case 'R': - lp_set_cmdline(global_loadparm, "name resolve order", arg); + lp_set_cmdline(lp_ctx, "name resolve order", arg); break; case OPT_OPTION: - if (!lp_set_option(global_loadparm, arg)) { + if (!lp_set_option(lp_ctx, arg)) { fprintf(stderr, "Error setting option '%s'\n", arg); exit(1); } diff --git a/source/lib/registry/registry.h b/source/lib/registry/registry.h index c1159dde2..c53e3dfbe 100644 --- a/source/lib/registry/registry.h +++ b/source/lib/registry/registry.h @@ -164,6 +164,7 @@ struct registry_context { struct auth_session_info; struct event_context; +struct loadparm_context; /** * Open the locally defined registry. @@ -175,6 +176,7 @@ WERROR reg_open_local(TALLOC_CTX *mem_ctx, WERROR reg_open_samba(TALLOC_CTX *mem_ctx, struct registry_context **ctx, + struct loadparm_context *lp_ctx, struct auth_session_info *session_info, struct cli_credentials *credentials); diff --git a/source/lib/registry/registry.i b/source/lib/registry/registry.i index 7e33f43a1..330f0856e 100644 --- a/source/lib/registry/registry.i +++ b/source/lib/registry/registry.i @@ -135,6 +135,7 @@ typedef struct hive_key { WERROR reg_open_samba(TALLOC_CTX *mem_ctx, struct registry_context **ctx, + struct loadparm_context *lp_ctx, struct auth_session_info *session_info, struct cli_credentials *credentials); diff --git a/source/lib/registry/samba.c b/source/lib/registry/samba.c index 2397432f0..a5a60ba61 100644 --- a/source/lib/registry/samba.c +++ b/source/lib/registry/samba.c @@ -26,6 +26,7 @@ */ static WERROR mount_samba_hive(struct registry_context *ctx, + struct loadparm_context *lp_ctx, struct auth_session_info *auth_info, struct cli_credentials *creds, const char *name, @@ -36,7 +37,7 @@ static WERROR mount_samba_hive(struct registry_context *ctx, const char *location; location = talloc_asprintf(ctx, "%s/%s.ldb", - lp_private_dir(global_loadparm), + lp_private_dir(lp_ctx), name); error = reg_open_hive(ctx, location, auth_info, creds, &hive); @@ -54,6 +55,7 @@ static WERROR mount_samba_hive(struct registry_context *ctx, _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx, struct registry_context **ctx, + struct loadparm_context *lp_ctx, struct auth_session_info *session_info, struct cli_credentials *credentials) { @@ -64,18 +66,18 @@ _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx, return result; } - mount_samba_hive(*ctx, session_info, credentials, + mount_samba_hive(*ctx, lp_ctx, session_info, credentials, "hklm", HKEY_LOCAL_MACHINE); - mount_samba_hive(*ctx, session_info, credentials, + mount_samba_hive(*ctx, lp_ctx, session_info, credentials, "hkcr", HKEY_CLASSES_ROOT); /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the * current user */ - mount_samba_hive(*ctx, session_info, credentials, + mount_samba_hive(*ctx, lp_ctx, session_info, credentials, "hkcu", HKEY_CURRENT_USER); - mount_samba_hive(*ctx, session_info, credentials, + mount_samba_hive(*ctx, lp_ctx, session_info, credentials, "hku", HKEY_USERS); /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes diff --git a/source/lib/registry/tools/common.c b/source/lib/registry/tools/common.c index 0233f2743..6d766fd25 100644 --- a/source/lib/registry/tools/common.c +++ b/source/lib/registry/tools/common.c @@ -65,12 +65,12 @@ struct registry_key *reg_common_open_file(const char *path, return reg_import_hive_key(h, hive_root, -1, NULL); } -struct registry_context *reg_common_open_local(struct cli_credentials *creds) +struct registry_context *reg_common_open_local(struct cli_credentials *creds, struct loadparm_context *lp_ctx) { WERROR error; struct registry_context *h; - error = reg_open_samba(NULL, &h, NULL, creds); + error = reg_open_samba(NULL, &h, lp_ctx, NULL, creds); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open local registry:%s \n", diff --git a/source/lib/registry/tools/regdiff.c b/source/lib/registry/tools/regdiff.c index f96761cda..1996861a2 100644 --- a/source/lib/registry/tools/regdiff.c +++ b/source/lib/registry/tools/regdiff.c @@ -24,10 +24,12 @@ #include "lib/events/events.h" #include "lib/cmdline/popt_common.h" #include "lib/registry/tools/common.h" +#include "param/param.h" enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL }; static struct registry_context *open_backend(poptContext pc, + struct loadparm_context *lp_ctx, enum reg_backend backend, const char *remote_host) { @@ -39,7 +41,7 @@ static struct registry_context *open_backend(poptContext pc, poptPrintUsage(pc, stderr, 0); return NULL; case REG_LOCAL: - error = reg_open_samba(NULL, &ctx, NULL, cmdline_credentials); + error = reg_open_samba(NULL, &ctx, lp_ctx, NULL, cmdline_credentials); break; case REG_REMOTE: error = reg_open_remote(&ctx, NULL, cmdline_credentials, @@ -114,11 +116,11 @@ int main(int argc, const char **argv) } - h1 = open_backend(pc, backend1, remote1); + h1 = open_backend(pc, global_loadparm, backend1, remote1); if (h1 == NULL) return 1; - h2 = open_backend(pc, backend2, remote2); + h2 = open_backend(pc, global_loadparm, backend2, remote2); if (h2 == NULL) return 1; diff --git a/source/lib/registry/tools/regpatch.c b/source/lib/registry/tools/regpatch.c index 35f12c7e6..2f2cf789a 100644 --- a/source/lib/registry/tools/regpatch.c +++ b/source/lib/registry/tools/regpatch.c @@ -24,6 +24,7 @@ #include "lib/cmdline/popt_common.h" #include "lib/registry/tools/common.h" #include "lib/registry/patchfile.h" +#include "param/param.h" int main(int argc, char **argv) { @@ -50,7 +51,7 @@ int main(int argc, char **argv) if (remote) { h = reg_common_open_remote (remote, cmdline_credentials); } else { - h = reg_common_open_local (cmdline_credentials); + h = reg_common_open_local (cmdline_credentials, global_loadparm); } if (h == NULL) diff --git a/source/lib/registry/tools/regshell.c b/source/lib/registry/tools/regshell.c index 7dbcf2f87..9b582c3c0 100644 --- a/source/lib/registry/tools/regshell.c +++ b/source/lib/registry/tools/regshell.c @@ -26,6 +26,7 @@ #include "lib/smbreadline/smbreadline.h" #include "librpc/gen_ndr/ndr_security.h" #include "lib/registry/tools/common.h" +#include "param/param.h" struct regshell_context { struct registry_context *registry; @@ -505,7 +506,7 @@ int main(int argc, char **argv) ctx->registry = ctx->current->context; ctx->path = talloc_strdup(ctx, ""); } else { - ctx->registry = reg_common_open_local(cmdline_credentials); + ctx->registry = reg_common_open_local(cmdline_credentials, global_loadparm); } if (ctx->registry == NULL) diff --git a/source/lib/registry/tools/regtree.c b/source/lib/registry/tools/regtree.c index 9f8d8c012..f95fc1968 100644 --- a/source/lib/registry/tools/regtree.c +++ b/source/lib/registry/tools/regtree.c @@ -23,6 +23,7 @@ #include "lib/registry/tools/common.h" #include "lib/events/events.h" #include "lib/cmdline/popt_common.h" +#include "param/param.h" /** * Print a registry key recursively @@ -132,7 +133,7 @@ int main(int argc, char **argv) } else if (file != NULL) { start_key = reg_common_open_file(file, cmdline_credentials); } else { - h = reg_common_open_local(cmdline_credentials); + h = reg_common_open_local(cmdline_credentials, global_loadparm); } if (h == NULL && start_key == NULL) diff --git a/source/libcli/cliconnect.c b/source/libcli/cliconnect.c index d80665375..39f97f4d8 100644 --- a/source/libcli/cliconnect.c +++ b/source/libcli/cliconnect.c @@ -55,9 +55,9 @@ bool smbcli_transport_establish(struct smbcli_state *cli, } /* wrapper around smb_raw_negotiate() */ -NTSTATUS smbcli_negprot(struct smbcli_state *cli, int maxprotocol) +NTSTATUS smbcli_negprot(struct smbcli_state *cli, bool unicode, int maxprotocol) { - return smb_raw_negotiate(cli->transport, maxprotocol); + return smb_raw_negotiate(cli->transport, unicode, maxprotocol); } /* wrapper around smb_raw_sesssetup() */ diff --git a/source/libcli/raw/rawnegotiate.c b/source/libcli/raw/rawnegotiate.c index 82d6fe523..78b908252 100644 --- a/source/libcli/raw/rawnegotiate.c +++ b/source/libcli/raw/rawnegotiate.c @@ -46,6 +46,7 @@ static const struct { Send a negprot command. */ struct smbcli_request *smb_raw_negotiate_send(struct smbcli_transport *transport, + bool unicode, int maxprotocol) { struct smbcli_request *req; @@ -58,7 +59,7 @@ struct smbcli_request *smb_raw_negotiate_send(struct smbcli_transport *transport } flags2 |= FLAGS2_32_BIT_ERROR_CODES; - if (lp_unicode(global_loadparm)) { + if (unicode) { flags2 |= FLAGS2_UNICODE_STRINGS; } flags2 |= FLAGS2_EXTENDED_ATTRIBUTES; @@ -190,8 +191,8 @@ failed: /* Send a negprot command (sync interface) */ -NTSTATUS smb_raw_negotiate(struct smbcli_transport *transport, int maxprotocol) +NTSTATUS smb_raw_negotiate(struct smbcli_transport *transport, bool unicode, int maxprotocol) { - struct smbcli_request *req = smb_raw_negotiate_send(transport, maxprotocol); + struct smbcli_request *req = smb_raw_negotiate_send(transport, unicode, maxprotocol); return smb_raw_negotiate_recv(req); } diff --git a/source/libcli/smb_composite/connect.c b/source/libcli/smb_composite/connect.c index 9f18c0d92..0238d5c55 100644 --- a/source/libcli/smb_composite/connect.c +++ b/source/libcli/smb_composite/connect.c @@ -63,7 +63,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, { struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); - state->req = smb_raw_negotiate_send(state->transport, + state->req = smb_raw_negotiate_send(state->transport, lp_unicode(global_loadparm), lp_cli_maxprotocol(global_loadparm)); NT_STATUS_HAVE_NO_MEMORY(state->req); diff --git a/source/ntptr/ntptr.h b/source/ntptr/ntptr.h index 458d90c61..56cb4176f 100644 --- a/source/ntptr/ntptr.h +++ b/source/ntptr/ntptr.h @@ -229,4 +229,7 @@ struct ntptr_critical_sizes { int sizeof_ntptr_context; int sizeof_ntptr_ops; }; + +struct loadparm_context; + #include "ntptr/ntptr_proto.h" diff --git a/source/ntptr/ntptr_base.c b/source/ntptr/ntptr_base.c index 379c4e541..1a14c3b33 100644 --- a/source/ntptr/ntptr_base.c +++ b/source/ntptr/ntptr_base.c @@ -69,10 +69,10 @@ NTSTATUS ntptr_register(const void *_ops) return NT_STATUS_OK; } -NTSTATUS ntptr_init(void) +NTSTATUS ntptr_init(struct loadparm_context *lp_ctx) { init_module_fn static_init[] = STATIC_ntptr_MODULES; - init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "ntptr"); + init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "ntptr"); run_init_functions(static_init); run_init_functions(shared_init); diff --git a/source/param/share.c b/source/param/share.c index 489049f39..6c0269d5f 100644 --- a/source/param/share.c +++ b/source/param/share.c @@ -149,10 +149,10 @@ NTSTATUS share_get_context(TALLOC_CTX *mem_ctx, struct share_context **ctx) /* initialise the SHARE subsystem */ -NTSTATUS share_init(void) +NTSTATUS share_init(struct loadparm_context *lp_ctx) { init_module_fn static_init[] = STATIC_share_MODULES; - init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "share"); + init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "share"); run_init_functions(static_init); run_init_functions(shared_init); diff --git a/source/param/share.h b/source/param/share.h index c93d0d985..fae1c31c1 100644 --- a/source/param/share.h +++ b/source/param/share.h @@ -61,6 +61,8 @@ struct share_ops { NTSTATUS (*remove)(struct share_context *, const char *); }; +struct loadparm_context; + #include "param/share_proto.h" /* list of shares options */ diff --git a/source/param/tests/share.c b/source/param/tests/share.c index de93e3c59..26af71d06 100644 --- a/source/param/tests/share.c +++ b/source/param/tests/share.c @@ -21,6 +21,7 @@ #include "includes.h" #include "param/share.h" +#include "param/param.h" #include "torture/torture.h" static bool test_list_empty(struct torture_context *tctx, @@ -196,7 +197,7 @@ struct torture_suite *torture_local_share(TALLOC_CTX *mem_ctx) struct torture_suite *suite = torture_suite_create(mem_ctx, "SHARE"); struct torture_tcase *tcase; - share_init(); + share_init(global_loadparm); tcase = torture_suite_add_tcase(suite, "ldb"); torture_tcase_set_fixture(tcase, setup_ldb, teardown); diff --git a/source/rpc_server/winreg/rpc_winreg.c b/source/rpc_server/winreg/rpc_winreg.c index 14da907df..5be9d837e 100644 --- a/source/rpc_server/winreg/rpc_winreg.c +++ b/source/rpc_server/winreg/rpc_winreg.c @@ -25,6 +25,7 @@ #include "librpc/gen_ndr/ndr_winreg.h" #include "rpc_server/common/common.h" #include "librpc/gen_ndr/ndr_security.h" +#include "param/param.h" enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY }; @@ -35,6 +36,7 @@ static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call, WERROR err; err = reg_open_samba(dce_call->context, + global_loadparm, &ctx, dce_call->conn->auth_state.session_info, NULL); diff --git a/source/scripting/ejs/smbcalls_reg.c b/source/scripting/ejs/smbcalls_reg.c index 38634b996..fee11b66d 100644 --- a/source/scripting/ejs/smbcalls_reg.c +++ b/source/scripting/ejs/smbcalls_reg.c @@ -70,7 +70,7 @@ static int ejs_reg_open(MprVarHandle eid, int argc, struct MprVar **argv) struct registry_context *rctx; WERROR error; - error = reg_open_samba(mprMemCtx(), &rctx, NULL, NULL); + error = reg_open_samba(mprMemCtx(), &rctx, global_loadparm, NULL, NULL); SMB_ASSERT(W_ERROR_IS_OK(error)); mprSetPtrChild(reg, "registry", rctx); diff --git a/source/smb_server/smb/receive.c b/source/smb_server/smb/receive.c index 973b6b993..3f590decc 100644 --- a/source/smb_server/smb/receive.c +++ b/source/smb_server/smb/receive.c @@ -643,7 +643,7 @@ error: /* * init the SMB protocol related stuff */ -NTSTATUS smbsrv_init_smb_connection(struct smbsrv_connection *smb_conn) +NTSTATUS smbsrv_init_smb_connection(struct smbsrv_connection *smb_conn, struct loadparm_context *lp_ctx) { NTSTATUS status; @@ -652,12 +652,12 @@ NTSTATUS smbsrv_init_smb_connection(struct smbsrv_connection *smb_conn) /* this is the size that w2k uses, and it appears to be important for good performance */ - smb_conn->negotiate.max_recv = lp_max_xmit(global_loadparm); + smb_conn->negotiate.max_recv = lp_max_xmit(lp_ctx); smb_conn->negotiate.zone_offset = get_time_zone(time(NULL)); - smb_conn->config.security = lp_security(global_loadparm); - smb_conn->config.nt_status_support = lp_nt_status_support(global_loadparm); + smb_conn->config.security = lp_security(lp_ctx); + smb_conn->config.nt_status_support = lp_nt_status_support(lp_ctx); status = smbsrv_init_sessions(smb_conn, UINT16_MAX); NT_STATUS_NOT_OK_RETURN(status); diff --git a/source/smb_server/smb_server.c b/source/smb_server/smb_server.c index 9242fb1a1..923c1bdfe 100644 --- a/source/smb_server/smb_server.c +++ b/source/smb_server/smb_server.c @@ -42,7 +42,7 @@ static NTSTATUS smbsrv_recv_generic_request(void *private, DATA_BLOB blob) /* see if its a special NBT packet */ if (CVAL(blob.data,0) != 0) { - status = smbsrv_init_smb_connection(smb_conn); + status = smbsrv_init_smb_connection(smb_conn, global_loadparm); NT_STATUS_NOT_OK_RETURN(status); packet_set_callback(smb_conn->packet, smbsrv_recv_smb_request); return smbsrv_recv_smb_request(smb_conn, blob); @@ -58,7 +58,7 @@ static NTSTATUS smbsrv_recv_generic_request(void *private, DATA_BLOB blob) switch (protocol_version) { case SMB_MAGIC: - status = smbsrv_init_smb_connection(smb_conn); + status = smbsrv_init_smb_connection(smb_conn, global_loadparm); NT_STATUS_NOT_OK_RETURN(status); packet_set_callback(smb_conn->packet, smbsrv_recv_smb_request); return smbsrv_recv_smb_request(smb_conn, blob); diff --git a/source/smb_server/smb_server.h b/source/smb_server/smb_server.h index 8ebd3e683..4af6ef136 100644 --- a/source/smb_server/smb_server.h +++ b/source/smb_server/smb_server.h @@ -382,6 +382,8 @@ NTSTATUS smbsrv_add_socket(struct event_context *event_context, const struct model_ops *model_ops, const char *address); +struct loadparm_context; + #include "smb_server/smb_server_proto.h" #include "smb_server/smb/smb_proto.h" diff --git a/source/smbd/pidfile.c b/source/smbd/pidfile.c index 4847ddd7b..356784607 100644 --- a/source/smbd/pidfile.c +++ b/source/smbd/pidfile.c @@ -33,14 +33,14 @@ * return the pid in a pidfile. return 0 if the process (or pidfile) * does not exist */ -pid_t pidfile_pid(const char *name) +pid_t pidfile_pid(const char *piddir, const char *name) { int fd; char pidstr[20]; pid_t ret; char *pidFile; - asprintf(&pidFile, "%s/%s.pid", lp_piddir(global_loadparm), name); + asprintf(&pidFile, "%s/%s.pid", piddir, name); fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644); @@ -80,16 +80,16 @@ pid_t pidfile_pid(const char *name) /** * create a pid file in the pid directory. open it and leave it locked */ -void pidfile_create(const char *name) +void pidfile_create(const char *piddir, const char *name) { int fd; char buf[20]; char *pidFile; pid_t pid; - asprintf(&pidFile, "%s/%s.pid", lp_piddir(global_loadparm), name); + asprintf(&pidFile, "%s/%s.pid", piddir, name); - pid = pidfile_pid(name); + pid = pidfile_pid(piddir, name); if (pid != 0) { DEBUG(0,("ERROR: %s is already running. File %s exists and process id %d is running.\n", name, pidFile, (int)pid)); diff --git a/source/smbd/process_model.c b/source/smbd/process_model.c index bb4d3a53b..e240ae2c6 100644 --- a/source/smbd/process_model.c +++ b/source/smbd/process_model.c @@ -80,10 +80,10 @@ _PUBLIC_ NTSTATUS register_process_model(const void *_ops) return NT_STATUS_OK; } -NTSTATUS process_model_init(void) +NTSTATUS process_model_init(struct loadparm_context *lp_ctx) { init_module_fn static_init[] = STATIC_process_model_MODULES; - init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "process_model"); + init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "process_model"); run_init_functions(static_init); run_init_functions(shared_init); diff --git a/source/smbd/server.c b/source/smbd/server.c index 5dac250ee..65196618d 100644 --- a/source/smbd/server.c +++ b/source/smbd/server.c @@ -88,12 +88,12 @@ static void recursive_delete(const char *path) range locking system. So instead of putting the burden on tdb to cleanup tmp files, this function deletes them. */ -static void cleanup_tmp_files(void) +static void cleanup_tmp_files(struct loadparm_context *lp_ctx) { char *path; TALLOC_CTX *mem_ctx = talloc_new(NULL); - path = smbd_tmp_path(mem_ctx, global_loadparm, NULL); + path = smbd_tmp_path(mem_ctx, lp_ctx, NULL); recursive_delete(path); talloc_free(mem_ctx); @@ -267,13 +267,13 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ become_daemon(true); } - cleanup_tmp_files(); + cleanup_tmp_files(global_loadparm); if (!directory_exist(lp_lockdir(global_loadparm))) { mkdir(lp_lockdir(global_loadparm), 0755); } - pidfile_create(binary_name); + pidfile_create(lp_piddir(global_loadparm), binary_name); /* Do *not* remove this, until you have removed * passdb/secrets.c, and proved that Samba still builds... */ @@ -284,17 +284,17 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ ldb_global_init(); /* FIXME: */ - share_init(); + share_init(global_loadparm); gensec_init(global_loadparm); /* FIXME: */ - ntptr_init(); /* FIXME: maybe run this in the initialization function + ntptr_init(global_loadparm); /* FIXME: maybe run this in the initialization function of the spoolss RPC server instead? */ ntvfs_init(); /* FIXME: maybe run this in the initialization functions of the SMB[,2] server instead? */ - process_model_init(); + process_model_init(global_loadparm); shared_init = load_samba_modules(NULL, global_loadparm, "service"); diff --git a/source/torture/basic/base.c b/source/torture/basic/base.c index 1415b4195..5c5428d61 100644 --- a/source/torture/basic/base.c +++ b/source/torture/basic/base.c @@ -355,7 +355,7 @@ static bool run_negprot_nowait(struct torture_context *tctx) for (i=0;i<100;i++) { struct smbcli_request *req; - req = smb_raw_negotiate_send(cli->transport, PROTOCOL_NT1); + req = smb_raw_negotiate_send(cli->transport, lp_unicode(global_loadparm), PROTOCOL_NT1); event_loop_once(cli->transport->socket->event.ctx); if (req->state == SMBCLI_REQUEST_ERROR) { if (i > 0) { diff --git a/source/torture/rpc/wkssvc.c b/source/torture/rpc/wkssvc.c index ff5c20e25..9a2f51853 100644 --- a/source/torture/rpc/wkssvc.c +++ b/source/torture/rpc/wkssvc.c @@ -1228,17 +1228,11 @@ static bool test_NetrJoinDomain2(struct torture_context *tctx, break; } - domain_admin_account = lp_parm_string(global_loadparm, NULL, - "torture", - "domain_admin_account"); + domain_admin_account = torture_setting_string(tctx, "domain_admin_account", NULL); - domain_admin_password = lp_parm_string(global_loadparm, NULL, - "torture", - "domain_admin_password"); + domain_admin_password = torture_setting_string(tctx, "domain_admin_password", NULL); - domain_name = lp_parm_string(global_loadparm, NULL, - "torture", - "domain_name"); + domain_name = torture_setting_string(tctx, "domain_name", NULL); if ((domain_admin_account == NULL) || (domain_admin_password == NULL) || @@ -1318,13 +1312,9 @@ static bool test_NetrUnjoinDomain2(struct torture_context *tctx, break; } - domain_admin_account = lp_parm_string(global_loadparm, NULL, - "torture", - "domain_admin_account"); + domain_admin_account = torture_setting_string(tctx, "domain_admin_account", NULL); - domain_admin_password = lp_parm_string(global_loadparm, NULL, - "torture", - "domain_admin_password"); + domain_admin_password = torture_setting_string(tctx, "domain_admin_password", NULL); if ((domain_admin_account == NULL) || (domain_admin_password == NULL)) { diff --git a/source/utils/ntlm_auth.c b/source/utils/ntlm_auth.c index 75c87fc11..72c99c112 100644 --- a/source/utils/ntlm_auth.c +++ b/source/utils/ntlm_auth.c @@ -129,7 +129,7 @@ static bool parse_ntlm_auth_domain_user(const char *domuser, fstring domain, fstring user) { - char *p = strchr(domuser,*lp_winbind_separator(global_loadparm)); + char *p = strchr(domuser, *lp_winbind_separator(global_loadparm)); if (!p) { return false;