1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-22 05:57:43 +03:00

r25446: Merge some changes I made on the way home from SFO:

2007-09-29 More higher-level passing around of lp_ctx.
2007-09-29 Fix warning.
2007-09-29 Pass loadparm contexts on a higher level.
2007-09-29 Avoid using global loadparm context.
(This used to be commit 3468952e771ab31f90b6c374ade01c5550810f42)
This commit is contained in:
Jelmer Vernooij 2007-10-01 18:52:55 +00:00 committed by Gerald (Jerry) Carter
parent 4d7273715f
commit 2f3551ca7c
63 changed files with 198 additions and 172 deletions

View File

@ -519,7 +519,7 @@ NTSTATUS auth_init(void)
if (initialized) return NT_STATUS_OK;
initialized = True;
shared_init = load_samba_modules(NULL, "auth");
shared_init = load_samba_modules(NULL, global_loadparm, "auth");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -342,14 +342,16 @@ static NTSTATUS authsam_want_check(struct auth_method_context *ctx,
TALLOC_CTX *mem_ctx,
const struct auth_usersupplied_info *user_info)
{
BOOL is_local_name, is_my_domain;
bool is_local_name, is_my_domain;
if (!user_info->mapped.account_name || !*user_info->mapped.account_name) {
return NT_STATUS_NOT_IMPLEMENTED;
}
is_local_name = is_myname(user_info->mapped.domain_name);
is_my_domain = strequal(user_info->mapped.domain_name, lp_workgroup(global_loadparm));
is_local_name = lp_is_myname(global_loadparm,
user_info->mapped.domain_name);
is_my_domain = lp_is_mydomain(global_loadparm,
user_info->mapped.domain_name);
/* check whether or not we service this domain/workgroup name */
switch (lp_server_role(global_loadparm)) {

View File

@ -195,8 +195,8 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
struct smbcli_state *cli;
static uint8_t badpass[24];
static fstring baduser;
static BOOL tested_password_server = False;
static BOOL bad_password_server = False;
static bool tested_password_server = false;
static bool bad_password_server = false;
NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
BOOL locally_made_cli = False;
@ -206,7 +206,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
* password file.
*/
if(is_myname(user_info->domain.str)) {
if (lp_is_myname(global_loadparm, user_info->domain.str)) {
DEBUG(3,("check_smbserver_security: Requested domain was for this machine.\n"));
return NT_STATUS_LOGON_FAILURE;
}

View File

@ -308,7 +308,7 @@ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
} else {
keytab = ldb_msg_find_attr_as_string(msgs[0], "privateKeytab", NULL);
if (keytab) {
keytab = talloc_asprintf(mem_ctx, "FILE:%s", private_path(mem_ctx, keytab));
keytab = talloc_asprintf(mem_ctx, "FILE:%s", private_path(mem_ctx, global_loadparm, keytab));
if (keytab) {
cli_credentials_set_keytab_name(cred, keytab, CRED_SPECIFIED);
}

View File

@ -1269,7 +1269,7 @@ NTSTATUS gensec_init(void)
if (initialized) return NT_STATUS_OK;
initialized = True;
shared_init = load_samba_modules(NULL, "gensec");
shared_init = load_samba_modules(NULL, global_loadparm, "gensec");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -41,14 +41,15 @@ struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx)
"computerName: CASE_INSENSITIVE\n" \
"flatname: CASE_INSENSITIVE\n";
path = smbd_tmp_path(mem_ctx, "schannel.ldb");
path = smbd_tmp_path(mem_ctx, global_loadparm, "schannel.ldb");
if (!path) {
return NULL;
}
existed = file_exist(path);
ldb = ldb_wrap_connect(mem_ctx, path, system_session(mem_ctx),
ldb = ldb_wrap_connect(mem_ctx, global_loadparm, path,
system_session(mem_ctx),
NULL, LDB_FLG_NOSYNC, NULL);
talloc_free(path);
if (!ldb) {

View File

@ -393,7 +393,7 @@ krb5_error_code smb_krb5_init_context(void *parent_ctx,
talloc_set_destructor(*smb_krb5_context, smb_krb5_context_destroy_1);
config_file = config_path(tmp_ctx, "krb5.conf");
config_file = config_path(tmp_ctx, global_loadparm, "krb5.conf");
if (!config_file) {
talloc_free(tmp_ctx);
return ENOMEM;

View File

@ -58,7 +58,7 @@ static struct tdb_wrap *local_tdb_tmp_open(struct cluster_ops *ops,
TALLOC_CTX *mem_ctx, const char *dbname,
int flags)
{
char *path = smbd_tmp_path(mem_ctx, dbname);
char *path = smbd_tmp_path(mem_ctx, global_loadparm, dbname);
struct tdb_wrap *w;
w = tdb_wrap_open(mem_ctx, path, 0, flags,
O_RDWR|O_CREAT, 0600);

View File

@ -45,7 +45,8 @@ struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx,
struct auth_session_info *session_info)
{
struct ldb_context *ldb;
ldb = ldb_wrap_connect(mem_ctx, lp_sam_url(global_loadparm), session_info,
ldb = ldb_wrap_connect(mem_ctx, global_loadparm,
lp_sam_url(global_loadparm), session_info,
NULL, 0, NULL);
if (!ldb) {
return NULL;

View File

@ -55,7 +55,9 @@ static int map_ldb_error(struct ldb_context *ldb, int err, const char **errstrin
*/
NTSTATUS ldapsrv_backend_Init(struct ldapsrv_connection *conn)
{
conn->ldb = ldb_wrap_connect(conn, lp_sam_url(global_loadparm), conn->session_info,
conn->ldb = ldb_wrap_connect(conn,
global_loadparm,
lp_sam_url(global_loadparm), conn->session_info,
NULL, conn->global_catalog ? LDB_FLG_RDONLY : 0, NULL);
if (conn->ldb == NULL) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;

View File

@ -37,7 +37,7 @@
*/
static BOOL dont_ask;
static bool dont_ask;
enum opt { OPT_SIMPLE_BIND_DN, OPT_PASSWORD, OPT_KERBEROS };

View File

@ -103,6 +103,7 @@ static int ldb_wrap_destructor(struct ldb_context *ldb)
TODO: We need an error_string parameter
*/
struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
const char *url,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
@ -121,7 +122,7 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
}
ldb_set_modules_dir(ldb,
talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(global_loadparm)));
talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx)));
/* we want to use the existing event context if possible. This
relies on the fact that in smbd, everything is a child of
@ -143,7 +144,7 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
return NULL;
}
if (strcmp(lp_sam_url(global_loadparm), url) == 0) {
if (strcmp(lp_sam_url(lp_ctx), url) == 0) {
dsdb_set_global_schema(ldb);
}
@ -157,14 +158,14 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
real_url = private_path(ldb, url);
real_url = private_path(ldb, lp_ctx, url);
if (real_url == NULL) {
talloc_free(ldb);
return NULL;
}
/* allow admins to force non-sync ldb for all databases */
if (lp_parm_bool(global_loadparm, NULL, "ldb", "nosync", false)) {
if (lp_parm_bool(lp_ctx, NULL, "ldb", "nosync", false)) {
flags |= LDB_FLG_NOSYNC;
}

View File

@ -31,5 +31,6 @@ struct auth_session_info;
struct ldb_message;
struct ldb_dn;
struct cli_credentials;
struct loadparm_context;
#include "lib/db_wrap_proto.h"

View File

@ -241,7 +241,7 @@ struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, const char *name, int td
/* the name passed in should not be a full path, it should be
just be the db name */
path = smbd_tmp_path(result, name);
path = smbd_tmp_path(result, global_loadparm, name);
db_tdb->wtdb = tdb_wrap_open(db_tdb, path, 0, tdb_flags,
O_CREAT|O_RDWR, 0666);

View File

@ -105,7 +105,7 @@ static void event_backend_init(void)
init_module_fn static_init[] = STATIC_LIBEVENTS_MODULES;
init_module_fn *shared_init;
if (event_backends) return;
shared_init = load_samba_modules(NULL, "LIBEVENTS");
shared_init = load_samba_modules(NULL, global_loadparm, "LIBEVENTS");
run_init_functions(static_init);
run_init_functions(shared_init);
#else

View File

@ -55,7 +55,7 @@ BOOL gencache_init(void)
/* skip file open if it's already opened */
if (cache) return True;
cache_fname = lock_path(mem_ctx, "gencache.tdb");
cache_fname = lock_path(mem_ctx, global_loadparm, "gencache.tdb");
if (cache_fname != NULL) {
DEBUG(5, ("Opening cache file at %s\n", cache_fname));
} else {

View File

@ -76,13 +76,12 @@ struct irpc_request {
} async;
};
struct loadparm_context;
typedef void (*msg_callback_t)(struct messaging_context *msg, void *private,
uint32_t msg_type,
struct server_id server_id, DATA_BLOB *data);
struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
struct server_id server_id,
struct event_context *ev);
NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server,
uint32_t msg_type, DATA_BLOB *data);
NTSTATUS messaging_register(struct messaging_context *msg, void *private,
@ -91,9 +90,11 @@ NTSTATUS messaging_register(struct messaging_context *msg, void *private,
NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private,
msg_callback_t fn, uint32_t *msg_type);
struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
const char *dir,
struct server_id server_id,
struct event_context *ev);
struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx,
const char *dir,
struct event_context *ev);
NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id server,
uint32_t msg_type, void *ptr);

View File

@ -530,13 +530,13 @@ static int messaging_destructor(struct messaging_context *msg)
create the listening socket and setup the dispatcher
*/
struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
const char *dir,
struct server_id server_id,
struct event_context *ev)
{
struct messaging_context *msg;
NTSTATUS status;
struct socket_address *path;
char *dir;
msg = talloc_zero(mem_ctx, struct messaging_context);
if (msg == NULL) {
@ -555,11 +555,9 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
}
/* create the messaging directory if needed */
dir = smbd_tmp_path(msg, "messaging");
mkdir(dir, 0700);
talloc_free(dir);
msg->base_path = smbd_tmp_path(msg, "messaging");
msg->base_path = talloc_reference(msg, dir);
msg->path = messaging_path(msg, server_id);
msg->server_id = server_id;
msg->idr = idr_init(msg);
@ -610,12 +608,13 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
A hack, for the short term until we get 'client only' messaging in place
*/
struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx,
const char *dir,
struct event_context *ev)
{
struct server_id id;
ZERO_STRUCT(id);
id.id = random() % 0x10000000;
return messaging_init(mem_ctx, id, ev);
return messaging_init(mem_ctx, dir, id, ev);
}
/*
a list of registered irpc server functions

View File

@ -23,6 +23,7 @@
#include "lib/ldb/include/ldb_errors.h"
#include "db_wrap.h"
#include "librpc/gen_ndr/winreg.h"
#include "param/param.h"
static struct hive_operations reg_backend_ldb;
@ -317,9 +318,9 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
}
WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
struct hive_key **k)
struct auth_session_info *session_info,
struct cli_credentials *credentials,
struct hive_key **k)
{
struct ldb_key_data *kd;
struct ldb_context *wrap;
@ -327,7 +328,8 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
if (location == NULL)
return WERR_INVALID_PARAM;
wrap = ldb_wrap_connect(parent_ctx, location, session_info, credentials, 0, NULL);
wrap = ldb_wrap_connect(parent_ctx, global_loadparm,
location, session_info, credentials, 0, NULL);
if (wrap == NULL) {
DEBUG(1, (__FILE__": unable to connect\n"));

View File

@ -25,11 +25,11 @@
* @brief Samba-specific registry functions
*/
static WERROR mount_samba_hive(struct registry_context *ctx,
struct auth_session_info *auth_info,
struct cli_credentials *creds,
const char *name,
uint32_t hive_id)
static WERROR mount_samba_hive(struct registry_context *ctx,
struct auth_session_info *auth_info,
struct cli_credentials *creds,
const char *name,
uint32_t hive_id)
{
WERROR error;
struct hive_key *hive;

View File

@ -357,11 +357,11 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx)
struct tls_params *params;
int ret;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
const char *keyfile = private_path(tmp_ctx, lp_tls_keyfile(global_loadparm));
const char *certfile = private_path(tmp_ctx, lp_tls_certfile(global_loadparm));
const char *cafile = private_path(tmp_ctx, lp_tls_cafile(global_loadparm));
const char *crlfile = private_path(tmp_ctx, lp_tls_crlfile(global_loadparm));
const char *dhpfile = private_path(tmp_ctx, lp_tls_dhpfile(global_loadparm));
const char *keyfile = private_path(tmp_ctx, global_loadparm, lp_tls_keyfile(global_loadparm));
const char *certfile = private_path(tmp_ctx, global_loadparm, lp_tls_certfile(global_loadparm));
const char *cafile = private_path(tmp_ctx, global_loadparm, lp_tls_cafile(global_loadparm));
const char *crlfile = private_path(tmp_ctx, global_loadparm, lp_tls_crlfile(global_loadparm));
const char *dhpfile = private_path(tmp_ctx, global_loadparm, lp_tls_dhpfile(global_loadparm));
void tls_cert_generate(TALLOC_CTX *, const char *, const char *, const char *);
params = talloc(mem_ctx, struct tls_params);
@ -565,7 +565,7 @@ struct socket_context *tls_init_client(struct socket_context *socket,
}
new_sock->private_data = tls;
cafile = private_path(tls, lp_tls_cafile(global_loadparm));
cafile = private_path(tls, global_loadparm, lp_tls_cafile(global_loadparm));
if (!cafile || !*cafile) {
goto failed;
}

View File

@ -57,7 +57,8 @@ BOOL smbcli_transport_establish(struct smbcli_state *cli,
/* wrapper around smb_raw_negotiate() */
NTSTATUS smbcli_negprot(struct smbcli_state *cli)
{
return smb_raw_negotiate(cli->transport, lp_cli_maxprotocol(global_loadparm));
return smb_raw_negotiate(cli->transport,
lp_cli_maxprotocol(global_loadparm));
}
/* wrapper around smb_raw_sesssetup() */

View File

@ -147,7 +147,7 @@ static void finddcs_name_resolved(struct composite_context *ctx)
state->r.in.ip_address = state->dcs[0].address;
state->r.in.my_computername = lp_netbios_name(global_loadparm);
state->r.in.my_accountname = talloc_asprintf(state, "%s$",
lp_netbios_name(global_loadparm));
lp_netbios_name(global_loadparm));
if (composite_nomem(state->r.in.my_accountname, state->ctx)) return;
state->r.in.account_control = ACB_WSTRUST;
state->r.in.domain_sid = state->domain_sid;

View File

@ -187,7 +187,8 @@ struct composite_context *smb2_connect_send(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(name);
name.name = host;
creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order(global_loadparm));
creq = resolve_name_send(&name, c->event_ctx,
lp_name_resolve_order(global_loadparm));
composite_continue(c, creq, continue_resolve, c);
return c;
}

View File

@ -63,7 +63,8 @@ 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, lp_cli_maxprotocol(global_loadparm));
state->req = smb_raw_negotiate_send(state->transport,
lp_cli_maxprotocol(global_loadparm));
NT_STATUS_HAVE_NO_MEMORY(state->req);
state->req->async.fn = request_handler;
@ -172,7 +173,8 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
state->io_setup->in.credentials = cli_credentials_init(state);
NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials);
cli_credentials_set_conf(state->io_setup->in.credentials, global_loadparm);
cli_credentials_set_conf(state->io_setup->in.credentials,
global_loadparm);
cli_credentials_set_anonymous(state->io_setup->in.credentials);
/* If the preceding attempt was with extended security, we
@ -459,7 +461,8 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
state->stage = CONNECT_RESOLVE;
make_nbt_name_server(&name, io->in.dest_host);
state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order(global_loadparm));
state->creq = resolve_name_send(&name, c->event_ctx,
lp_name_resolve_order(global_loadparm));
if (state->creq == NULL) goto failed;
state->creq->async.private_data = c;

View File

@ -418,7 +418,7 @@ static NTSTATUS session_setup_spnego(struct composite_context *c,
}
}
if (chosen_oid == GENSEC_OID_SPNEGO) {
if ((const void *)chosen_oid == (const void *)GENSEC_OID_SPNEGO) {
status = gensec_update(session->gensec, state,
session->transport->negotiate.secblob,
&state->setup.spnego.in.secblob);

View File

@ -790,7 +790,7 @@ static NTSTATUS becomeDC_ldap_connect(struct libnet_BecomeDC_state *s, struct be
url = talloc_asprintf(s, "ldap://%s/", s->source_dsa.dns_name);
NT_STATUS_HAVE_NO_MEMORY(url);
ldap->ldb = ldb_wrap_connect(s, url,
ldap->ldb = ldb_wrap_connect(s, global_loadparm, url,
NULL,
s->libnet->cred,
0, NULL);

View File

@ -228,7 +228,8 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
return NT_STATUS_NO_MEMORY;
}
remote_ldb = ldb_wrap_connect(tmp_ctx, remote_ldb_url,
remote_ldb = ldb_wrap_connect(tmp_ctx, global_loadparm,
remote_ldb_url,
NULL, ctx->cred, 0, NULL);
if (!remote_ldb) {
r->out.error_string = NULL;

View File

@ -34,6 +34,8 @@
#include "librpc/gen_ndr/lsa.h"
#include "librpc/gen_ndr/ndr_lsa_c.h"
#include "param/param.h"
struct lookup_state {
struct nbt_name hostname;
const char *address;
@ -189,7 +191,8 @@ struct composite_context* libnet_LookupDCs_send(struct libnet_context *ctx,
struct libnet_LookupDCs *io)
{
struct composite_context *c;
struct messaging_context *msg_ctx = messaging_client_init(mem_ctx, ctx->event_ctx);
struct messaging_context *msg_ctx =
messaging_client_init(mem_ctx, lp_messaging_path(mem_ctx, global_loadparm), ctx->event_ctx);
c = finddcs_send(mem_ctx, io->in.domain_name, io->in.name_type,
NULL, ctx->name_res_methods, ctx->event_ctx, msg_ctx);

View File

@ -1191,7 +1191,9 @@ static NTSTATUS libnet_samsync_ldb_init(TALLOC_CTX *mem_ctx,
}
ldap_url = talloc_asprintf(state, "ldap://%s", server);
state->remote_ldb = ldb_wrap_connect(mem_ctx, ldap_url,
state->remote_ldb = ldb_wrap_connect(mem_ctx,
global_loadparm,
ldap_url,
NULL, state->samsync_state->machine_net_ctx->cred,
0, NULL);
if (!state->remote_ldb) {
@ -1217,7 +1219,9 @@ NTSTATUS libnet_samsync_ldb(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, str
state->secrets = NULL;
state->trusted_domains = NULL;
state->sam_ldb = ldb_wrap_connect(mem_ctx, lp_sam_url(global_loadparm),
state->sam_ldb = ldb_wrap_connect(mem_ctx,
global_loadparm,
lp_sam_url(global_loadparm),
r->in.session_info,
ctx->cred, 0, NULL);

View File

@ -27,6 +27,7 @@
#include "dsdb/samdb/samdb.h"
#include "dsdb/common/flags.h"
#include "librpc/gen_ndr/ndr_drsuapi_c.h"
#include "param/param.h"
/*****************************************************************************
* Windows 2003 (w2k3) does the following steps when changing the server role
@ -307,7 +308,7 @@ static NTSTATUS unbecomeDC_ldap_connect(struct libnet_UnbecomeDC_state *s)
url = talloc_asprintf(s, "ldap://%s/", s->source_dsa.dns_name);
NT_STATUS_HAVE_NO_MEMORY(url);
s->ldap.ldb = ldb_wrap_connect(s, url,
s->ldap.ldb = ldb_wrap_connect(s, global_loadparm, url,
NULL,
s->libnet->cred,
0, NULL);

View File

@ -992,7 +992,7 @@ static BOOL winsdb_check_or_add_module_list(struct winsdb_handle *h)
flags |= LDB_FLG_NOSYNC;
}
h->ldb = ldb_wrap_connect(h, lock_path(h, lp_wins_url(global_loadparm)),
h->ldb = ldb_wrap_connect(h, global_loadparm, lock_path(h, global_loadparm, lp_wins_url(global_loadparm)),
NULL, NULL, flags, NULL);
if (!h->ldb) goto failed;
@ -1025,7 +1025,7 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, enum winsdb_handle_cal
flags |= LDB_FLG_NOSYNC;
}
h->ldb = ldb_wrap_connect(h, lock_path(h, lp_wins_url(global_loadparm)),
h->ldb = ldb_wrap_connect(h, global_loadparm, lock_path(h, global_loadparm, lp_wins_url(global_loadparm)),
NULL, NULL, flags, NULL);
if (!h->ldb) goto failed;

View File

@ -72,7 +72,7 @@ NTSTATUS ntptr_register(const void *_ops)
NTSTATUS ntptr_init(void)
{
init_module_fn static_init[] = STATIC_ntptr_MODULES;
init_module_fn *shared_init = load_samba_modules(NULL, "ntptr");
init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "ntptr");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -43,7 +43,7 @@
*/
static struct ldb_context *sptr_db_connect(TALLOC_CTX *mem_ctx)
{
return ldb_wrap_connect(mem_ctx, lp_spoolss_url(global_loadparm), system_session(mem_ctx),
return ldb_wrap_connect(mem_ctx, global_loadparm, lp_spoolss_url(global_loadparm), system_session(mem_ctx),
NULL, 0, NULL);
}

View File

@ -200,7 +200,7 @@ NTSTATUS ntvfs_init_connection(TALLOC_CTX *mem_ctx, struct share_config *scfg, e
NTSTATUS ntvfs_init(void)
{
init_module_fn static_init[] = STATIC_ntvfs_MODULES;
init_module_fn *shared_init = load_samba_modules(NULL, "ntvfs");
init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "ntvfs");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -131,7 +131,7 @@ _PUBLIC_ NTSTATUS sys_notify_init(void)
if (initialized) return NT_STATUS_OK;
initialized = True;
shared_init = load_samba_modules(NULL, "sys_notify");
shared_init = load_samba_modules(NULL, global_loadparm, "sys_notify");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -108,7 +108,7 @@ struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx)
return NULL;
}
path = private_path(mem_ctx, url);
path = private_path(mem_ctx, global_loadparm, url);
if (!path) {
return NULL;
}
@ -117,7 +117,7 @@ struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx)
/* Secrets.ldb *must* always be local. If we call for a
* system_session() we will recurse */
ldb = ldb_wrap_connect(mem_ctx, path, NULL, NULL, 0, NULL);
ldb = ldb_wrap_connect(mem_ctx, global_loadparm, path, NULL, NULL, 0, NULL);
talloc_free(path);
if (!ldb) {
return NULL;

View File

@ -152,7 +152,7 @@ NTSTATUS share_get_context(TALLOC_CTX *mem_ctx, struct share_context **ctx)
NTSTATUS share_init(void)
{
init_module_fn static_init[] = STATIC_share_MODULES;
init_module_fn *shared_init = load_samba_modules(NULL, "share");
init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "share");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -37,10 +37,10 @@ static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, stru
return NT_STATUS_NO_MEMORY;
}
sdb = ldb_wrap_connect( *ctx,
private_path(*ctx, "share.ldb"),
system_session(*ctx),
NULL, 0, NULL);
sdb = ldb_wrap_connect(*ctx, global_loadparm,
private_path(*ctx, global_loadparm, "share.ldb"),
system_session(*ctx),
NULL, 0, NULL);
if (!sdb) {
talloc_free(*ctx);
@ -569,22 +569,21 @@ done:
return ret;
}
static const struct share_ops ops = {
.name = "ldb",
.init = sldb_init,
.string_option = sldb_string_option,
.int_option = sldb_int_option,
.bool_option = sldb_bool_option,
.string_list_option = sldb_string_list_option,
.list_all = sldb_list_all,
.get_config = sldb_get_config,
.create = sldb_create,
.set = sldb_set,
.remove = sldb_remove
};
NTSTATUS share_ldb_init(void)
{
static struct share_ops ops = {
.name = "ldb",
.init = sldb_init,
.string_option = sldb_string_option,
.int_option = sldb_int_option,
.bool_option = sldb_bool_option,
.string_list_option = sldb_string_list_option,
.list_all = sldb_list_all,
.get_config = sldb_get_config,
.create = sldb_create,
.set = sldb_set,
.remove = sldb_remove
};
return share_register(&ops);
}

