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);
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)) {
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;
* 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;
}
} 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);
}
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);
"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) {
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;
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);
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;
*/
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;
*/
-static BOOL dont_ask;
+static bool dont_ask;
enum opt { OPT_SIMPLE_BIND_DN, OPT_PASSWORD, OPT_KERBEROS };
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,
}
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
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);
}
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;
}
struct ldb_message;
struct ldb_dn;
struct cli_credentials;
+struct loadparm_context;
#include "lib/db_wrap_proto.h"
/* 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);
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
/* 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 {
} 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,
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);
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) {
}
/* 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);
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
#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;
}
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;
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"));
* @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;
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);
}
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;
}
/* 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() */
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;
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;
}
{
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;
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
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;
}
}
- 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);
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);
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;
#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;
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);
}
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) {
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);
#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
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);
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;
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;
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);
*/
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);
}
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);
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);
return NULL;
}
- path = private_path(mem_ctx, url);
+ path = private_path(mem_ctx, global_loadparm, url);
if (!path) {
return NULL;
}
/* 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;
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);
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);
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);
}
-
*/
+_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;
/**
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) {
return talloc_strdup(mem_ctx, name);
}
- dname = talloc_strdup(mem_ctx, lp_lockdir(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;
-}
-
-
-/**
- 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));
+ dname = talloc_strdup(mem_ctx, lp_lockdir(lp_ctx));
trim_string(dname,"","/");
if (!directory_exist(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
*
* @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;
*
* @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) {
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;
}
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);
}
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);
}
/**
* 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);
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");
+}
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);
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);
#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;
} 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) {
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) {
/* 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) {
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;
}
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);
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);
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);
}
/* 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;
#include "smbd/service.h"
#include "smbd/service_task.h"
#include "lib/messaging/irpc.h"
+#include "param/param.h"
/*
terminate a task service
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;
#include "torture/torture.h"
#include "torture/ldap/proto.h"
+#include "param/param.h"
+
struct test_rootDSE {
const char *defaultdn;
const char *rootdn;
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);
#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)
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);
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) {
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) {
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) {
#include "lib/ldb/include/ldb_errors.h"
#include "lib/db_wrap.h"
#include "torture/torture.h"
+#include "param/param.h"
float tdb_speed;
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");
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");
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);
#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)
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);
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);
if (!ev) {
exit(1);
}
- msg = messaging_client_init(state, ev);
+ msg = messaging_client_init(state, global_loadparm, ev);
if (!msg) {
exit(1);
}
{
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;
}
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;
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);
}