From 18cddd580e04344e05593d9f63beb9ead53cfab2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 20 Mar 2006 00:28:12 +0000 Subject: r14575: Move some path-related functions to libsamba-config so libsamba-util doesn't have to depend on the lp_* functions. (This used to be commit f97df7d90a41b77a9edd2d6bdc47c27bf1b6bb07) --- source4/param/util.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 source4/param/util.c (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c new file mode 100644 index 0000000000..85a0587827 --- /dev/null +++ b/source4/param/util.c @@ -0,0 +1,194 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Jeremy Allison 2001-2002 + Copyright (C) Simo Sorce 2001 + Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. + Copyright (C) James J Myers 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "dynconfig.h" +#include "system/network.h" +#include "system/iconv.h" +#include "system/filesys.h" + +/** + * @file + * @brief Misc utility functions + */ + + +/** + 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) +{ + const char **aliases; + int i; + + if (strcasecmp(name, lp_netbios_name()) == 0) { + return True; + } + + aliases = lp_netbios_aliases(); + for (i=0; aliases && aliases[i]; i++) { + if (strcasecmp(name, aliases[i]) == 0) { + return True; + } + } + + return False; +} + + +/** + A useful function for returning a path in the Samba lock directory. +**/ +_PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, const char *name) +{ + char *fname, *dname; + if (name == NULL) { + return NULL; + } + if (name[0] == 0 || name[0] == '/' || strstr(name, ":/")) { + return talloc_strdup(mem_ctx, name); + } + + dname = talloc_strdup(mem_ctx, lp_lockdir()); + 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()); + 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 Samba private directory. + * + * @param name File to find, relative to PRIVATEDIR. + * if name is not relative, then use it as-is + * + * @retval Pointer to a talloc'ed string containing the full path. + **/ +_PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, const char *name) +{ + char *fname; + if (name == NULL) { + return 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(), name); + return fname; +} + +/** + return a path in the smbd.tmp directory, where all temporary file + 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) +{ + char *fname, *dname; + + dname = pid_path(mem_ctx, "smbd.tmp"); + if (!directory_exist(dname)) { + mkdir(dname,0755); + } + + if (name == NULL) { + return dname; + } + + fname = talloc_asprintf(mem_ctx, "%s/%s", dname, name); + talloc_free(dname); + + return fname; +} + +static char *modules_path(TALLOC_CTX* mem_ctx, const char *name) +{ + return talloc_asprintf(mem_ctx, "%s/%s", dyn_MODULESDIR, name); +} + +/** + * Load the initialization functions from DSO files for a specific subsystem. + * + * Will return an array of function pointers to initialization functions + */ + +_PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem) +{ + char *path = modules_path(mem_ctx, subsystem); + init_module_fn *ret; + + ret = load_modules(mem_ctx, path); + + talloc_free(path); + + return ret; +} + + -- cgit From 97fe71c1f54551dfddf5430c185c45d2b881124f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Apr 2006 16:20:32 +0000 Subject: r14909: Add lp_modulesdir() smb.conf option (This used to be commit eaa68826d34c2bebc3df5e96aed2102debb67964) --- source4/param/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 85a0587827..b3df175e43 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -170,7 +170,7 @@ _PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name) static char *modules_path(TALLOC_CTX* mem_ctx, const char *name) { - return talloc_asprintf(mem_ctx, "%s/%s", dyn_MODULESDIR, name); + return talloc_asprintf(mem_ctx, "%s/%s", lp_modulesdir(), name); } /** @@ -184,6 +184,7 @@ _PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *sub char *path = modules_path(mem_ctx, subsystem); init_module_fn *ret; + printf("MODULESDIR: %s\n", path); ret = load_modules(mem_ctx, path); talloc_free(path); -- cgit From 1385cd968bf94dd9b9b252bc679667568845c682 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Apr 2006 17:48:53 +0000 Subject: r14914: Remove printf statement I accidently committed. (This used to be commit ca4d1b4c0e1a18c2b071f49076251369370a785c) --- source4/param/util.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index b3df175e43..dc605191fe 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -184,7 +184,6 @@ _PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *sub char *path = modules_path(mem_ctx, subsystem); init_module_fn *ret; - printf("MODULESDIR: %s\n", path); ret = load_modules(mem_ctx, path); talloc_free(path); -- cgit From 172a83d72491f90f6191be1040ef8b2e1789bd2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 May 2006 19:14:12 +0000 Subject: r15573: Fix build of systems that have iconv headers in non-standard locations Split of system/locale.h header from system/iconv.h Previously, iconv wasn't being used on these systems (This used to be commit aa6d66fda69779d1c2948a1aca85dbd5208f1cba) --- source4/param/util.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index dc605191fe..af97903277 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -25,7 +25,6 @@ #include "includes.h" #include "dynconfig.h" #include "system/network.h" -#include "system/iconv.h" #include "system/filesys.h" /** -- cgit From 4fa24df98ded939c68bdc95e9f09334caeeb84af Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 29 Oct 2006 17:40:19 +0000 Subject: r19507: Merge my DSO fixes branch. Building Samba's libraries as shared libraries works again now, by specifying --enable-dso to configure. (This used to be commit 7a01235067a4800b07b8919a6a475954bfb0b04c) --- source4/param/util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index af97903277..2453094798 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -169,7 +169,10 @@ _PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name) static char *modules_path(TALLOC_CTX* mem_ctx, const char *name) { - return talloc_asprintf(mem_ctx, "%s/%s", lp_modulesdir(), name); + const char *env_moduledir = getenv("LD_SAMBA_MODULE_PATH"); + return talloc_asprintf(mem_ctx, "%s/%s", + env_moduledir?env_moduledir:lp_modulesdir(), + name); } /** -- cgit From d5bbd817fe83aed1ee48ed4f478f3887c059f7b9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 24 Jan 2007 02:48:40 +0000 Subject: r20988: Call out to Heimdal's krb5.conf processing to configure many aspects of KDC behaviour. This should allow PKINIT to be turned on and managed with reasonable sanity. This also means that the krb5.conf in the same directory as the smb.conf will always have priority in Samba4, which I think will be useful. Andrew Bartlett (This used to be commit a50bbde81b010bc5d06e3fc3417ade44627eb771) --- source4/param/util.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 2453094798..82f57a605b 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -122,6 +122,28 @@ _PUBLIC_ char *data_path(TALLOC_CTX* mem_ctx, const char *name) return fname; } +/** + * @brief Returns an absolute path to a file in the directory containing the current config file + * + * @param name File to find, relative to the config file directory. + * + * @retval Pointer to a talloc'ed string containing the full path. + **/ + +_PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, const char *name) +{ + char *fname, *config_dir, *p; + config_dir = talloc_strdup(mem_ctx, lp_configfile()); + p = strrchr(config_dir, '/'); + if (!p) { + return NULL; + } + p[0] = '\0'; + fname = talloc_asprintf(mem_ctx, "%s/%s", config_dir, name); + talloc_free(config_dir); + return fname; +} + /** * @brief Returns an absolute path to a file in the Samba private directory. * -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/param/util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 82f57a605b..7af2693876 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -9,7 +9,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -18,8 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 82037a75eae9deaf6ec80b5ecc3bb89aab6e6dd8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 30 Aug 2007 23:15:12 +0000 Subject: r24814: Fix headers, trim core.h even more. (This used to be commit 9647f860bdd5c0a74583e886182bd041a45e7655) --- source4/param/util.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 7af2693876..6e6e12596b 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -6,6 +6,7 @@ Copyright (C) Simo Sorce 2001 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. Copyright (C) James J Myers 2003 + Copyright (C) Jelmer Vernooij 2005-2007 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +26,7 @@ #include "dynconfig.h" #include "system/network.h" #include "system/filesys.h" +#include "system/dir.h" /** * @file @@ -188,6 +190,91 @@ _PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name) return fname; } +/** + * Obtain the init function from a shared library file + */ +_PUBLIC_ init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path) +{ + void *handle; + void *init_fn; + + handle = dlopen(path, RTLD_NOW); + if (handle == NULL) { + DEBUG(0, ("Unable to open %s: %s\n", path, dlerror())); + return NULL; + } + + init_fn = dlsym(handle, "init_module"); + + if (init_fn == NULL) { + DEBUG(0, ("Unable to find init_module() in %s: %s\n", path, dlerror())); + DEBUG(1, ("Loading module '%s' failed\n", path)); + dlclose(handle); + return NULL; + } + + return (init_module_fn)init_fn; +} + +/** + * Obtain list of init functions from the modules in the specified + * directory + */ +_PUBLIC_ init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) +{ + DIR *dir; + struct dirent *entry; + char *filename; + int success = 0; + init_module_fn *ret = talloc_array(mem_ctx, init_module_fn, 2); + + ret[0] = NULL; + + dir = opendir(path); + if (dir == NULL) { + talloc_free(ret); + return NULL; + } + + while((entry = readdir(dir))) { + if (ISDOT(entry->d_name) || ISDOTDOT(entry->d_name)) + continue; + + filename = talloc_asprintf(mem_ctx, "%s/%s", path, entry->d_name); + + ret[success] = load_module(mem_ctx, filename); + if (ret[success]) { + ret = talloc_realloc(mem_ctx, ret, init_module_fn, success+2); + success++; + ret[success] = NULL; + } + + talloc_free(filename); + } + + closedir(dir); + + return ret; +} + +/** + * Run the specified init functions. + * + * @return true if all functions ran successfully, false otherwise + */ +_PUBLIC_ bool run_init_functions(init_module_fn *fns) +{ + int i; + bool ret = true; + + if (fns == NULL) + return true; + + for (i = 0; fns[i]; i++) { ret &= (bool)NT_STATUS_IS_OK(fns[i]()); } + + return ret; +} + static char *modules_path(TALLOC_CTX* mem_ctx, const char *name) { const char *env_moduledir = getenv("LD_SAMBA_MODULE_PATH"); -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/param/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 6e6e12596b..308d4bfc2b 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -27,6 +27,7 @@ #include "system/network.h" #include "system/filesys.h" #include "system/dir.h" +#include "param/param.h" /** * @file @@ -38,7 +39,7 @@ 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 is_myname(const char *name) { const char **aliases; int i; -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/param/util.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 308d4bfc2b..25959c4919 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -44,11 +44,11 @@ _PUBLIC_ bool is_myname(const char *name) const char **aliases; int i; - if (strcasecmp(name, lp_netbios_name()) == 0) { + if (strcasecmp(name, lp_netbios_name(global_loadparm)) == 0) { return True; } - aliases = lp_netbios_aliases(); + aliases = lp_netbios_aliases(global_loadparm); for (i=0; aliases && aliases[i]; i++) { if (strcasecmp(name, aliases[i]) == 0) { return True; @@ -72,7 +72,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()); + dname = talloc_strdup(mem_ctx, lp_lockdir(global_loadparm)); trim_string(dname,"","/"); if (!directory_exist(dname)) { @@ -94,7 +94,7 @@ static char *pid_path(TALLOC_CTX* mem_ctx, const char *name) { char *fname, *dname; - dname = talloc_strdup(mem_ctx, lp_piddir()); + dname = talloc_strdup(mem_ctx, lp_piddir(global_loadparm)); trim_string(dname,"","/"); if (!directory_exist(dname)) { @@ -135,7 +135,7 @@ _PUBLIC_ char *data_path(TALLOC_CTX* mem_ctx, const char *name) _PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, const char *name) { char *fname, *config_dir, *p; - config_dir = talloc_strdup(mem_ctx, lp_configfile()); + config_dir = talloc_strdup(mem_ctx, lp_configfile(global_loadparm)); p = strrchr(config_dir, '/'); if (!p) { return NULL; @@ -163,7 +163,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(), name); + fname = talloc_asprintf(mem_ctx, "%s/%s", lp_private_dir(global_loadparm), name); return fname; } @@ -280,7 +280,7 @@ static char *modules_path(TALLOC_CTX* mem_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(), + env_moduledir?env_moduledir:lp_modulesdir(global_loadparm), name); } -- cgit From 2f3551ca7cee59d4d053cceb87abdf1da1b3a1ad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Oct 2007 18:52:55 +0000 Subject: 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) --- source4/param/util.c | 88 ++++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 54 deletions(-) (limited to 'source4/param/util.c') 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"); +} -- cgit From d5a93dfcb950ecd52d8dea7a2a5d667feb6259ca Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 21:39:52 +0000 Subject: r25547: Convert to standard bool type. (This used to be commit 97a241692c4b8dc45e086aa9b959f2cd30b8d6c9) --- source4/param/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 9c682a7791..8d59861f40 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -51,17 +51,17 @@ _PUBLIC_ bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name) int i; if (strcasecmp(name, lp_netbios_name(lp_ctx)) == 0) { - return True; + return true; } aliases = lp_netbios_aliases(lp_ctx); for (i=0; aliases && aliases[i]; i++) { if (strcasecmp(name, aliases[i]) == 0) { - return True; + return true; } } - return False; + return false; } -- cgit From b440ed3df31b11d520c6d744cf53c54165f61b7a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 6 Dec 2007 17:16:40 +0100 Subject: r26315: Avoid using lp_ functions in libcharset. (This used to be commit db6dd425e3526c04e96d778a736dbb5cf14ddc56) --- source4/param/util.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 8d59861f40..1cbae841bc 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -283,3 +283,19 @@ _PUBLIC_ const char *lp_messaging_path(TALLOC_CTX *mem_ctx, return smbd_tmp_path(mem_ctx, lp_ctx, "messaging"); } +struct smb_iconv_convenience *global_smb_iconv_convenience = NULL; + +struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx) +{ + return smb_iconv_convenience_init(mem_ctx, lp_dos_charset(lp_ctx), + lp_unix_charset(lp_ctx), + lp_display_charset(lp_ctx), + lp_parm_bool(lp_ctx, NULL, "iconv", "native", true)); +} + +_PUBLIC_ void reload_charcnv(void) +{ + talloc_free(global_smb_iconv_convenience); + global_smb_iconv_convenience = smb_iconv_convenience_init_lp(talloc_autofree_context(), global_loadparm); +} -- cgit From 038c75c0cb6307ee411cb3eabdf2305f2f3b653d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 04:33:29 +0100 Subject: r26357: Add separate subsystem for auth_sam_reply parsing. (This used to be commit 2d61e7c96e249d7031b709e9f727626a78e435f1) --- source4/param/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 1cbae841bc..89498b57a6 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -107,7 +107,7 @@ _PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, char *fname, *config_dir, *p; config_dir = talloc_strdup(mem_ctx, lp_configfile(lp_ctx)); p = strrchr(config_dir, '/'); - if (!p) { + if (p == NULL) { return NULL; } p[0] = '\0'; -- cgit From a5b8999f23d56b4a19b87fc17b22c96f88e487e8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 12:19:33 +0100 Subject: r26427: Avoid global_smb_iconv_convenience. (This used to be commit bf072c6fb37b3e6a71c0c747b9fbeaa01480229e) --- source4/param/util.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 89498b57a6..281d32f35f 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -285,6 +285,11 @@ _PUBLIC_ const char *lp_messaging_path(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *global_smb_iconv_convenience = NULL; +struct smb_iconv_convenience *lp_iconv_convenience(struct loadparm_context *lp_ctx) +{ + return global_smb_iconv_convenience; +} + struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx) { -- cgit From d891c0c74a03d797aed1c5ac0329fd9d1d78da63 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 22:46:09 +0100 Subject: r26429: Avoid use of global_smb_iconv_convenience. (This used to be commit d37136b7abfbba75ef2e5ab855eb3382b9648b8c) --- source4/param/util.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 281d32f35f..48ddbfdca0 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -283,13 +283,6 @@ _PUBLIC_ const char *lp_messaging_path(TALLOC_CTX *mem_ctx, return smbd_tmp_path(mem_ctx, lp_ctx, "messaging"); } -struct smb_iconv_convenience *global_smb_iconv_convenience = NULL; - -struct smb_iconv_convenience *lp_iconv_convenience(struct loadparm_context *lp_ctx) -{ - return global_smb_iconv_convenience; -} - struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx) { @@ -299,8 +292,4 @@ struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx, lp_parm_bool(lp_ctx, NULL, "iconv", "native", true)); } -_PUBLIC_ void reload_charcnv(void) -{ - talloc_free(global_smb_iconv_convenience); - global_smb_iconv_convenience = smb_iconv_convenience_init_lp(talloc_autofree_context(), global_loadparm); -} + -- cgit From 2bf0cdd01cf399bf28125f9e2a0d419f4e94996c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 22:46:33 +0100 Subject: r26434: Remove display charset from iconv convenience context. (This used to be commit a76625994abf9906d54ae11f9c171f89063cf508) --- source4/param/util.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 48ddbfdca0..4d4e562590 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -288,7 +288,6 @@ struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx, { return smb_iconv_convenience_init(mem_ctx, lp_dos_charset(lp_ctx), lp_unix_charset(lp_ctx), - lp_display_charset(lp_ctx), lp_parm_bool(lp_ctx, NULL, "iconv", "native", true)); } -- cgit From bf6d40f271682e87224102afd0855cee8916202e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 14 Dec 2007 01:46:25 +0100 Subject: r26449: Support configuration without a known configuration dir. (This used to be commit d3643c2152a490952e59ee15b7a62ad3ad465462) --- source4/param/util.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 4d4e562590..1cf05d4fa7 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -106,6 +106,9 @@ _PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, { char *fname, *config_dir, *p; config_dir = talloc_strdup(mem_ctx, lp_configfile(lp_ctx)); + if (config_dir == NULL) { + return NULL; + } p = strrchr(config_dir, '/'); if (p == NULL) { return NULL; -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/param/util.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 1cf05d4fa7..2baaefda8b 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -35,7 +35,7 @@ */ -_PUBLIC_ bool lp_is_mydomain(struct loadparm_context *lp_ctx, +bool lp_is_mydomain(struct loadparm_context *lp_ctx, const char *domain) { return strequal(lp_workgroup(lp_ctx), domain); @@ -45,7 +45,7 @@ _PUBLIC_ bool lp_is_mydomain(struct loadparm_context *lp_ctx, see if a string matches either our primary or one of our secondary netbios aliases. do a case insensitive match */ -_PUBLIC_ bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name) +bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name) { const char **aliases; int i; @@ -68,7 +68,7 @@ _PUBLIC_ bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name) /** A useful function for returning a path in the Samba lock directory. **/ -_PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, +char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, const char *name) { char *fname, *dname; @@ -101,7 +101,7 @@ _PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, * @retval Pointer to a talloc'ed string containing the full path. **/ -_PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, +char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, const char *name) { char *fname, *config_dir, *p; @@ -127,7 +127,7 @@ _PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, * * @retval Pointer to a talloc'ed string containing the full path. **/ -_PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, +char *private_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, const char *name) { @@ -147,7 +147,7 @@ _PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, for smbd go. If NULL is passed for name then return the directory path itself */ -_PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, +char *smbd_tmp_path(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *name) { @@ -171,7 +171,7 @@ _PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, /** * Obtain the init function from a shared library file */ -_PUBLIC_ init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path) +init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path) { void *handle; void *init_fn; @@ -198,7 +198,7 @@ _PUBLIC_ init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path) * Obtain list of init functions from the modules in the specified * directory */ -_PUBLIC_ init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) +init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) { DIR *dir; struct dirent *entry; @@ -240,7 +240,7 @@ _PUBLIC_ init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) * * @return true if all functions ran successfully, false otherwise */ -_PUBLIC_ bool run_init_functions(init_module_fn *fns) +bool run_init_functions(init_module_fn *fns) { int i; bool ret = true; @@ -268,7 +268,7 @@ static char *modules_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, * Will return an array of function pointers to initialization functions */ -_PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem) +init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem) { char *path = modules_path(mem_ctx, lp_ctx, subsystem); init_module_fn *ret; @@ -280,7 +280,7 @@ _PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm return ret; } -_PUBLIC_ const char *lp_messaging_path(TALLOC_CTX *mem_ctx, +const char *lp_messaging_path(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx) { return smbd_tmp_path(mem_ctx, lp_ctx, "messaging"); -- cgit From 936b973acbc756cc3b6cb0d9df85ebc28ba76ae7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 May 2008 14:36:28 +0200 Subject: Use new dynconfig.h location. (This used to be commit c3f556915f09d078253e4c5539910a1cf420eeca) --- source4/param/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 2baaefda8b..15e3b4768c 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -23,7 +23,7 @@ */ #include "includes.h" -#include "dynconfig.h" +#include "dynconfig/dynconfig.h" #include "system/network.h" #include "system/filesys.h" #include "system/dir.h" -- cgit From 310875e637fd237752770027b28675ed970352dd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 17 Jun 2008 13:11:29 +1000 Subject: Change our module code to not use the special symbol name init_module() Current glibc libraries include a function called init_module(). If we use the same name, then a dlsym() can find the glibc function if the module doesn't have an initialisation function. In ldb, none of our modules have an init_module(), so we end up calling the libc functions with bogus arguments. (This used to be commit 1b0621068998590e7b1e9528b78744dcd2cd5909) --- source4/param/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/param/util.c') diff --git a/source4/param/util.c b/source4/param/util.c index 15e3b4768c..ec192939d0 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -182,7 +182,7 @@ init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path) return NULL; } - init_fn = dlsym(handle, "init_module"); + init_fn = dlsym(handle, SAMBA_INIT_MODULE); if (init_fn == NULL) { DEBUG(0, ("Unable to find init_module() in %s: %s\n", path, dlerror())); -- cgit