1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r26355: Eliminate global_loadparm in more places.

(This used to be commit 5d589a0d94)
This commit is contained in:
Jelmer Vernooij 2007-12-10 04:33:16 +01:00 committed by Stefan Metzmacher
parent 4a36b71675
commit b65dba2245
42 changed files with 136 additions and 115 deletions

View File

@ -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 : */

View File

@ -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));
}

View File

@ -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",

View File

@ -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());

View File

@ -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 */

View File

@ -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));

View File

@ -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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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:

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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 *,

View File

@ -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;

View File

@ -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();

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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)) {

View File

@ -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)) {

View File

@ -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;

View File

@ -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());

View File

@ -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;
}

View File

@ -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;

View File

@ -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());

View File

@ -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")) {

View File

@ -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());

View File

@ -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;
}

View File

@ -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;

View File

@ -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");

View File

@ -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);

View File

@ -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);

View File

@ -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;i<num_interfaces;i++) {
const char *bcast = iface_n_bcast(global_loadparm, i);
const char *bcast = iface_n_bcast(lp_ctx, i);
if (bcast == NULL) continue;
status = do_node_query(nbtsock, bcast, nbt_port,
node_name, node_type, true);
@ -353,7 +353,7 @@ int main(int argc, const char *argv[])
while (poptPeekArg(pc)) {
const char *name = poptGetArg(pc);
ret &= process_one(name, lp_nbt_port(global_loadparm));
ret &= process_one(cmdline_lp_ctx, name, lp_nbt_port(cmdline_lp_ctx));
}
poptFreeContext(pc);

View File

@ -77,7 +77,8 @@ static void manage_ntlm_server_1_request (enum stdio_helper_mode stdio_helper_mo
char *buf, int length, void **private,
unsigned int mux_id, void **private2);
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);
static const struct {
@ -329,7 +330,7 @@ static const char *get_password(struct cli_credentials *credentials)
mux_printf((unsigned int)credentials->priv_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; i<NUM_HELPER_MODES; i++) {
if (strcmp(helper_protocol, stdio_helper_protocols[i].name) == 0) {
squid_stream(stdio_helper_protocols[i].mode, stdio_helper_protocols[i].fn);
squid_stream(cmdline_lp_ctx, stdio_helper_protocols[i].mode, stdio_helper_protocols[i].fn);
exit(0);
}
}
@ -1123,7 +1125,7 @@ int main(int argc, const char **argv)
}
if (opt_workstation == NULL) {
opt_workstation = lp_netbios_name(global_loadparm);
opt_workstation = lp_netbios_name(cmdline_lp_ctx);
}
if (!opt_password) {
@ -1133,7 +1135,7 @@ int main(int argc, const char **argv)
{
char *user;
asprintf(&user, "%s%c%s", opt_domain, *lp_winbind_separator(global_loadparm), opt_username);
asprintf(&user, "%s%c%s", opt_domain, *lp_winbind_separator(cmdline_lp_ctx), opt_username);
if (!check_plaintext_auth(user, opt_password, true)) {
return 1;
}

View File

@ -234,7 +234,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c
}
*/
lp_ctx = global_loadparm;
lp_ctx = cmdline_lp_ctx;
/* We need this to force the output */
lp_set_cmdline(lp_ctx, "log level", "2");

View File

@ -405,7 +405,7 @@ static void init_domain_recv_samr(struct composite_context *ctx)
state->domain->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/",