diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-07-12 13:04:08 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-07-12 14:58:34 +0200 |
commit | c0eb56d1599fee0f0f5cf757b5381f56e04b74c1 (patch) | |
tree | c5e8dab9b820a775c3463075c7142802f4c677e9 /source4 | |
parent | 8a234cbe1589439497608d35f35768c6841750c9 (diff) | |
download | samba-c0eb56d1599fee0f0f5cf757b5381f56e04b74c1.tar.gz samba-c0eb56d1599fee0f0f5cf757b5381f56e04b74c1.tar.bz2 samba-c0eb56d1599fee0f0f5cf757b5381f56e04b74c1.zip |
s4:param: add "state dir" and "cache dir" options
metze
Diffstat (limited to 'source4')
-rw-r--r-- | source4/param/loadparm.c | 20 | ||||
-rw-r--r-- | source4/param/util.c | 56 | ||||
-rw-r--r-- | source4/scripting/python/samba/provision/__init__.py | 10 | ||||
-rw-r--r-- | source4/setup/provision.smb.conf.dc | 2 | ||||
-rw-r--r-- | source4/setup/provision.smb.conf.member | 2 | ||||
-rw-r--r-- | source4/setup/provision.smb.conf.standalone | 2 | ||||
-rw-r--r-- | source4/smbd/server.c | 2 |
7 files changed, 93 insertions, 1 deletions
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index b890ad81a9..df8b054d30 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -1083,6 +1083,22 @@ static struct parm_struct parm_table[] = { .enum_list = NULL }, { + .label = "state dir", + .type = P_STRING, + .p_class = P_GLOBAL, + .offset = GLOBAL_VAR(szStateDir), + .special = NULL, + .enum_list = NULL + }, + { + .label = "cache dir", + .type = P_STRING, + .p_class = P_GLOBAL, + .offset = GLOBAL_VAR(szCacheDir), + .special = NULL, + .enum_list = NULL + }, + { .label = "pid directory", .type = P_STRING, .p_class = P_GLOBAL, @@ -1476,6 +1492,8 @@ FN_GLOBAL_BOOL(idmap_trusted_only, bIdmapTrustedOnly) FN_GLOBAL_STRING(private_dir, szPrivateDir) FN_GLOBAL_STRING(serverstring, szServerString) FN_GLOBAL_STRING(lockdir, szLockDir) +FN_GLOBAL_STRING(statedir, szStateDir) +FN_GLOBAL_STRING(cachedir, szCacheDir) FN_GLOBAL_STRING(ncalrpc_dir, ncalrpc_dir) FN_GLOBAL_STRING(dos_charset, dos_charset) FN_GLOBAL_STRING(unix_charset, unix_charset) @@ -3263,6 +3281,8 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx) lpcfg_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR); lpcfg_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR); + lpcfg_do_global_parameter(lp_ctx, "state dir", dyn_STATEDIR); + lpcfg_do_global_parameter(lp_ctx, "cache dir", dyn_CACHEDIR); lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR); lpcfg_do_global_parameter(lp_ctx, "socket address", ""); diff --git a/source4/param/util.c b/source4/param/util.c index b1a7a571e6..92672ecba2 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -101,6 +101,62 @@ char *lpcfg_lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, } /** + A useful function for returning a path in the Samba state directory. +**/ +char *lpcfg_state_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_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, lpcfg_statedir(lp_ctx)); + 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 cache directory. +**/ +char *lpcfg_cache_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_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, lpcfg_cachedir(lp_ctx)); + 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 directory containing the current config file * * @param name File to find, relative to the config file directory. diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py index 91c4ef7f80..b20e584776 100644 --- a/source4/scripting/python/samba/provision/__init__.py +++ b/source4/scripting/python/samba/provision/__init__.py @@ -714,11 +714,17 @@ def make_smbconf(smbconf, hostname, domain, realm, serverrole, if targetdir is not None: privatedir_line = "private dir = " + os.path.abspath(os.path.join(targetdir, "private")) lockdir_line = "lock dir = " + os.path.abspath(targetdir) + statedir_line = "state dir = " + os.path.abspath(targetdir) + cachedir_line = "cache dir = " + os.path.abspath(targetdir) lp.set("lock dir", os.path.abspath(targetdir)) + lp.set("state dir", os.path.abspath(targetdir)) + lp.set("cache dir", os.path.abspath(targetdir)) else: privatedir_line = "" lockdir_line = "" + statedir_line = "" + cachedir_line = "" sysvol = os.path.join(lp.get("lock dir"), "sysvol") netlogon = os.path.join(sysvol, realm.lower(), "scripts") @@ -732,7 +738,9 @@ def make_smbconf(smbconf, hostname, domain, realm, serverrole, "NETLOGONPATH": netlogon, "SYSVOLPATH": sysvol, "PRIVATEDIR_LINE": privatedir_line, - "LOCKDIR_LINE": lockdir_line + "LOCKDIR_LINE": lockdir_line, + "STATEDIR_LINE": statedir_line, + "CACHEDIR_LINE": cachedir_line }) # reload the smb.conf diff --git a/source4/setup/provision.smb.conf.dc b/source4/setup/provision.smb.conf.dc index f489f59ff9..3fd2e77770 100644 --- a/source4/setup/provision.smb.conf.dc +++ b/source4/setup/provision.smb.conf.dc @@ -5,6 +5,8 @@ server role = ${SERVERROLE} ${PRIVATEDIR_LINE} ${LOCKDIR_LINE} + ${STATEDIR_LINE} + ${CACHEDIR_LINE} [netlogon] path = ${NETLOGONPATH} diff --git a/source4/setup/provision.smb.conf.member b/source4/setup/provision.smb.conf.member index 96e5d0c2e5..6c57b5a8d3 100644 --- a/source4/setup/provision.smb.conf.member +++ b/source4/setup/provision.smb.conf.member @@ -5,3 +5,5 @@ server role = ${SERVERROLE} ${PRIVATEDIR_LINE} ${LOCKDIR_LINE} + ${STATEDIR_LINE} + ${CACHEDIR_LINE} diff --git a/source4/setup/provision.smb.conf.standalone b/source4/setup/provision.smb.conf.standalone index 96e5d0c2e5..6c57b5a8d3 100644 --- a/source4/setup/provision.smb.conf.standalone +++ b/source4/setup/provision.smb.conf.standalone @@ -5,3 +5,5 @@ server role = ${SERVERROLE} ${PRIVATEDIR_LINE} ${LOCKDIR_LINE} + ${STATEDIR_LINE} + ${CACHEDIR_LINE} diff --git a/source4/smbd/server.c b/source4/smbd/server.c index 1be3b2885f..b0f683ba93 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -252,6 +252,8 @@ static void show_build(void) CONFIG_OPTION(DATADIR), CONFIG_OPTION(MODULESDIR), CONFIG_OPTION(LOCKDIR), + CONFIG_OPTION(STATEDIR), + CONFIG_OPTION(CACHEDIR), CONFIG_OPTION(PIDDIR), CONFIG_OPTION(PRIVATE_DIR), CONFIG_OPTION(SWATDIR), |