summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorSteven Danneman <steven.danneman@isilon.com>2009-01-08 11:18:13 -0800
committerMichael Adam <obnox@samba.org>2009-01-12 12:16:03 +0100
commit19a05bf2f485023b11b41dfae3f6459847d55ef7 (patch)
tree74b17e9f203dd81926a09876dc78e7cae3e799f6 /source3/lib
parentffb53c35748154081c1587b5f167721e32ff10f2 (diff)
downloadsamba-19a05bf2f485023b11b41dfae3f6459847d55ef7.tar.gz
samba-19a05bf2f485023b11b41dfae3f6459847d55ef7.tar.bz2
samba-19a05bf2f485023b11b41dfae3f6459847d55ef7.zip
Make STATEDIR and CACHEDIR configurable through ./configure and loadparm.c
If they are not explicitely set in either place both will default to LOCKDIR. Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/popt_common.c20
-rw-r--r--source3/lib/util.c60
2 files changed, 66 insertions, 14 deletions
diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index cad14ec493..115133089c 100644
--- a/source3/lib/popt_common.c
+++ b/source3/lib/popt_common.c
@@ -187,6 +187,8 @@ struct poptOption popt_common_debuglevel[] = {
* --modulesdir
* --shlibext
* --lockdir
+ * --statedir
+ * --cachedir
* --piddir
* --smb-passwd-file
* --private-dir
@@ -201,6 +203,8 @@ enum dyn_item{
DYN_MODULESDIR,
DYN_SHLIBEXT,
DYN_LOCKDIR,
+ DYN_STATEDIR,
+ DYN_CACHEDIR,
DYN_PIDDIR,
DYN_SMB_PASSWD_FILE,
DYN_PRIVATE_DIR,
@@ -262,6 +266,18 @@ static void popt_dynconfig_callback(poptContext con,
}
break;
+ case DYN_STATEDIR:
+ if (arg) {
+ set_dyn_STATEDIR(arg);
+ }
+ break;
+
+ case DYN_CACHEDIR:
+ if (arg) {
+ set_dyn_CACHEDIR(arg);
+ }
+ break;
+
case DYN_PIDDIR:
if (arg) {
set_dyn_PIDDIR(arg);
@@ -303,6 +319,10 @@ const struct poptOption popt_common_dynconfig[] = {
"Shared library extension", "SHLIBEXT" },
{ "lockdir", '\0' , POPT_ARG_STRING, NULL, DYN_LOCKDIR,
"Path to lock file directory", "LOCKDIR" },
+ { "statedir", '\0' , POPT_ARG_STRING, NULL, DYN_STATEDIR,
+ "Path to persistent state file directory", "STATEDIR" },
+ { "cachedir", '\0' , POPT_ARG_STRING, NULL, DYN_CACHEDIR,
+ "Path to temporary cache file directory", "CACHEDIR" },
{ "piddir", '\0' , POPT_ARG_STRING, NULL, DYN_PIDDIR,
"Path to PID file directory", "PIDDIR" },
{ "smb-passwd-file", '\0' , POPT_ARG_STRING, NULL, DYN_SMB_PASSWD_FILE,
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 08ea5add7a..1e6ee56230 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2232,9 +2232,14 @@ char *myhostname(void)
return ret;
}
-/*****************************************************************
- A useful function for returning a path in the Samba pid directory.
-*****************************************************************/
+/**
+ * @brief Returns an absolute path to a file concatenating the provided
+ * @a rootpath and @a basename
+ *
+ * @param name Filename, relative to @a rootpath
+ *
+ * @retval Pointer to a string containing the full path.
+ **/
static char *xx_path(const char *name, const char *rootpath)
{
@@ -2247,7 +2252,9 @@ static char *xx_path(const char *name, const char *rootpath)
trim_string(fname,"","/");
if (!directory_exist(fname)) {
- mkdir(fname,0755);
+ if (!mkdir(fname,0755))
+ DEBUG(1, ("Unable to create directory %s for file %s. "
+ "Error was %s\n", fname, name, strerror(errno)));
}
return talloc_asprintf(talloc_tos(),
@@ -2256,18 +2263,26 @@ static char *xx_path(const char *name, const char *rootpath)
name);
}
-/*****************************************************************
- A useful function for returning a path in the Samba lock directory.
-*****************************************************************/
+/**
+ * @brief Returns an absolute path to a file in the Samba lock directory.
+ *
+ * @param name File to find, relative to LOCKDIR.
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
char *lock_path(const char *name)
{
return xx_path(name, lp_lockdir());
}
-/*****************************************************************
- A useful function for returning a path in the Samba pid directory.
-*****************************************************************/
+/**
+ * @brief Returns an absolute path to a file in the Samba pid directory.
+ *
+ * @param name File to find, relative to PIDDIR.
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
char *pid_path(const char *name)
{
@@ -2313,13 +2328,30 @@ char *data_path(const char *name)
return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_CODEPAGEDIR(), name);
}
-/*****************************************************************
-a useful function for returning a path in the Samba state directory
- *****************************************************************/
+/**
+ * @brief Returns an absolute path to a file in the Samba state directory.
+ *
+ * @param name File to find, relative to STATEDIR.
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
char *state_path(const char *name)
{
- return xx_path(name, get_dyn_STATEDIR());
+ return xx_path(name, lp_statedir());
+}
+
+/**
+ * @brief Returns an absolute path to a file in the Samba cache directory.
+ *
+ * @param name File to find, relative to CACHEDIR.
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
+
+char *cache_path(const char *name)
+{
+ return xx_path(name, lp_cachedir());
}
/**