View File

@ -35,20 +35,26 @@
*/
_PUBLIC_ bool lp_is_mydomain(struct loadparm_context *lp_ctx,
const char *domain)
{
return strequal(lp_workgroup(lp_ctx), domain);
}
/**
see if a string matches either our primary or one of our secondary
netbios aliases. do a case insensitive match
*/
_PUBLIC_ bool is_myname(const char *name)
_PUBLIC_ bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name)
{
const char **aliases;
int i;
if (strcasecmp(name, lp_netbios_name(global_loadparm)) == 0) {
if (strcasecmp(name, lp_netbios_name(lp_ctx)) == 0) {
return True;
}
aliases = lp_netbios_aliases(global_loadparm);
aliases = lp_netbios_aliases(lp_ctx);
for (i=0; aliases && aliases[i]; i++) {
if (strcasecmp(name, aliases[i]) == 0) {
return True;
@ -62,7 +68,8 @@ _PUBLIC_ bool is_myname(const char *name)
/**
A useful function for returning a path in the Samba lock directory.
**/
_PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, const char *name)
_PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
const char *name)
{
char *fname, *dname;
if (name == NULL) {
@ -72,7 +79,7 @@ _PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, const char *name)
return talloc_strdup(mem_ctx, name);
}
dname = talloc_strdup(mem_ctx, lp_lockdir(global_loadparm));
dname = talloc_strdup(mem_ctx, lp_lockdir(lp_ctx));
trim_string(dname,"","/");
if (!directory_exist(dname)) {
@ -86,44 +93,6 @@ _PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, const char *name)
return fname;
}
/**
A useful function for returning a path in the Samba piddir directory.
**/
static char *pid_path(TALLOC_CTX* mem_ctx, const char *name)
{
char *fname, *dname;
dname = talloc_strdup(mem_ctx, lp_piddir(global_loadparm));
trim_string(dname,"","/");
if (!directory_exist(dname)) {
mkdir(dname,0755);
}
fname = talloc_asprintf(mem_ctx, "%s/%s", dname, name);
talloc_free(dname);
return fname;
}
/**
* @brief Returns an absolute path to a file in the Samba lib directory.
*
* @param name File to find, relative to DATADIR.
*
* @retval Pointer to a talloc'ed string containing the full path.
**/
_PUBLIC_ char *data_path(TALLOC_CTX* mem_ctx, const char *name)
{
char *fname;
fname = talloc_asprintf(mem_ctx, "%s/%s", dyn_DATADIR, name);
return fname;
}
/**
* @brief Returns an absolute path to a file in the directory containing the current config file
*
@ -132,10 +101,11 @@ _PUBLIC_ char *data_path(TALLOC_CTX* mem_ctx, const char *name)
* @retval Pointer to a talloc'ed string containing the full path.
**/
_PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, const char *name)
_PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
const char *name)
{
char *fname, *config_dir, *p;
config_dir = talloc_strdup(mem_ctx, lp_configfile(global_loadparm));
config_dir = talloc_strdup(mem_ctx, lp_configfile(lp_ctx));
p = strrchr(config_dir, '/');
if (!p) {
return NULL;
@ -154,7 +124,9 @@ _PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, const char *name)
*
* @retval Pointer to a talloc'ed string containing the full path.
**/
_PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, const char *name)
_PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx,
struct loadparm_context *lp_ctx,
const char *name)
{
char *fname;
if (name == NULL) {
@ -163,7 +135,7 @@ _PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, const char *name)
if (name[0] == 0 || name[0] == '/' || strstr(name, ":/")) {
return talloc_strdup(mem_ctx, name);
}
fname = talloc_asprintf(mem_ctx, "%s/%s", lp_private_dir(global_loadparm), name);
fname = talloc_asprintf(mem_ctx, "%s/%s", lp_private_dir(lp_ctx), name);
return fname;
}
@ -172,11 +144,13 @@ _PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, const char *name)
for smbd go. If NULL is passed for name then return the directory
path itself
*/
_PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name)
_PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
const char *name)
{
char *fname, *dname;
dname = pid_path(mem_ctx, "smbd.tmp");
dname = private_path(mem_ctx, lp_ctx, "smbd.tmp");
if (!directory_exist(dname)) {
mkdir(dname,0755);
}
@ -276,12 +250,13 @@ _PUBLIC_ bool run_init_functions(init_module_fn *fns)
return ret;
}
static char *modules_path(TALLOC_CTX* mem_ctx, const char *name)
static char *modules_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
const char *name)
{
const char *env_moduledir = getenv("LD_SAMBA_MODULE_PATH");
return talloc_asprintf(mem_ctx, "%s/%s",
env_moduledir?env_moduledir:lp_modulesdir(global_loadparm),
name);
env_moduledir?env_moduledir:lp_modulesdir(lp_ctx),
name);
}
/**
@ -290,9 +265,9 @@ static char *modules_path(TALLOC_CTX* mem_ctx, const char *name)
* Will return an array of function pointers to initialization functions
*/
_PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem)
_PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem)
{
char *path = modules_path(mem_ctx, subsystem);
char *path = modules_path(mem_ctx, lp_ctx, subsystem);
init_module_fn *ret;
ret = load_modules(mem_ctx, path);
@ -302,4 +277,9 @@ _PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *sub
return ret;
}
_PUBLIC_ const char *lp_messaging_path(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx)
{
return smbd_tmp_path(mem_ctx, lp_ctx, "messaging");
}

