summaryrefslogtreecommitdiff
path: root/source4/lib/util
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-03-20 00:28:12 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:58:52 -0500
commit18cddd580e04344e05593d9f63beb9ead53cfab2 (patch)
tree7e49547cc37afcf2f3b974bf21d3bfd3ebcdfb20 /source4/lib/util
parent679a993329fddc320e4c67d2b66b5874c189b142 (diff)
downloadsamba-18cddd580e04344e05593d9f63beb9ead53cfab2.tar.gz
samba-18cddd580e04344e05593d9f63beb9ead53cfab2.tar.bz2
samba-18cddd580e04344e05593d9f63beb9ead53cfab2.zip
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)
Diffstat (limited to 'source4/lib/util')
-rw-r--r--source4/lib/util/config.mk2
-rw-r--r--source4/lib/util/debug.c3
-rw-r--r--source4/lib/util/fault.c7
-rw-r--r--source4/lib/util/util.c158
-rw-r--r--source4/lib/util/util.h3
5 files changed, 10 insertions, 163 deletions
diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk
index 5aac291152..c598d703c5 100644
--- a/source4/lib/util/config.mk
+++ b/source4/lib/util/config.mk
@@ -33,7 +33,7 @@ OBJ_FILES = xfile.o \
module.o
REQUIRED_SUBSYSTEMS = \
CHARSET LIBREPLACE LIBCRYPTO EXT_LIB_DL LIBTALLOC \
- SOCKET_WRAPPER LIBSAMBA-CONFIG \
+ SOCKET_WRAPPER \
# for the base64 functions
ldb
diff --git a/source4/lib/util/debug.c b/source4/lib/util/debug.c
index 2c40064b75..fa781c823a 100644
--- a/source4/lib/util/debug.c
+++ b/source4/lib/util/debug.c
@@ -117,12 +117,13 @@ _PUBLIC_ void do_debug(const char *format, ...) _PRINTF_ATTRIBUTE(1,2)
free(s);
}
+_PUBLIC_ const char *logfile = NULL;
+
/**
reopen the log file (usually called because the log file name might have changed)
*/
_PUBLIC_ void reopen_logs(void)
{
- const char *logfile = lp_logfile();
char *fname = NULL;
int old_fd = state.fd;
diff --git a/source4/lib/util/fault.c b/source4/lib/util/fault.c
index ff44b8a292..8b447851dc 100644
--- a/source4/lib/util/fault.c
+++ b/source4/lib/util/fault.c
@@ -109,18 +109,19 @@ _PUBLIC_ void call_backtrace(void)
#endif
}
+_PUBLIC_ const char *panic_action = NULL;
+
/**
Something really nasty happened - panic !
**/
_PUBLIC_ void smb_panic(const char *why)
{
- const char *cmd = lp_panic_action();
int result;
- if (cmd && *cmd) {
+ if (panic_action && *panic_action) {
char pidstr[20];
char cmdstring[200];
- safe_strcpy(cmdstring, cmd, sizeof(cmdstring));
+ safe_strcpy(cmdstring, panic_action, sizeof(cmdstring));
snprintf(pidstr, sizeof(pidstr), "%u", getpid());
all_string_sub(cmdstring, "%PID%", pidstr, sizeof(cmdstring));
if (progname) {
diff --git a/source4/lib/util/util.c b/source4/lib/util/util.c
index a0890d5ba9..b7293c0092 100644
--- a/source4/lib/util/util.c
+++ b/source4/lib/util/util.c
@@ -23,7 +23,6 @@
*/
#include "includes.h"
-#include "dynconfig.h"
#include "system/network.h"
#include "system/iconv.h"
#include "system/filesys.h"
@@ -268,30 +267,6 @@ _PUBLIC_ void safe_free(void *p)
/**
- 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;
-}
-
-
-/**
Get my own name, return in malloc'ed storage.
**/
@@ -585,139 +560,6 @@ _PUBLIC_ void *memdup(const void *p, size_t size)
}
/**
- 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;
-}
-
-/**
* Write a password to the log file.
*
* @note Only actually does something if DEBUG_PASSWORD was defined during
diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h
index 73fb675e28..1b48bafc94 100644
--- a/source4/lib/util/util.h
+++ b/source4/lib/util/util.h
@@ -36,6 +36,9 @@ struct substitute_context;
struct asn1_data;
struct smbsrv_tcon;
+extern const char *logfile;
+extern const char *panic_action;
+
#include "util/xfile.h"
#include "util/debug.h"
#include "util/mutex.h"