summaryrefslogtreecommitdiff
path: root/source4/lib/util.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-16 11:54:05 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:26 -0500
commitc0277892d079dc2d8fcd5bbb5061369ddd8d9c74 (patch)
tree6e03adbbb7e6043191db1d554ff55cc5c706e812 /source4/lib/util.c
parent28e3c7ac0070bfc6991aa6b6ccf5ac0d4b34f7df (diff)
downloadsamba-c0277892d079dc2d8fcd5bbb5061369ddd8d9c74.tar.gz
samba-c0277892d079dc2d8fcd5bbb5061369ddd8d9c74.tar.bz2
samba-c0277892d079dc2d8fcd5bbb5061369ddd8d9c74.zip
r12285: move the smbd.tmp into piddir, --with-fhs piddir is different
from lockdir and they are typically set to piddir=/var/run/samba and lockdir=/var/lib/samba, and we should keep the temporary stuff under /var/run/samba metze (This used to be commit 571a870618cf595930da3057b147058489c8a37b)
Diffstat (limited to 'source4/lib/util.c')
-rw-r--r--source4/lib/util.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/source4/lib/util.c b/source4/lib/util.c
index 0733103e93..1b51fe5e05 100644
--- a/source4/lib/util.c
+++ b/source4/lib/util.c
@@ -625,6 +625,29 @@ char *lock_path(TALLOC_CTX* mem_ctx, const char *name)
return fname;
}
+
+/*****************************************************************
+ A useful function for returning a path in the Samba piddir directory.
+*****************************************************************/
+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.
*
@@ -670,7 +693,7 @@ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name)
{
char *fname, *dname;
- dname = lock_path(mem_ctx, "smbd.tmp");
+ dname = pid_path(mem_ctx, "smbd.tmp");
if (!directory_exist(dname)) {
mkdir(dname,0755);
}