From b65dba2245bf382c47d65c95ac9b1efa43918fc0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 04:33:16 +0100 Subject: r26355: Eliminate global_loadparm in more places. (This used to be commit 5d589a0d94bd76a9b4c9fc748854e8098ea43c4d) --- source4/client/cifsdd.c | 4 ++-- source4/client/client.c | 6 +++--- source4/client/smbmount.c | 2 +- source4/client/smbspool.c | 2 +- source4/lib/cmdline/popt_common.h | 1 + source4/lib/ldb/ldb_ildap/ldb_ildap.c | 5 +++-- source4/lib/ldb/tools/cmdline.c | 6 +++--- source4/lib/registry/tools/regdiff.c | 4 ++-- source4/lib/registry/tools/regpatch.c | 4 ++-- source4/lib/registry/tools/regshell.c | 4 ++-- source4/lib/registry/tools/regtree.c | 4 ++-- source4/libcli/ldap/ldap_bind.c | 2 +- source4/libcli/ldap/ldap_client.c | 13 ++++++++----- source4/libcli/ldap/ldap_client.h | 2 ++ source4/nsswitch/wbinfo.c | 8 ++++---- source4/ntvfs/common/brlock.c | 3 ++- source4/ntvfs/common/brlock.h | 1 + source4/ntvfs/common/brlock_tdb.c | 3 ++- source4/ntvfs/common/opendb.c | 2 +- source4/ntvfs/ntvfs_base.c | 4 ++-- source4/ntvfs/posix/vfs_posix.c | 1 + source4/param/share.c | 6 +----- source4/param/share_classic.c | 16 ++++++++++++---- source4/param/tests/share.c | 2 +- source4/smb_server/smb/service.c | 2 +- source4/smb_server/smb2/tcon.c | 2 +- source4/smbd/server.c | 28 ++++++++++++++-------------- source4/torture/gentest.c | 2 +- source4/torture/ldap/basic.c | 9 +++++---- source4/torture/ldap/common.c | 13 +++++++------ source4/torture/locktest.c | 2 +- source4/torture/locktest2.c | 2 +- source4/torture/masktest.c | 2 +- source4/torture/rpc/dssync.c | 18 ++++++++++-------- source4/torture/rpc/spoolss_notify.c | 2 +- source4/torture/smbtorture.c | 24 ++++++++++++------------ source4/torture/torture.c | 2 +- source4/utils/net/net.c | 2 +- source4/utils/nmblookup.c | 8 ++++---- source4/utils/ntlm_auth.c | 24 +++++++++++++----------- source4/utils/testparm.c | 2 +- source4/winbind/wb_init_domain.c | 2 +- 42 files changed, 136 insertions(+), 115 deletions(-) (limited to 'source4') diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c index 06a5f79ed7..2ce01a2227 100644 --- a/source4/client/cifsdd.c +++ b/source4/client/cifsdd.c @@ -574,7 +574,7 @@ int main(int argc, const char ** argv) } } - gensec_init(global_loadparm); + gensec_init(cmdline_lp_ctx); dump_args(); if (check_arg_numeric("ibs") == 0 || check_arg_numeric("ibs") == 0) { @@ -595,7 +595,7 @@ int main(int argc, const char ** argv) CatchSignal(SIGINT, dd_handle_signal); CatchSignal(SIGUSR1, dd_handle_signal); - return(copy_files(global_loadparm)); + return(copy_files(cmdline_lp_ctx)); } /* vim: set sw=8 sts=8 ts=8 tw=79 : */ diff --git a/source4/client/client.c b/source4/client/client.c index 6842e2e91d..9e031cd09e 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -3181,7 +3181,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c } } - gensec_init(global_loadparm); + gensec_init(cmdline_lp_ctx); if(poptPeekArg(pc)) { char *s = strdup(poptGetArg(pc)); @@ -3220,11 +3220,11 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c } if (query_host) { - return do_host_query(global_loadparm, query_host, lp_workgroup(global_loadparm)); + return do_host_query(cmdline_lp_ctx, query_host, lp_workgroup(cmdline_lp_ctx)); } if (message) { - return do_message_op(lp_netbios_name(global_loadparm), desthost, dest_ip, name_type, lp_name_resolve_order(global_loadparm), lp_max_xmit(global_loadparm), lp_maxmux(global_loadparm)); + return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, dest_ip, name_type, lp_name_resolve_order(cmdline_lp_ctx), lp_max_xmit(cmdline_lp_ctx), lp_maxmux(cmdline_lp_ctx)); } diff --git a/source4/client/smbmount.c b/source4/client/smbmount.c index 0c1c330104..9ab6c375f2 100644 --- a/source4/client/smbmount.c +++ b/source4/client/smbmount.c @@ -897,7 +897,7 @@ static void parse_mount_smb(int argc, char **argv) pstrcpy(username,getenv("LOGNAME")); } - lp_ctx = global_loadparm = loadparm_init(talloc_autofree_context()); + lp_ctx = loadparm_init(talloc_autofree_context()); if (!lp_load(lp_ctx, dyn_CONFIGFILE)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", diff --git a/source4/client/smbspool.c b/source4/client/smbspool.c index 80a11d5f2d..57050acab8 100644 --- a/source4/client/smbspool.c +++ b/source4/client/smbspool.c @@ -177,7 +177,7 @@ static int smb_print(struct smbcli_state *, char *, FILE *); setup_logging(argv[0], DEBUG_STDOUT); - global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context()); + lp_ctx = loadparm_init(talloc_autofree_context()); if (!lp_load(lp_ctx, dyn_CONFIGFILE)) { fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file()); diff --git a/source4/lib/cmdline/popt_common.h b/source4/lib/cmdline/popt_common.h index 7de8027c0b..df432bb475 100644 --- a/source4/lib/cmdline/popt_common.h +++ b/source4/lib/cmdline/popt_common.h @@ -34,5 +34,6 @@ extern struct poptOption popt_common_credentials[]; #define POPT_COMMON_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL }, extern struct cli_credentials *cmdline_credentials; +extern struct loadparm_context *cmdline_lp_ctx; #endif /* _POPT_COMMON_H */ diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index 0c0ee629bf..a834e912d4 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -756,7 +756,8 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, } module->private_data = ildb; ildb->module = module; - ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "EventContext")); + ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"), + ldb_get_opaque(ldb, "EventContext")); if (!ildb->ldap) { ldb_oom(ldb); goto failed; @@ -793,7 +794,7 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, goto failed; } } else { - status = ldap_bind_sasl(ildb->ldap, creds, global_loadparm); + status = ldap_bind_sasl(ildb->ldap, creds, ldb_get_opaque(ldb, "loadparm")); if (!NT_STATUS_IS_OK(status)) { ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s\n", ldap_errstr(ildb->ldap, module, status)); diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index aff730c178..8ee1994615 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -210,15 +210,15 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, #if (_SAMBA_BUILD_ >= 4) /* Must be after we have processed command line options */ - gensec_init(global_loadparm); + gensec_init(cmdline_lp_ctx); - if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb, global_loadparm))) { + if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb, cmdline_lp_ctx))) { goto failed; } if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) { goto failed; } - if (ldb_set_opaque(ldb, "loadparm", global_loadparm)) { + if (ldb_set_opaque(ldb, "loadparm", cmdline_lp_ctx)) { goto failed; } diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index ea4b754fe7..406eaeea3d 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -116,11 +116,11 @@ int main(int argc, const char **argv) } - h1 = open_backend(pc, global_loadparm, backend1, remote1); + h1 = open_backend(pc, cmdline_lp_ctx, backend1, remote1); if (h1 == NULL) return 1; - h2 = open_backend(pc, global_loadparm, backend2, remote2); + h2 = open_backend(pc, cmdline_lp_ctx, backend2, remote2); if (h2 == NULL) return 1; diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 441138832e..ddbedce18a 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -49,9 +49,9 @@ int main(int argc, char **argv) } if (remote) { - h = reg_common_open_remote (remote, global_loadparm, cmdline_credentials); + h = reg_common_open_remote (remote, cmdline_lp_ctx, cmdline_credentials); } else { - h = reg_common_open_local (cmdline_credentials, global_loadparm); + h = reg_common_open_local (cmdline_credentials, cmdline_lp_ctx); } if (h == NULL) diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 7169d7c9f8..2c692952fb 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -497,7 +497,7 @@ int main(int argc, char **argv) ctx = talloc_zero(NULL, struct regshell_context); if (remote != NULL) { - ctx->registry = reg_common_open_remote(remote, global_loadparm, + ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials); } else if (file != NULL) { ctx->current = reg_common_open_file(file, cmdline_credentials); @@ -506,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, global_loadparm); + ctx->registry = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx); } if (ctx->registry == NULL) diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index 6c21f2cbad..b267e11b43 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -129,11 +129,11 @@ int main(int argc, char **argv) } if (remote != NULL) { - h = reg_common_open_remote(remote, global_loadparm, cmdline_credentials); + h = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials); } else if (file != NULL) { start_key = reg_common_open_file(file, cmdline_credentials); } else { - h = reg_common_open_local(cmdline_credentials, global_loadparm); + h = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx); } if (h == NULL && start_key == NULL) diff --git a/source4/libcli/ldap/ldap_bind.c b/source4/libcli/ldap/ldap_bind.c index ba1ae90ebd..bd548be38e 100644 --- a/source4/libcli/ldap/ldap_bind.c +++ b/source4/libcli/ldap/ldap_bind.c @@ -44,7 +44,7 @@ NTSTATUS ldap_rebind(struct ldap_connection *conn) switch (conn->bind.type) { case LDAP_BIND_SASL: status = ldap_bind_sasl(conn, (struct cli_credentials *)conn->bind.creds, - global_loadparm); + conn->lp_ctx); break; case LDAP_BIND_SIMPLE: diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c index c859b4a4d1..906e9c2574 100644 --- a/source4/libcli/ldap/ldap_client.c +++ b/source4/libcli/ldap/ldap_client.c @@ -37,11 +37,12 @@ #include "param/param.h" -/* +/** create a new ldap_connection stucture. The event context is optional */ struct ldap_connection *ldap4_new_connection(TALLOC_CTX *mem_ctx, - struct event_context *ev) + struct loadparm_context *lp_ctx, + struct event_context *ev) { struct ldap_connection *conn; @@ -61,6 +62,8 @@ struct ldap_connection *ldap4_new_connection(TALLOC_CTX *mem_ctx, conn->next_messageid = 1; conn->event.event_ctx = ev; + conn->lp_ctx = lp_ctx; + /* set a reasonable request timeout */ conn->timeout = 60; @@ -352,7 +355,7 @@ struct composite_context *ldap_connect_send(struct ldap_connection *conn, } ctx = socket_connect_send(conn->sock, NULL, unix_addr, - 0, lp_name_resolve_order(global_loadparm), conn->event.event_ctx); + 0, lp_name_resolve_order(conn->lp_ctx), conn->event.event_ctx); ctx->async.fn = ldap_connect_recv_unix_conn; ctx->async.private_data = state; return result; @@ -365,7 +368,7 @@ struct composite_context *ldap_connect_send(struct ldap_connection *conn, } ctx = socket_connect_multi_send(state, conn->host, 1, &conn->port, - lp_name_resolve_order(global_loadparm), conn->event.event_ctx); + lp_name_resolve_order(conn->lp_ctx), conn->event.event_ctx); if (ctx == NULL) goto failed; ctx->async.fn = ldap_connect_recv_tcp_conn; @@ -394,7 +397,7 @@ static void ldap_connect_got_sock(struct composite_context *ctx, talloc_steal(conn, conn->sock); if (conn->ldaps) { struct socket_context *tls_socket; - char *cafile = private_path(conn->sock, global_loadparm, lp_tls_cafile(global_loadparm)); + char *cafile = private_path(conn->sock, conn->lp_ctx, lp_tls_cafile(conn->lp_ctx)); if (!cafile || !*cafile) { talloc_free(conn->sock); diff --git a/source4/libcli/ldap/ldap_client.h b/source4/libcli/ldap/ldap_client.h index d2a12ee8b5..d5ff441aff 100644 --- a/source4/libcli/ldap/ldap_client.h +++ b/source4/libcli/ldap/ldap_client.h @@ -51,6 +51,8 @@ struct ldap_request { /* main context for a ldap client connection */ struct ldap_connection { struct socket_context *sock; + struct loadparm_context *lp_ctx; + char *host; uint16_t port; bool ldaps; diff --git a/source4/nsswitch/wbinfo.c b/source4/nsswitch/wbinfo.c index 4303f36e4a..144c279279 100644 --- a/source4/nsswitch/wbinfo.c +++ b/source4/nsswitch/wbinfo.c @@ -52,7 +52,7 @@ static char winbind_separator_int(bool strict) return 0; } /* HACK: (this module should not call lp_ funtions) */ - return *lp_winbind_separator(global_loadparm); + return *lp_winbind_separator(cmdline_lp_ctx); } sep = response.data.info.winbind_separator; @@ -64,7 +64,7 @@ static char winbind_separator_int(bool strict) return 0; } /* HACK: (this module should not call lp_ funtions) */ - sep = *lp_winbind_separator(global_loadparm); + sep = *lp_winbind_separator(cmdline_lp_ctx); } return sep; @@ -89,7 +89,7 @@ static const char *get_winbind_domain(void) d_fprintf(stderr, "could not obtain winbind domain name!\n"); /* HACK: (this module should not call lp_ funtions) */ - return lp_workgroup(global_loadparm); + return lp_workgroup(cmdline_lp_ctx); } fstrcpy(winbind_domain, response.data.domain_name); @@ -1218,7 +1218,7 @@ int main(int argc, char **argv, char **envp) got_error = true; } - if (!wbinfo_auth_crap(global_loadparm, string_arg)) { + if (!wbinfo_auth_crap(cmdline_lp_ctx, string_arg)) { d_fprintf(stderr, "Could not authenticate user %s with " "challenge/response\n", string_arg); got_error = true; diff --git a/source4/ntvfs/common/brlock.c b/source4/ntvfs/common/brlock.c index ddf3219a9a..c87eca8aff 100644 --- a/source4/ntvfs/common/brlock.c +++ b/source4/ntvfs/common/brlock.c @@ -48,12 +48,13 @@ void brl_set_ops(const struct brlock_ops *new_ops) need the messaging_ctx to allow for pending lock notifications. */ struct brl_context *brl_init(TALLOC_CTX *mem_ctx, struct server_id server, + struct loadparm_context *lp_ctx, struct messaging_context *messaging_ctx) { if (ops == NULL) { brl_tdb_init_ops(); } - return ops->brl_init(mem_ctx, server, messaging_ctx); + return ops->brl_init(mem_ctx, server, lp_ctx, messaging_ctx); } struct brl_handle *brl_create_handle(TALLOC_CTX *mem_ctx, struct ntvfs_handle *ntvfs, DATA_BLOB *file_key) diff --git a/source4/ntvfs/common/brlock.h b/source4/ntvfs/common/brlock.h index 50f30ec276..aff30d138e 100644 --- a/source4/ntvfs/common/brlock.h +++ b/source4/ntvfs/common/brlock.h @@ -23,6 +23,7 @@ struct brlock_ops { struct brl_context *(*brl_init)(TALLOC_CTX *, struct server_id , + struct loadparm_context *lp_ctx, struct messaging_context *); struct brl_handle *(*brl_create_handle)(TALLOC_CTX *, struct ntvfs_handle *, DATA_BLOB *); NTSTATUS (*brl_lock)(struct brl_context *, diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c index 25642d5f5c..362a6d01e2 100644 --- a/source4/ntvfs/common/brlock_tdb.c +++ b/source4/ntvfs/common/brlock_tdb.c @@ -86,6 +86,7 @@ struct brl_handle { pending lock notifications. */ static struct brl_context *brl_tdb_init(TALLOC_CTX *mem_ctx, struct server_id server, + struct loadparm_context *lp_ctx, struct messaging_context *messaging_ctx) { struct brl_context *brl; @@ -95,7 +96,7 @@ static struct brl_context *brl_tdb_init(TALLOC_CTX *mem_ctx, struct server_id se return NULL; } - brl->db = db_tmp_open(brl, global_loadparm, "brlock.tdb", TDB_DEFAULT); + brl->db = db_tmp_open(brl, lp_ctx, "brlock.tdb", TDB_DEFAULT); if (brl->db == NULL) { talloc_free(brl); return NULL; diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c index 59990d2fc1..4826ca5c26 100644 --- a/source4/ntvfs/common/opendb.c +++ b/source4/ntvfs/common/opendb.c @@ -62,7 +62,7 @@ _PUBLIC_ struct odb_context *odb_init(TALLOC_CTX *mem_ctx, struct ntvfs_context *ntvfs_ctx) { if (ops == NULL) { - if (lp_parm_bool(global_loadparm, NULL, "ctdb", "opendb", false)) { + if (lp_parm_bool(ntvfs_ctx->lp_ctx, NULL, "ctdb", "opendb", false)) { odb_ctdb_init_ops(); } else { odb_tdb_init_ops(); diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c index 9172fe1580..3873afbdfa 100644 --- a/source4/ntvfs/ntvfs_base.c +++ b/source4/ntvfs/ntvfs_base.c @@ -199,10 +199,10 @@ NTSTATUS ntvfs_init_connection(TALLOC_CTX *mem_ctx, struct share_config *scfg, e return NT_STATUS_OK; } -NTSTATUS ntvfs_init(void) +NTSTATUS ntvfs_init(struct loadparm_context *lp_ctx) { init_module_fn static_init[] = STATIC_ntvfs_MODULES; - init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "ntvfs"); + init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "ntvfs"); run_init_functions(static_init); run_init_functions(shared_init); diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index c1e15976d2..8e5e5a6942 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -199,6 +199,7 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs, pvfs->brl_context = brl_init(pvfs, pvfs->ntvfs->ctx->server_id, + pvfs->ntvfs->ctx->lp_ctx, pvfs->ntvfs->ctx->msg_ctx); if (pvfs->brl_context == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; diff --git a/source4/param/share.c b/source4/param/share.c index 5bf5879290..7ee1d8037a 100644 --- a/source4/param/share.c +++ b/source4/param/share.c @@ -149,15 +149,11 @@ NTSTATUS share_get_context(TALLOC_CTX *mem_ctx, struct share_context **ctx) /* initialise the SHARE subsystem */ -NTSTATUS share_init(struct loadparm_context *lp_ctx) +NTSTATUS share_init(void) { init_module_fn static_init[] = STATIC_share_MODULES; - init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "share"); run_init_functions(static_init); - run_init_functions(shared_init); - - talloc_free(shared_init); return NT_STATUS_OK; } diff --git a/source4/param/share_classic.c b/source4/param/share_classic.c index ab1b4bf904..4a7fbcb263 100644 --- a/source4/param/share_classic.c +++ b/source4/param/share_classic.c @@ -45,6 +45,8 @@ static const char *sclassic_string_option(struct share_config *scfg, { struct loadparm_service *s = talloc_get_type(scfg->opaque, struct loadparm_service); + struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data, + struct loadparm_context); char *parm, *val; const char *ret; @@ -57,7 +59,7 @@ static const char *sclassic_string_option(struct share_config *scfg, *val = '\0'; val++; - ret = lp_parm_string(global_loadparm, s, parm, val); + ret = lp_parm_string(lp_ctx, s, parm, val); if (!ret) { ret = defval; } @@ -105,6 +107,8 @@ static int sclassic_int_option(struct share_config *scfg, const char *opt_name, { struct loadparm_service *s = talloc_get_type(scfg->opaque, struct loadparm_service); + struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data, + struct loadparm_context); char *parm, *val; int ret; @@ -117,7 +121,7 @@ static int sclassic_int_option(struct share_config *scfg, const char *opt_name, *val = '\0'; val++; - ret = lp_parm_int(global_loadparm, s, parm, val, defval); + ret = lp_parm_int(lp_ctx, s, parm, val, defval); if (!ret) { ret = defval; } @@ -161,6 +165,8 @@ static bool sclassic_bool_option(struct share_config *scfg, const char *opt_name { struct loadparm_service *s = talloc_get_type(scfg->opaque, struct loadparm_service); + struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data, + struct loadparm_context); char *parm, *val; bool ret; @@ -173,7 +179,7 @@ static bool sclassic_bool_option(struct share_config *scfg, const char *opt_name *val = '\0'; val++; - ret = lp_parm_bool(global_loadparm, s, parm, val, defval); + ret = lp_parm_bool(lp_ctx, s, parm, val, defval); talloc_free(parm); return ret; } @@ -228,6 +234,8 @@ static const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct shar { struct loadparm_service *s = talloc_get_type(scfg->opaque, struct loadparm_service); + struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data, + struct loadparm_context); char *parm, *val; const char **ret; @@ -240,7 +248,7 @@ static const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct shar *val = '\0'; val++; - ret = lp_parm_string_list(mem_ctx, global_loadparm, s, parm, val, ",;"); + ret = lp_parm_string_list(mem_ctx, lp_ctx, s, parm, val, ",;"); talloc_free(parm); return ret; } diff --git a/source4/param/tests/share.c b/source4/param/tests/share.c index 26af71d06f..1f8ecb2d84 100644 --- a/source4/param/tests/share.c +++ b/source4/param/tests/share.c @@ -197,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(global_loadparm); + share_init(); tcase = torture_suite_add_tcase(suite, "ldb"); torture_tcase_set_fixture(tcase, setup_ldb, teardown); diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 467cbca418..35b3653026 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -49,7 +49,7 @@ static NTSTATUS make_connection_scfg(struct smbsrv_request *req, req->smb_conn->negotiate.protocol, req->smb_conn->connection->event.ctx, req->smb_conn->connection->msg_ctx, - global_loadparm, + req->smb_conn->lp_ctx, req->smb_conn->connection->server_id, &tcon->ntvfs); if (!NT_STATUS_IS_OK(status)) { diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 4393d38c0d..6d0d98554c 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -294,7 +294,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon req->smb_conn->negotiate.protocol, req->smb_conn->connection->event.ctx, req->smb_conn->connection->msg_ctx, - global_loadparm, + req->smb_conn->lp_ctx, req->smb_conn->connection->server_id, &tcon->ntvfs); if (!NT_STATUS_IS_OK(status)) { diff --git a/source4/smbd/server.c b/source4/smbd/server.c index 434f8882c1..e7d7d1a7fc 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -267,36 +267,36 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ become_daemon(true); } - cleanup_tmp_files(global_loadparm); + cleanup_tmp_files(cmdline_lp_ctx); - if (!directory_exist(lp_lockdir(global_loadparm))) { - mkdir(lp_lockdir(global_loadparm), 0755); + if (!directory_exist(lp_lockdir(cmdline_lp_ctx))) { + mkdir(lp_lockdir(cmdline_lp_ctx), 0755); } - pidfile_create(lp_piddir(global_loadparm), binary_name); + pidfile_create(lp_piddir(cmdline_lp_ctx), binary_name); /* Do *not* remove this, until you have removed * passdb/secrets.c, and proved that Samba still builds... */ /* Setup the SECRETS subsystem */ - if (!secrets_init(global_loadparm)) { + if (!secrets_init(cmdline_lp_ctx)) { exit(1); } ldb_global_init(); /* FIXME: */ - share_init(global_loadparm); + share_init(); - gensec_init(global_loadparm); /* FIXME: */ + gensec_init(cmdline_lp_ctx); /* FIXME: */ - ntptr_init(global_loadparm); /* FIXME: maybe run this in the initialization function + ntptr_init(cmdline_lp_ctx); /* FIXME: maybe run this in the initialization function of the spoolss RPC server instead? */ - ntvfs_init(); /* FIXME: maybe run this in the initialization functions + ntvfs_init(cmdline_lp_ctx); /* FIXME: maybe run this in the initialization functions of the SMB[,2] server instead? */ - process_model_init(global_loadparm); + process_model_init(cmdline_lp_ctx); - shared_init = load_samba_modules(NULL, global_loadparm, "service"); + shared_init = load_samba_modules(NULL, cmdline_lp_ctx, "service"); run_init_functions(static_init); run_init_functions(shared_init); @@ -313,7 +313,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ } /* initialise clustering if needed */ - cluster_ctdb_init(global_loadparm, event_ctx, model); + cluster_ctdb_init(cmdline_lp_ctx, event_ctx, model); if (opt_interactive) { /* catch EOF on stdin */ @@ -334,8 +334,8 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ } DEBUG(0,("%s: using '%s' process model\n", binary_name, model)); - status = server_service_startup(event_ctx, global_loadparm, model, - lp_server_services(global_loadparm)); + status = server_service_startup(event_ctx, cmdline_lp_ctx, model, + lp_server_services(cmdline_lp_ctx)); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("Starting Services failed - %s\n", nt_errstr(status))); return 1; diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index e8e531a119..25512b9567 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -2197,7 +2197,7 @@ static bool split_unc_name(const char *unc, char **server, char **share) argc -= NSERVERS; argv += NSERVERS; - global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context()); + lp_ctx = loadparm_init(talloc_autofree_context()); lp_load(lp_ctx, dyn_CONFIGFILE); servers[0].credentials = cli_credentials_init(talloc_autofree_context()); diff --git a/source4/torture/ldap/basic.c b/source4/torture/ldap/basic.c index 76d412a7cd..358bf53590 100644 --- a/source4/torture/ldap/basic.c +++ b/source4/torture/ldap/basic.c @@ -42,14 +42,15 @@ static bool test_bind_simple(struct ldap_connection *conn, const char *userdn, c return ret; } -static bool test_bind_sasl(struct ldap_connection *conn, struct cli_credentials *creds) +static bool test_bind_sasl(struct torture_context *tctx, + struct ldap_connection *conn, struct cli_credentials *creds) { NTSTATUS status; bool ret = true; printf("Testing sasl bind as user\n"); - status = torture_ldap_bind_sasl(conn, creds, global_loadparm); + status = torture_ldap_bind_sasl(conn, creds, tctx->lp_ctx); if (!NT_STATUS_IS_OK(status)) { ret = false; } @@ -205,7 +206,7 @@ bool torture_ldap_basic(struct torture_context *torture) url = talloc_asprintf(mem_ctx, "ldap://%s/", host); - status = torture_ldap_connection(mem_ctx, &conn, url); + status = torture_ldap_connection(torture, &conn, url); if (!NT_STATUS_IS_OK(status)) { return false; } @@ -220,7 +221,7 @@ bool torture_ldap_basic(struct torture_context *torture) ret = false; } - if (!test_bind_sasl(conn, cmdline_credentials)) { + if (!test_bind_sasl(torture, conn, cmdline_credentials)) { ret = false; } diff --git a/source4/torture/ldap/common.c b/source4/torture/ldap/common.c index b03a6d8113..11b11dcc00 100644 --- a/source4/torture/ldap/common.c +++ b/source4/torture/ldap/common.c @@ -54,8 +54,9 @@ _PUBLIC_ NTSTATUS torture_ldap_bind_sasl(struct ldap_connection *conn, } /* open a ldap connection to a server */ -_PUBLIC_ NTSTATUS torture_ldap_connection(TALLOC_CTX *mem_ctx, struct ldap_connection **conn, - const char *url) +_PUBLIC_ NTSTATUS torture_ldap_connection(struct torture_context *tctx, + struct ldap_connection **conn, + const char *url) { NTSTATUS status; @@ -64,7 +65,7 @@ _PUBLIC_ NTSTATUS torture_ldap_connection(TALLOC_CTX *mem_ctx, struct ldap_conne return NT_STATUS_INVALID_PARAMETER; } - *conn = ldap4_new_connection(mem_ctx, NULL); + *conn = ldap4_new_connection(tctx, tctx->lp_ctx, NULL); status = ldap_connect(*conn, url); if (!NT_STATUS_IS_OK(status)) { @@ -76,17 +77,17 @@ _PUBLIC_ NTSTATUS torture_ldap_connection(TALLOC_CTX *mem_ctx, struct ldap_conne } /* open a ldap connection to a server */ -NTSTATUS torture_ldap_connection2(TALLOC_CTX *mem_ctx, struct ldap_connection **conn, +NTSTATUS torture_ldap_connection2(struct torture_context *tctx, struct ldap_connection **conn, const char *url, const char *userdn, const char *password) { NTSTATUS status; - status = torture_ldap_connection(mem_ctx, conn, url); + status = torture_ldap_connection(tctx, conn, url); NT_STATUS_NOT_OK_RETURN(status); status = ldap_bind_simple(*conn, userdn, password); if (!NT_STATUS_IS_OK(status)) { - printf("Failed a simple ldap bind - %s\n", ldap_errstr(*conn, mem_ctx, status)); + printf("Failed a simple ldap bind - %s\n", ldap_errstr(*conn, tctx, status)); } return status; diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c index d51c2692d7..82e9b416b3 100644 --- a/source4/torture/locktest.c +++ b/source4/torture/locktest.c @@ -565,7 +565,7 @@ static void usage(void) argc -= NSERVERS; argv += NSERVERS; - global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context()); + lp_ctx = loadparm_init(talloc_autofree_context()); lp_load(lp_ctx, dyn_CONFIGFILE); servers[0] = cli_credentials_init(talloc_autofree_context()); diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c index 19629d8770..1dfefc15ed 100644 --- a/source4/torture/locktest2.c +++ b/source4/torture/locktest2.c @@ -484,7 +484,7 @@ static void usage(void) argc -= 4; argv += 4; - global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context()); + lp_ctx = loadparm_init(talloc_autofree_context()); lp_load(lp_ctx, dyn_CONFIGFILE); if (getenv("USER")) { diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c index 612b96e4f7..dab8193753 100644 --- a/source4/torture/masktest.c +++ b/source4/torture/masktest.c @@ -303,7 +303,7 @@ static void usage(void) argc -= 1; argv += 1; - lp_ctx = global_loadparm = loadparm_init(talloc_autofree_context()); + lp_ctx = loadparm_init(talloc_autofree_context()); lp_load(lp_ctx, dyn_CONFIGFILE); credentials = cli_credentials_init(talloc_autofree_context()); diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c index 8f15f6f096..4417285e04 100644 --- a/source4/torture/rpc/dssync.c +++ b/source4/torture/rpc/dssync.c @@ -173,7 +173,8 @@ static struct DsSyncTest *test_create_context(struct torture_context *tctx) return ctx; } -static bool _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncBindInfo *b) +static bool _test_DsBind(struct torture_context *tctx, + struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncBindInfo *b) { NTSTATUS status; bool ret = true; @@ -182,7 +183,7 @@ static bool _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credent status = dcerpc_pipe_connect_b(ctx, &b->pipe, ctx->drsuapi_binding, &ndr_table_drsuapi, - credentials, event, global_loadparm); + credentials, event, tctx->lp_ctx); if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status)); @@ -223,12 +224,13 @@ static bool _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credent return ret; } -static bool test_LDAPBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncLDAPInfo *l) +static bool test_LDAPBind(struct torture_context *tctx, struct DsSyncTest *ctx, + struct cli_credentials *credentials, struct DsSyncLDAPInfo *l) { NTSTATUS status; bool ret = true; - status = torture_ldap_connection(ctx, &l->conn, ctx->ldap_url); + status = torture_ldap_connection(tctx, &l->conn, ctx->ldap_url); if (!NT_STATUS_IS_OK(status)) { printf("failed to connect to LDAP: %s\n", ctx->ldap_url); return false; @@ -236,7 +238,7 @@ static bool test_LDAPBind(struct DsSyncTest *ctx, struct cli_credentials *creden printf("connected to LDAP: %s\n", ctx->ldap_url); - status = torture_ldap_bind_sasl(l->conn, credentials, global_loadparm); + status = torture_ldap_bind_sasl(l->conn, credentials, tctx->lp_ctx); if (!NT_STATUS_IS_OK(status)) { printf("failed to bind to LDAP:\n"); return false; @@ -811,16 +813,16 @@ bool torture_rpc_dssync(struct torture_context *torture) mem_ctx = talloc_init("torture_rpc_dssync"); ctx = test_create_context(torture); - ret &= _test_DsBind(ctx, ctx->admin.credentials, &ctx->admin.drsuapi); + ret &= _test_DsBind(torture, ctx, ctx->admin.credentials, &ctx->admin.drsuapi); if (!ret) { return ret; } - ret &= test_LDAPBind(ctx, ctx->admin.credentials, &ctx->admin.ldap); + ret &= test_LDAPBind(torture, ctx, ctx->admin.credentials, &ctx->admin.ldap); if (!ret) { return ret; } ret &= test_GetInfo(torture, ctx); - ret &= _test_DsBind(ctx, ctx->new_dc.credentials, &ctx->new_dc.drsuapi); + ret &= _test_DsBind(torture, ctx, ctx->new_dc.credentials, &ctx->new_dc.drsuapi); if (!ret) { return ret; } diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c index 5e7a4469e4..bdbdc6b0c6 100644 --- a/source4/torture/rpc/spoolss_notify.c +++ b/source4/torture/rpc/spoolss_notify.c @@ -289,7 +289,7 @@ struct torture_suite *torture_rpc_spoolss_notify(TALLOC_CTX *mem_ctx) struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite, "notify", &ndr_table_spoolss); - ntvfs_init(); + ntvfs_init(global_loadparm); torture_rpc_tcase_add_test(tcase, "testRFFPCNEx", test_RFFPCNEx); return suite; diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index 33e80a4b97..b35e623610 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -572,36 +572,36 @@ int main(int argc,char *argv[]) while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_LOADFILE: - lp_set_cmdline(global_loadparm, "torture:loadfile", poptGetOptArg(pc)); + lp_set_cmdline(cmdline_lp_ctx, "torture:loadfile", poptGetOptArg(pc)); break; case OPT_UNCLIST: - lp_set_cmdline(global_loadparm, "torture:unclist", poptGetOptArg(pc)); + lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc)); break; case OPT_TIMELIMIT: - lp_set_cmdline(global_loadparm, "torture:timelimit", poptGetOptArg(pc)); + lp_set_cmdline(cmdline_lp_ctx, "torture:timelimit", poptGetOptArg(pc)); break; case OPT_NUMPROGS: - lp_set_cmdline(global_loadparm, "torture:nprocs", poptGetOptArg(pc)); + lp_set_cmdline(cmdline_lp_ctx, "torture:nprocs", poptGetOptArg(pc)); break; case OPT_DNS: - parse_dns(global_loadparm, poptGetOptArg(pc)); + parse_dns(cmdline_lp_ctx, poptGetOptArg(pc)); break; case OPT_DANGEROUS: - lp_set_cmdline(global_loadparm, "torture:dangerous", "Yes"); + lp_set_cmdline(cmdline_lp_ctx, "torture:dangerous", "Yes"); break; case OPT_ASYNC: - lp_set_cmdline(global_loadparm, "torture:async", "Yes"); + lp_set_cmdline(cmdline_lp_ctx, "torture:async", "Yes"); break; case OPT_SMB_PORTS: - lp_set_cmdline(global_loadparm, "smb ports", poptGetOptArg(pc)); + lp_set_cmdline(cmdline_lp_ctx, "smb ports", poptGetOptArg(pc)); break; } } if (strcmp(target, "samba3") == 0) { - lp_set_cmdline(global_loadparm, "torture:samba3", "true"); + lp_set_cmdline(cmdline_lp_ctx, "torture:samba3", "true"); } else if (strcmp(target, "samba4") == 0) { - lp_set_cmdline(global_loadparm, "torture:samba4", "true"); + lp_set_cmdline(cmdline_lp_ctx, "torture:samba4", "true"); } if (max_runtime) { @@ -658,7 +658,7 @@ int main(int argc,char *argv[]) exit(1); } - if (!parse_target(global_loadparm, argv_new[1])) { + if (!parse_target(cmdline_lp_ctx, argv_new[1])) { usage(pc); exit(1); } @@ -690,7 +690,7 @@ int main(int argc,char *argv[]) torture->outputdir = pwd; } - torture->lp_ctx = global_loadparm; + torture->lp_ctx = cmdline_lp_ctx; if (argc_new == 0) { printf("You must specify a test to run, or 'ALL'\n"); diff --git a/source4/torture/torture.c b/source4/torture/torture.c index 44a0d3b4c2..f0538c0362 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -65,7 +65,7 @@ struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx, int torture_init(void) { init_module_fn static_init[] = STATIC_torture_MODULES; - init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "torture"); + init_module_fn *shared_init = load_samba_modules(NULL, cmdline_lp_ctx, "torture"); run_init_functions(static_init); run_init_functions(shared_init); diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 2741f485cc..2c95e9033d 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -193,7 +193,7 @@ static int binary_net(int argc, const char **argv) ZERO_STRUCTP(ctx); ctx->mem_ctx = mem_ctx; - ctx->lp_ctx = global_loadparm; + ctx->lp_ctx = cmdline_lp_ctx; ctx->credentials = cmdline_credentials; rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c index 9f121390f6..a3e33e2748 100644 --- a/source4/utils/nmblookup.c +++ b/source4/utils/nmblookup.c @@ -179,7 +179,7 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock, } -static bool process_one(const char *name, int nbt_port) +static bool process_one(struct loadparm_context *lp_ctx, const char *name, int nbt_port) { TALLOC_CTX *tmp_ctx = talloc_new(NULL); enum nbt_name_type node_type = NBT_NAME_CLIENT; @@ -241,9 +241,9 @@ static bool process_one(const char *name, int nbt_port) status = do_node_query(nbtsock, options.unicast_address, nbt_port, node_name, node_type, false); } else { - int i, num_interfaces = iface_count(global_loadparm); + int i, num_interfaces = iface_count(lp_ctx); for (i=0;ipriv_data, "PW\n"); credentials->priv_data = NULL; - manage_squid_request(NUM_HELPER_MODES /* bogus */, manage_gensec_get_pw_request, (void **)&password); + manage_squid_request(cmdline_lp_ctx, NUM_HELPER_MODES /* bogus */, manage_gensec_get_pw_request, (void **)&password); return password; } @@ -897,7 +898,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod } } -static void manage_squid_request(enum stdio_helper_mode helper_mode, +static void manage_squid_request(struct loadparm_context *lp_ctx, enum stdio_helper_mode helper_mode, stdio_helper_function fn, void **private2) { char *buf; @@ -1000,17 +1001,18 @@ static void manage_squid_request(enum stdio_helper_mode helper_mode, private = &normal_private; } - fn(helper_mode, global_loadparm, c, length, private, mux_id, private2); + fn(helper_mode, lp_ctx, c, length, private, mux_id, private2); talloc_free(buf); } -static void squid_stream(enum stdio_helper_mode stdio_mode, +static void squid_stream(struct loadparm_context *lp_ctx, + enum stdio_helper_mode stdio_mode, stdio_helper_function fn) { /* initialize FDescs */ x_setbuf(x_stdout, NULL); x_setbuf(x_stderr, NULL); while(1) { - manage_squid_request(stdio_mode, fn, NULL); + manage_squid_request(lp_ctx, stdio_mode, fn, NULL); } } @@ -1093,17 +1095,17 @@ int main(int argc, const char **argv) return 1; } - gensec_init(global_loadparm); + gensec_init(cmdline_lp_ctx); if (opt_domain == NULL) { - opt_domain = lp_workgroup(global_loadparm); + opt_domain = lp_workgroup(cmdline_lp_ctx); } if (helper_protocol) { int i; for (i=0; idomain->libnet_ctx->samr.sid = state->domain->info->sid; state->domain->ldap_conn = - ldap4_new_connection(state->domain, state->ctx->event_ctx); + ldap4_new_connection(state->domain, state->domain->libnet_ctx->lp_ctx, state->ctx->event_ctx); composite_nomem(state->domain->ldap_conn, state->ctx); ldap_url = talloc_asprintf(state, "ldap://%s/", -- cgit