summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-10-01 18:52:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:07:34 -0500
commit2f3551ca7cee59d4d053cceb87abdf1da1b3a1ad (patch)
tree2d02f6e998c150cca5323e574ffb8094fffc288f /source4/param
parent4d7273715f109db82a4ee4852855927a32bb4073 (diff)
downloadsamba-2f3551ca7cee59d4d053cceb87abdf1da1b3a1ad.tar.gz
samba-2f3551ca7cee59d4d053cceb87abdf1da1b3a1ad.tar.bz2
samba-2f3551ca7cee59d4d053cceb87abdf1da1b3a1ad.zip
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)
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/secrets.c4
-rw-r--r--source4/param/share.c2
-rw-r--r--source4/param/share_ldb.c37
-rw-r--r--source4/param/util.c88
4 files changed, 55 insertions, 76 deletions
diff --git a/source4/param/secrets.c b/source4/param/secrets.c
index 4107526d75..829341a5f9 100644
--- a/source4/param/secrets.c
+++ b/source4/param/secrets.c
@@ -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;
diff --git a/source4/param/share.c b/source4/param/share.c
index dabd4e8d26..d0a570eeca 100644
--- a/source4/param/share.c
+++ b/source4/param/share.c
@@ -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);
diff --git a/source4/param/share_ldb.c b/source4/param/share_ldb.c
index 586000f503..5ddf0e3511 100644
--- a/source4/param/share_ldb.c
+++ b/source4/param/share_ldb.c
@@ -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);
}
-
diff --git a/source4/param/util.c b/source4/param/util.c
index 25959c4919..9c682a7791 100644
--- a/source4/param/util.c
+++ b/source4/param/util.c
@@ -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,29 +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));
- 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)) {
@@ -108,22 +93,6 @@ static char *pid_path(TALLOC_CTX* mem_ctx, const char *name)
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");
+}