summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/util/util.h26
-rw-r--r--lib/util/util_paths.c63
-rwxr-xr-xlib/util/wscript_build2
-rw-r--r--libgpo/gpext/gpext.c3
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/intl/lang_tdb.c2
-rw-r--r--source3/lib/module.c8
-rw-r--r--source3/lib/util.c37
-rw-r--r--source3/smbd/mangle_hash.c2
-rw-r--r--source4/lib/ldb-samba/ldb_wrap.c5
-rw-r--r--source4/param/util.c10
-rw-r--r--source4/torture/drs/rpc/dssync.c5
-rw-r--r--source4/torture/drs/rpc/msds_intid.c5
-rw-r--r--source4/torture/rpc/dsgetinfo.c2
15 files changed, 104 insertions, 71 deletions
diff --git a/lib/util/util.h b/lib/util/util.h
index d1c5e82bdd..e89c4ac997 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -891,4 +891,30 @@ int samba_runcmd_recv(struct tevent_req *req, int *perrno);
void samba_start_debugger(void);
#endif
+/**
+ * @brief Returns an absolute path to a file in the Samba modules directory.
+ *
+ * @param name File to find, relative to MODULESDIR.
+ *
+ * @retval Pointer to a string containing the full path.
+ **/
+char *modules_path(TALLOC_CTX *mem_ctx, const char *name);
+
+/**
+ * @brief Returns an absolute path to a file in the Samba data directory.
+ *
+ * @param name File to find, relative to CODEPAGEDIR.
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
+char *data_path(TALLOC_CTX *mem_ctx, const char *name);
+
+/**
+ * @brief Returns the platform specific shared library extension.
+ *
+ * @retval Pointer to a const char * containing the extension.
+ **/
+const char *shlib_ext(void);
+
+
#endif /* _SAMBA_UTIL_H_ */
diff --git a/lib/util/util_paths.c b/lib/util/util_paths.c
new file mode 100644
index 0000000000..0baa6801c5
--- /dev/null
+++ b/lib/util/util_paths.c
@@ -0,0 +1,63 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 2001-2007
+ Copyright (C) Simo Sorce 2001
+ Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
+ Copyright (C) James Peach 2006
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "dynconfig/dynconfig.h"
+
+/**
+ * @brief Returns an absolute path to a file in the Samba modules directory.
+ *
+ * @param name File to find, relative to MODULESDIR.
+ *
+ * @retval Pointer to a string containing the full path.
+ **/
+
+char *modules_path(TALLOC_CTX *mem_ctx, const char *name)
+{
+ return talloc_asprintf(mem_ctx, "%s/%s", get_dyn_MODULESDIR(), name);
+}
+
+/**
+ * @brief Returns an absolute path to a file in the Samba data directory.
+ *
+ * @param name File to find, relative to CODEPAGEDIR.
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
+
+char *data_path(TALLOC_CTX *mem_ctx, const char *name)
+{
+ return talloc_asprintf(mem_ctx, "%s/%s", get_dyn_CODEPAGEDIR(), name);
+}
+
+/**
+ * @brief Returns the platform specific shared library extension.
+ *
+ * @retval Pointer to a const char * containing the extension.
+ **/
+
+const char *shlib_ext(void)
+{
+ return get_dyn_SHLIBEXT();
+}
+
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index 3092b6ccbb..8ce30eb689 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -4,7 +4,7 @@ common_util_sources = '''talloc_stack.c smb_threads.c xfile.c data_blob.c
util_file.c time.c rbtree.c rfc1738.c select.c
genrand.c fsusage.c blocking.c become_daemon.c
signal.c system.c params.c util.c util_id.c util_net.c
- util_strlist.c idtree.c debug.c fault.c base64.c
+ util_strlist.c util_paths.c idtree.c debug.c fault.c base64.c
util_str.c util_str_common.c substitute.c ms_fnmatch.c'''
common_util_headers = 'debug.h'
diff --git a/libgpo/gpext/gpext.c b/libgpo/gpext/gpext.c
index f38d87358a..ac6c181e34 100644
--- a/libgpo/gpext/gpext.c
+++ b/libgpo/gpext/gpext.c
@@ -492,7 +492,8 @@ static NTSTATUS gp_glob_ext_list(TALLOC_CTX *mem_ctx,
SMB_STRUCT_DIR *dir = NULL;
SMB_STRUCT_DIRENT *dirent = NULL;
- dir = sys_opendir(modules_path(SAMBA_SUBSYSTEM_GPEXT));
+ dir = sys_opendir(modules_path(talloc_tos(),
+ SAMBA_SUBSYSTEM_GPEXT));
if (!dir) {
return map_nt_error_from_unix(errno);
}
diff --git a/source3/Makefile.in b/source3/Makefile.in
index f7458d353a..d4b59b95b9 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -421,7 +421,7 @@ LIBSAMBAUTIL_OBJ = \
UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
../lib/util/xfile.o ../lib/util/util_strlist.o \
../lib/util/util_file.o ../lib/util/data_blob.o \
- ../lib/util/util.o ../lib/util/fsusage.o \
+ ../lib/util/util.o ../lib/util/util_paths.o ../lib/util/fsusage.o \
../lib/util/params.o ../lib/util/talloc_stack.o \
../lib/util/genrand.o ../lib/util/util_net.o \
../lib/util/become_daemon.o ../lib/util/system.o \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 1cdc0c9081..10a84f9050 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -570,11 +570,8 @@ void *smb_xmalloc_array(size_t size, unsigned int count);
char *myhostname(void);
char *lock_path(const char *name);
char *pid_path(const char *name);
-char *modules_path(const char *name);
-char *data_path(const char *name);
char *state_path(const char *name);
char *cache_path(const char *name);
-const char *shlib_ext(void);
bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
const char **name);
bool ms_has_wild(const char *s);
diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c
index c6206c16e4..6070e29e5a 100644
--- a/source3/intl/lang_tdb.c
+++ b/source3/intl/lang_tdb.c
@@ -131,7 +131,7 @@ bool lang_tdb_init(const char *lang)
return True;
if (asprintf(&msg_path, "%s.msg",
- data_path((const char *)lang)) == -1) {
+ data_path(talloc_tos(), (const char *)lang)) == -1) {
DEBUG(0, ("asprintf failed\n"));
goto done;
}
diff --git a/source3/lib/module.c b/source3/lib/module.c
index de13668009..bec4fddefd 100644
--- a/source3/lib/module.c
+++ b/source3/lib/module.c
@@ -117,10 +117,10 @@ NTSTATUS smb_probe_module(const char *subsystem, const char *module)
}
full_path = talloc_asprintf(ctx,
- "%s/%s.%s",
- modules_path(subsystem),
- module,
- shlib_ext());
+ "%s/%s.%s",
+ modules_path(ctx, subsystem),
+ module,
+ shlib_ext());
if (!full_path) {
TALLOC_FREE(ctx);
return NT_STATUS_NO_MEMORY;
diff --git a/source3/lib/util.c b/source3/lib/util.c
index dc91fa06a1..a596385bfb 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1514,32 +1514,6 @@ char *pid_path(const char *name)
}
/**
- * @brief Returns an absolute path to a file in the Samba modules directory.
- *
- * @param name File to find, relative to MODULESDIR.
- *
- * @retval Pointer to a string containing the full path.
- **/
-
-char *modules_path(const char *name)
-{
- return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_MODULESDIR(), name);
-}
-
-/**
- * @brief Returns an absolute path to a file in the Samba data directory.
- *
- * @param name File to find, relative to CODEPAGEDIR.
- *
- * @retval Pointer to a talloc'ed string containing the full path.
- **/
-
-char *data_path(const char *name)
-{
- return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_CODEPAGEDIR(), name);
-}
-
-/**
* @brief Returns an absolute path to a file in the Samba state directory.
*
* @param name File to find, relative to STATEDIR.
@@ -1565,17 +1539,6 @@ char *cache_path(const char *name)
return xx_path(name, lp_cachedir());
}
-/**
- * @brief Returns the platform specific shared library extension.
- *
- * @retval Pointer to a const char * containing the extension.
- **/
-
-const char *shlib_ext(void)
-{
- return get_dyn_SHLIBEXT();
-}
-
/*******************************************************************
Given a filename - get its directory name
********************************************************************/
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index 575c35e458..988251e878 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -87,7 +87,7 @@ static void init_valid_table(void)
return;
}
- valid_table = (uint8 *)map_file(data_path("valid.dat"), 0x10000);
+ valid_table = (uint8 *)map_file(data_path(talloc_tos(), "valid.dat"), 0x10000);
if (!valid_table) {
smb_panic("Could not load valid.dat file required for mangle method=hash");
return;
diff --git a/source4/lib/ldb-samba/ldb_wrap.c b/source4/lib/ldb-samba/ldb_wrap.c
index f7d562377a..d713dfffbf 100644
--- a/source4/lib/ldb-samba/ldb_wrap.c
+++ b/source4/lib/ldb-samba/ldb_wrap.c
@@ -126,10 +126,7 @@ char *wrap_casefold(void *context, void *mem_ctx, const char *s, size_t n)
return NULL;
}
- ldb_set_modules_dir(ldb,
- talloc_asprintf(ldb,
- "%s/ldb",
- lpcfg_modulesdir(lp_ctx)));
+ ldb_set_modules_dir(ldb, modules_path(ldb, "ldb"));
ldb_set_debug(ldb, ldb_wrap_debug, NULL);
diff --git a/source4/param/util.c b/source4/param/util.c
index f8fc15a152..bcb5be1974 100644
--- a/source4/param/util.c
+++ b/source4/param/util.c
@@ -266,14 +266,6 @@ bool run_init_functions(init_module_fn *fns)
return ret;
}
-static char *modules_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
- const char *name)
-{
- return talloc_asprintf(mem_ctx, "%s/%s",
- lpcfg_modulesdir(lp_ctx),
- name);
-}
-
/**
* Load the initialization functions from DSO files for a specific subsystem.
*
@@ -282,7 +274,7 @@ static char *modules_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
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);
+ char *path = modules_path(mem_ctx, subsystem);
init_module_fn *ret;
ret = load_modules(mem_ctx, path);
diff --git a/source4/torture/drs/rpc/dssync.c b/source4/torture/drs/rpc/dssync.c
index 733e55ded5..8279e736b1 100644
--- a/source4/torture/drs/rpc/dssync.c
+++ b/source4/torture/drs/rpc/dssync.c
@@ -271,10 +271,7 @@ static bool test_LDAPBind(struct torture_context *tctx, struct DsSyncTest *ctx,
return NULL;
}
- ldb_set_modules_dir(ldb,
- talloc_asprintf(ldb,
- "%s/ldb",
- lpcfg_modulesdir(tctx->lp_ctx)));
+ ldb_set_modules_dir(ldb, modules_path(ldb, "ldb"));
if (ldb_set_opaque(ldb, "credentials", credentials)) {
talloc_free(ldb);
diff --git a/source4/torture/drs/rpc/msds_intid.c b/source4/torture/drs/rpc/msds_intid.c
index 53f4992ba2..14c6454abe 100644
--- a/source4/torture/drs/rpc/msds_intid.c
+++ b/source4/torture/drs/rpc/msds_intid.c
@@ -283,10 +283,7 @@ static bool _test_LDAPBind(struct torture_context *tctx,
return NULL;
}
- ldb_set_modules_dir(ldb,
- talloc_asprintf(ldb,
- "%s/ldb",
- lpcfg_modulesdir(tctx->lp_ctx)));
+ ldb_set_modules_dir(ldb, modules_path(ldb, "ldb"));
if (ldb_set_opaque(ldb, "credentials", credentials) != LDB_SUCCESS) {
talloc_free(ldb);
diff --git a/source4/torture/rpc/dsgetinfo.c b/source4/torture/rpc/dsgetinfo.c
index 6122ff0603..a0360e8404 100644
--- a/source4/torture/rpc/dsgetinfo.c
+++ b/source4/torture/rpc/dsgetinfo.c
@@ -88,7 +88,7 @@ static const char *torture_get_ldap_base_dn(struct torture_context *tctx, struct
}
ldb_set_modules_dir(ldb,
- talloc_asprintf(ldb, "%s/ldb", lpcfg_modulesdir(tctx->lp_ctx)));
+ modules_path(ldb, "ldb"));
ret = ldb_connect(ldb, ldap_url, 0, NULL);
if (ret != LDB_SUCCESS) {