View File

@ -446,7 +446,7 @@ static NTSTATUS dcesrv_init(struct event_context *event_context,
NTSTATUS server_service_rpc_init(void)
{
init_module_fn static_init[] = STATIC_dcerpc_server_MODULES;
init_module_fn *shared_init = load_samba_modules(NULL, "dcerpc_server");
init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "dcerpc_server");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -184,7 +184,7 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *))
smb_setup_ejs_param();
smb_setup_ejs_literal();
shared_init = load_samba_modules(NULL, "smbcalls");
shared_init = load_samba_modules(NULL, global_loadparm, "smbcalls");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -30,9 +30,11 @@
#include "libcli/security/security.h"
static int ejs_doauth(MprVarHandle eid,
TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username,
const char *password, const char *domain, const char *workstation,
struct socket_address *remote_host, const char **auth_types)
TALLOC_CTX *tmp_ctx, struct MprVar *auth,
const char *username, const char *password,
const char *domain, const char *workstation,
struct socket_address *remote_host,
const char **auth_types)
{
struct auth_usersupplied_info *user_info = NULL;
struct auth_serversupplied_info *server_info = NULL;
@ -54,7 +56,7 @@ static int ejs_doauth(MprVarHandle eid,
} else {
/* Hope we can find the event context somewhere up there... */
ev = event_context_find(tmp_ctx);
msg = messaging_client_init(tmp_ctx, ev);
msg = messaging_client_init(tmp_ctx, global_loadparm, ev);
}
if (auth_types) {

View File

@ -452,7 +452,7 @@ static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv)
dbfile = argv[0];
ldb = ldb_wrap_connect(mprMemCtx(), dbfile,
ldb = ldb_wrap_connect(mprMemCtx(), global_loadparm, dbfile,
session_info, creds,
0, (const char **)(argv+1));
if (ldb == NULL) {

View File

@ -78,7 +78,9 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
/* create a messaging context, looping as we have no way to
allocate temporary server ids automatically */
for (i=0;i<10000;i++) {
p->msg_ctx = messaging_init(p, cluster_id(EJS_ID_BASE + i), ev);
p->msg_ctx = messaging_init(p,
lp_messaging_path(p, global_loadparm),
cluster_id(EJS_ID_BASE + i), ev);
if (p->msg_ctx) break;
}
if (p->msg_ctx == NULL) {

View File

@ -281,7 +281,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
capabilities |= CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS;
}
large_test_path = lock_path(req, "large_test.dat");
large_test_path = lock_path(req, global_loadparm, "large_test.dat");
if (large_file_support(large_test_path)) {
capabilities |= CAP_LARGE_FILES;
}

View File

@ -83,7 +83,7 @@ _PUBLIC_ NTSTATUS register_process_model(const void *_ops)
NTSTATUS process_model_init(void)
{
init_module_fn static_init[] = STATIC_process_model_MODULES;
init_module_fn *shared_init = load_samba_modules(NULL, "process_model");
init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "process_model");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -93,7 +93,7 @@ static void cleanup_tmp_files(void)
char *path;
TALLOC_CTX *mem_ctx = talloc_new(NULL);
path = smbd_tmp_path(mem_ctx, NULL);
path = smbd_tmp_path(mem_ctx, global_loadparm, NULL);
recursive_delete(path);
talloc_free(mem_ctx);
@ -296,7 +296,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
process_model_init();
shared_init = load_samba_modules(NULL, "service");
shared_init = load_samba_modules(NULL, global_loadparm, "service");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -181,7 +181,9 @@ static void stream_new_connection(struct event_context *ev,
}
/* setup to receive internal messages on this connection */
srv_conn->msg_ctx = messaging_init(srv_conn, srv_conn->server_id, ev);
srv_conn->msg_ctx = messaging_init(srv_conn,
lp_messaging_path(srv_conn, global_loadparm),
srv_conn->server_id, ev);
if (!srv_conn->msg_ctx) {
stream_terminate_connection(srv_conn, "messaging_init() failed");
return;

View File

@ -25,6 +25,7 @@
#include "smbd/service.h"
#include "smbd/service_task.h"
#include "lib/messaging/irpc.h"
#include "param/param.h"
/*
terminate a task service
@ -64,7 +65,9 @@ static void task_server_callback(struct event_context *event_ctx,
task->model_ops = state->model_ops;
task->server_id = server_id;
task->msg_ctx = messaging_init(task, task->server_id, task->event_ctx);
task->msg_ctx = messaging_init(task,
lp_messaging_path(task, global_loadparm),
task->server_id, task->event_ctx);
if (!task->msg_ctx) {
task_server_terminate(task, "messaging_init() failed");
return;

View File

@ -31,6 +31,8 @@
#include "torture/torture.h"
#include "torture/ldap/proto.h"
#include "param/param.h"
struct test_rootDSE {
const char *defaultdn;
const char *rootdn;
@ -374,7 +376,7 @@ BOOL torture_ldap_schema(struct torture_context *torture)
url = talloc_asprintf(torture, "ldap://%s/", host);
ldb = ldb_wrap_connect(torture, url,
ldb = ldb_wrap_connect(torture, global_loadparm, url,
NULL,
cmdline_credentials,
0, NULL);

View File

@ -34,6 +34,8 @@
#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "param/param.h"
static bool test_check_uptodatevector(struct torture_context *torture,
struct ldb_context *ldb,
struct ldb_dn *partition_dn)
@ -158,7 +160,7 @@ BOOL torture_ldap_uptodatevector(struct torture_context *torture)
url = talloc_asprintf(torture, "ldap://%s/", host);
if (!url) goto failed;
ldb = ldb_wrap_connect(torture, url,
ldb = ldb_wrap_connect(torture, global_loadparm, url,
NULL,
cmdline_credentials,
0, NULL);

View File

@ -256,7 +256,7 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
DEBUG(0,("Open the SAM LDB with system credentials: %s\n", s->path.samdb_ldb));
s->ldb = ldb_wrap_connect(s, s->path.samdb_ldb,
s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb,
system_session(s),
NULL, 0, NULL);
if (!s->ldb) {
@ -484,7 +484,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
s->schema = NULL;
DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema: %s\n", s->path.samdb_ldb));
s->ldb = ldb_wrap_connect(s, s->path.samdb_ldb,
s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb,
system_session(s),
NULL, 0, NULL);
if (!s->ldb) {
@ -817,7 +817,7 @@ BOOL torture_net_become_dc(struct torture_context *torture)
s->schema = NULL;
DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", s->path.samdb_ldb));
s->ldb = ldb_wrap_connect(s, s->path.samdb_ldb,
s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb,
system_session(s),
NULL, 0, NULL);
if (!s->ldb) {

View File

@ -26,6 +26,7 @@
#include "lib/ldb/include/ldb_errors.h"
#include "lib/db_wrap.h"
#include "torture/torture.h"
#include "param/param.h"
float tdb_speed;
@ -174,7 +175,7 @@ static BOOL test_ldb_speed(struct torture_context *torture, const void *_data)
torture_comment(torture, "Testing ldb speed for sidmap\n");
ldb = ldb_wrap_connect(tmp_ctx, "tdb://test.ldb",
ldb = ldb_wrap_connect(tmp_ctx, global_loadparm, "tdb://test.ldb",
NULL, NULL, LDB_FLG_NOSYNC, NULL);
if (!ldb) {
unlink("./test.ldb");

View File

@ -220,11 +220,13 @@ static BOOL irpc_setup(struct torture_context *tctx, void **_data)
data->ev = tctx->ev;
torture_assert(tctx, data->msg_ctx1 =
messaging_init(tctx,
lp_messaging_path(tctx, global_loadparm),
cluster_id(MSG_ID1), data->ev),
"Failed to init first messaging context");
torture_assert(tctx, data->msg_ctx2 =
messaging_init(tctx,
lp_messaging_path(tctx, global_loadparm),
cluster_id(MSG_ID2), data->ev),
"Failed to init second messaging context");

View File

@ -72,16 +72,21 @@ static bool test_ping_speed(struct torture_context *tctx)
ev = tctx->ev;
msg_server_ctx = messaging_init(mem_ctx, cluster_id(1), ev);
msg_server_ctx = messaging_init(mem_ctx,
lp_messaging_path(tctx, global_loadparm),
cluster_id(1), ev);
torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context");
messaging_register_tmp(msg_server_ctx, NULL, ping_message, &msg_ping);
messaging_register_tmp(msg_server_ctx, mem_ctx, exit_message, &msg_exit);
msg_client_ctx = messaging_init(mem_ctx, cluster_id(2), ev);
msg_client_ctx = messaging_init(mem_ctx,
lp_messaging_path(mem_ctx, global_loadparm),
cluster_id(2), ev);
torture_assert(tctx, msg_client_ctx != NULL, "msg_client_ctx messaging_init() failed");
torture_assert(tctx, msg_client_ctx != NULL,
"msg_client_ctx messaging_init() failed");
messaging_register_tmp(msg_client_ctx, &pong_count, pong_message, &msg_pong);

View File

@ -68,7 +68,7 @@ struct test_spoolss_context {
#endif
#define COMPARE_UINT32(tctx, c, r, e) do {\
_CHECK_FIELD_SIZE(c, r, e,uint32_t); \
_CHECK_FIELD_SIZE(c, r, e, uint32_t); \
torture_assert_int_equal(tctx, c.e, r.e, "invalid value"); \
} while(0)

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, "torture");
init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "torture");
run_init_functions(static_init);
run_init_functions(shared_init);

View File

@ -141,7 +141,8 @@ static bool torture_winbind_struct_priv_pipe_dir(struct torture_context *torture
torture_assert(torture, got_dir, "NULL WINBINDD_PRIV_PIPE_DIR\n");
default_dir = lock_path(torture, WINBINDD_PRIV_SOCKET_SUBDIR);
default_dir = lock_path(torture, global_loadparm,
WINBINDD_PRIV_SOCKET_SUBDIR);
expected_dir = torture_setting_string(torture,
"winbindd private pipe dir",
default_dir);

View File

@ -461,7 +461,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
if (!ev) {
exit(1);
}
msg = messaging_client_init(state, ev);
msg = messaging_client_init(state, global_loadparm, ev);
if (!msg) {
exit(1);
}

View File

@ -112,7 +112,7 @@ NTSTATUS wbsrv_samba3_priv_pipe_dir(struct wbsrv_samba3_call *s3call)
{
s3call->response.result = WINBINDD_OK;
s3call->response.extra_data.data =
smbd_tmp_path(s3call, WINBINDD_SAMBA3_PRIVILEGED_SOCKET);
smbd_tmp_path(s3call, global_loadparm, WINBINDD_SAMBA3_PRIVILEGED_SOCKET);
NT_STATUS_HAVE_NO_MEMORY(s3call->response.extra_data.data);
return NT_STATUS_OK;
}

View File

@ -166,7 +166,7 @@ static void winbind_task_init(struct task_server *task)
listen_socket = talloc(service, struct wbsrv_listen_socket);
if (!listen_socket) goto nomem;
listen_socket->socket_path =
smbd_tmp_path(listen_socket,
smbd_tmp_path(listen_socket, global_loadparm,
WINBINDD_SAMBA3_PRIVILEGED_SOCKET);
if (!listen_socket->socket_path) goto nomem;
listen_socket->service = service;

View File

@ -35,8 +35,9 @@
static struct ldb_context *wins_config_db_connect(TALLOC_CTX *mem_ctx)
{
return ldb_wrap_connect(mem_ctx, private_path(mem_ctx,
lp_wins_config_url(global_loadparm)),
return ldb_wrap_connect(mem_ctx, global_loadparm, private_path(mem_ctx,
global_loadparm,
lp_wins_config_url(global_loadparm)),
system_session(mem_ctx), NULL, 0, NULL);
}