summaryrefslogtreecommitdiff
path: root/source4/param/util.c
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/util.c
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/util.c')
-rw-r--r--source4/param/util.c88
1 files changed, 34 insertions, 54 deletions
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");
+}