From f4f65ea9a3c9c99871bb76381541b7f1703c60c8 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 19 Nov 2001 02:24:05 +0000 Subject: Source file defining global variables for configuration paths. This has two purposes: - If ./configure is re-run to configure Samba for a new set of path or prefix, then when Samba is re-built it really will use the new paths. - This is a step towards making sure all programs can be consistently told to use a different configuration file or prefix directory, which is required for testing. Possibly not true at the moment. (This used to be commit f54c64babd31abf9f5bbf960316d4b9502b9477d) --- source3/dynconfig.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 source3/dynconfig.c (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c new file mode 100644 index 0000000000..4db2caa652 --- /dev/null +++ b/source3/dynconfig.c @@ -0,0 +1,45 @@ +/* + Unix SMB/Netbios implementation. + Copyright (C) 2001 by Martin Pool + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/** + * @file dynconfig.c + * + * @brief Compile-time configured constants. + * + * This file should be the only file that depends on path + * configuration (--prefix, etc), so that if ./configure is re-run, + * all programs will be appropriately updated. Everything else in + * Samba should import extern variables from here, rather than relying + * on preprocessor macros. + * + * Eventually some of these may become even more variable, so that + * they can for example consistently be set across the whole of Samba + * by command-line parameters, config file entries, or environment + * variables. + **/ + +char const *dyn_SBINDIR = SBINDIR, + *dyn_BINDIR = BINDIR, + *dyn_SWATDIR = SWATDIR; + +pstring dyn_CONFIGFILE = CONFIGFILE; /**< Location of smb.conf file. **/ + +pstring dyn_LOGFILEBASE; /**< Log file directory. **/ -- cgit From f741f656737f4ec46cd318e986b6bf412ed309d2 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 19 Nov 2001 02:49:53 +0000 Subject: Store some path names in global variables initialized to configure default, rather than in preprocessor macros. (This used to be commit 79ec88f0da40faebe1e587f1b3e87b5f2b184f58) --- source3/dynconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 4db2caa652..22d6caa8cf 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -22,7 +22,7 @@ /** * @file dynconfig.c * - * @brief Compile-time configured constants. + * @brief Global configurations, initialized to configured defaults. * * This file should be the only file that depends on path * configuration (--prefix, etc), so that if ./configure is re-run, -- cgit From 8654a161c8722a0059b15af12cdb81b27d49e71a Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 19 Nov 2001 03:12:10 +0000 Subject: LMHOSTSFILE is now dynamically configured too. (This used to be commit a779710fff5fddcbf65a8ddc8e9169b586b85481) --- source3/dynconfig.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 22d6caa8cf..fd77e88309 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -43,3 +43,5 @@ char const *dyn_SBINDIR = SBINDIR, pstring dyn_CONFIGFILE = CONFIGFILE; /**< Location of smb.conf file. **/ pstring dyn_LOGFILEBASE; /**< Log file directory. **/ + +pstring dyn_LMHOSTSFILE; /**< Statically configured LanMan hosts. **/ -- cgit From caef2d2884fb202bd6184f9a676ecff94c7ab600 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 19 Nov 2001 03:35:27 +0000 Subject: LIBDIR and LOCKDIR are dynamically configured too. (This used to be commit 868999ad3c82ad72f11d5b3208b0e42b1ed95096) --- source3/dynconfig.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index fd77e88309..34603fee86 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -34,6 +34,9 @@ * they can for example consistently be set across the whole of Samba * by command-line parameters, config file entries, or environment * variables. + * + * @todo Perhaps eventually these should be merged into the parameter + * table? There's kind of a chicken-and-egg situation there... **/ char const *dyn_SBINDIR = SBINDIR, @@ -45,3 +48,17 @@ pstring dyn_CONFIGFILE = CONFIGFILE; /**< Location of smb.conf file. **/ pstring dyn_LOGFILEBASE; /**< Log file directory. **/ pstring dyn_LMHOSTSFILE; /**< Statically configured LanMan hosts. **/ + +/** + * @brief Samba library directory. + * + * @sa lib_path() to get the path to a file inside the LIBDIR. + **/ +pstring dyn_LIBDIR; + +/** + * @brief Directory holding lock files. + * + * Not writable, but used to set a default in the parameter table. + **/ +const pstring dyn_LOCKDIR; -- cgit From c2a4f75e3e2b06fe538196ffd008705ede3cca7f Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 19 Nov 2001 03:38:57 +0000 Subject: oopsum. (This used to be commit 9b6667aa19c479fb27f557ca24129592bf94cbb7) --- source3/dynconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 34603fee86..a12eee1506 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -61,4 +61,4 @@ pstring dyn_LIBDIR; * * Not writable, but used to set a default in the parameter table. **/ -const pstring dyn_LOCKDIR; +pstring dyn_LOCKDIR; -- cgit From 9ba9fcd6dd56e48847bd91bb1fbb34089a684890 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 19 Nov 2001 03:52:09 +0000 Subject: dyn_LOCKDIR should be const because it's never modified directly -- it's just copied in to the parameter table and optionally overridden there. (This used to be commit 988fe772a39e08dec738b045021cd6e06b4e59c8) --- source3/dynconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index a12eee1506..34603fee86 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -61,4 +61,4 @@ pstring dyn_LIBDIR; * * Not writable, but used to set a default in the parameter table. **/ -pstring dyn_LOCKDIR; +const pstring dyn_LOCKDIR; -- cgit From 788379830166313922fa6cb56f789a6754e27614 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 19 Nov 2001 05:49:20 +0000 Subject: Move all other paths into dynconfig (This used to be commit d51ef6bfa3d194b58c3ee7706a7d475ef042676d) --- source3/dynconfig.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 34603fee86..a9055715c9 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -45,20 +45,29 @@ char const *dyn_SBINDIR = SBINDIR, pstring dyn_CONFIGFILE = CONFIGFILE; /**< Location of smb.conf file. **/ -pstring dyn_LOGFILEBASE; /**< Log file directory. **/ +/** Log file directory. **/ +pstring dyn_LOGFILEBASE = LOGFILEBASE; -pstring dyn_LMHOSTSFILE; /**< Statically configured LanMan hosts. **/ +/** Statically configured LanMan hosts. **/ +pstring dyn_LMHOSTSFILE = LMHOSTSFILE; /** * @brief Samba library directory. * * @sa lib_path() to get the path to a file inside the LIBDIR. **/ -pstring dyn_LIBDIR; +pstring dyn_LIBDIR = LIBDIR; /** * @brief Directory holding lock files. * * Not writable, but used to set a default in the parameter table. **/ -const pstring dyn_LOCKDIR; +const pstring dyn_LOCKDIR = LOCKDIR; + +const pstring dyn_DRIVERFILE = DRIVERFILE; + +const pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE; +const pstring dyn_PRIVATE_DIR = PRIVATE_DIR; + + -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/dynconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index a9055715c9..76b5bce5c9 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -1,5 +1,5 @@ /* - Unix SMB/Netbios implementation. + Unix SMB/CIFS implementation. Copyright (C) 2001 by Martin Pool This program is free software; you can redistribute it and/or modify -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/dynconfig.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 76b5bce5c9..b1d4f000af 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -64,6 +64,7 @@ pstring dyn_LIBDIR = LIBDIR; * Not writable, but used to set a default in the parameter table. **/ const pstring dyn_LOCKDIR = LOCKDIR; +const pstring dyn_PIDDIR = PIDDIR; const pstring dyn_DRIVERFILE = DRIVERFILE; -- cgit From f3e3a56ea9085b186af24b0b4e911863fd9ceacc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 29 Nov 2002 02:58:59 +0000 Subject: Merge a bunch of trivial changes from HEAD. The difference remaining should actual functional differences between HEAD and 3.0. - Mostly reformatting - Removal of unecessary #include "smb.h" - Merge of dyn_DRIVERFILE removal - Silly bug fix for python code (This used to be commit d3998307adc50ba50defe610cb656c73799ae3b9) --- source3/dynconfig.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index b1d4f000af..18a280f7d0 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -66,9 +66,5 @@ pstring dyn_LIBDIR = LIBDIR; const pstring dyn_LOCKDIR = LOCKDIR; const pstring dyn_PIDDIR = PIDDIR; -const pstring dyn_DRIVERFILE = DRIVERFILE; - const pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE; const pstring dyn_PRIVATE_DIR = PRIVATE_DIR; - - -- cgit From 49d3f7bc81d3ce96513128f3e504ae1228e53d68 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 14 Feb 2003 00:48:28 +0000 Subject: merge from HEAD - enable dynamic RPC modules (This used to be commit d9c485b01017594d113502f9de2248d6c120cfa3) --- source3/dynconfig.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 18a280f7d0..4577c3947c 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -1,6 +1,7 @@ /* Unix SMB/CIFS implementation. Copyright (C) 2001 by Martin Pool + Copyright (C) 2003 by Anthony Liguori 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 @@ -56,7 +57,8 @@ pstring dyn_LMHOSTSFILE = LMHOSTSFILE; * * @sa lib_path() to get the path to a file inside the LIBDIR. **/ -pstring dyn_LIBDIR = LIBDIR; +pstring dyn_LIBDIR = LIBDIR; +const fstring dyn_SHLIBEXT = SHLIBEXT; /** * @brief Directory holding lock files. -- cgit From f210ee9b99b3b6ac0234680f1af83fd783ef9af4 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 1 Aug 2003 14:47:39 +0000 Subject: Fix copyright statements for various pieces of Anthony Liguori's work. (This used to be commit 15d2bc47854df75f8b2644ccbc887d0357d9cd27) --- source3/dynconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 4577c3947c..34c716926c 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. Copyright (C) 2001 by Martin Pool - Copyright (C) 2003 by Anthony Liguori + Copyright (C) 2003 by Jim McDonough 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 -- cgit From 90a6873b0570f2691ba8d8fd11154c856bdd4415 Mon Sep 17 00:00:00 2001 From: James Peach Date: Wed, 24 May 2006 04:02:14 +0000 Subject: r15848: Introduce commandline options to set the remainder of the parameters in dynconfig.c. This is mainly useful for test harness scripts, hence the lack of short options. (This used to be commit bf3b71c84595608d71e0f15a6158adacb295518e) --- source3/dynconfig.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 34c716926c..3104a12f7c 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -58,15 +58,15 @@ pstring dyn_LMHOSTSFILE = LMHOSTSFILE; * @sa lib_path() to get the path to a file inside the LIBDIR. **/ pstring dyn_LIBDIR = LIBDIR; -const fstring dyn_SHLIBEXT = SHLIBEXT; +fstring dyn_SHLIBEXT = SHLIBEXT; /** * @brief Directory holding lock files. * * Not writable, but used to set a default in the parameter table. **/ -const pstring dyn_LOCKDIR = LOCKDIR; -const pstring dyn_PIDDIR = PIDDIR; +pstring dyn_LOCKDIR = LOCKDIR; +pstring dyn_PIDDIR = PIDDIR; -const pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE; -const pstring dyn_PRIVATE_DIR = PRIVATE_DIR; +pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE; +pstring dyn_PRIVATE_DIR = PRIVATE_DIR; -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/dynconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 3104a12f7c..9298e1572a 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -5,7 +5,7 @@ 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 2 of the License, or + 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, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/dynconfig.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 9298e1572a..6a40a07554 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -14,8 +14,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 8132a7b98b09bb5915559f6ca0ca8eb3ae0e529d Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Thu, 1 Nov 2007 13:00:10 -0400 Subject: Patch from Debian Samba package maintainers: Patch 1 of 3: - Patch 1 adds the new variables - Patch 2 makes uses of them for files belonging to the "state" path and the "code pages" path This patch seemed more easily acceptable, which explains why we separated it from patch 3 - Patch 3 reassigns files to the "cache" path. Indeed all "debatable" changes have been moved to that one The point is adding: - a path for non discardable state data: basically all TDB files that may need to be backed up - a path for shared data: mostly codepage stuff - a path for cache data to host files such as browse.dat, printers.tbd, .tdb All these are currently mixed in "libdir" (${prefix}/lib/samba by default). The patch keeps these new paths to point to ${prefix}/lib/samba by default and does therefore not change the software behaviour. Used alone, it just adds unused variables...so it can safely be used in sources without any behaviour change and no impact on Samba developers work. (This used to be commit b7d2fadbef044a89920da613b1aafc74a3d94e24) --- source3/dynconfig.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 6a40a07554..01460b8363 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -51,6 +51,13 @@ pstring dyn_LOGFILEBASE = LOGFILEBASE; /** Statically configured LanMan hosts. **/ pstring dyn_LMHOSTSFILE = LMHOSTSFILE; +/** + * @brief Samba data directory. + * + * @sa data_path() to get the path to a file inside the CODEPAGEDIR. + **/ +pstring dyn_CODEPAGEDIR = CODEPAGEDIR; + /** * @brief Samba library directory. * @@ -69,3 +76,27 @@ pstring dyn_PIDDIR = PIDDIR; pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE; pstring dyn_PRIVATE_DIR = PRIVATE_DIR; + + +/* In non-FHS mode, these should be configurable using 'lock dir ='; + but in FHS mode, they are their own directory. Implement as wrapper + functions so that everything can still be kept in dynconfig.c. + */ + +char *dyn_STATEDIR(void) +{ +#ifdef FHS_COMPATIBLE + return STATEDIR; +#else + return lp_lockdir(); +#endif +} + +char *dyn_CACHEDIR(void) +{ +#ifdef FHS_COMPATIBLE + return CACHEDIR; +#else + return lp_lockdir(); +#endif +} -- cgit From 77652360ec78807bbd2c7989bc9ea06943a6b2d1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 6 Dec 2007 19:01:27 -0800 Subject: These should be char *, but replace them with [1024] for now to eliminate the pstring data type. Jeremy (This used to be commit d690ba77107d8c2b722972300272f9d540641ce9) --- source3/dynconfig.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 01460b8363..c9dcea5204 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -43,27 +43,28 @@ char const *dyn_SBINDIR = SBINDIR, *dyn_BINDIR = BINDIR, *dyn_SWATDIR = SWATDIR; -pstring dyn_CONFIGFILE = CONFIGFILE; /**< Location of smb.conf file. **/ +/* JRA - FIXME - these should be dynamic char * */ +char dyn_CONFIGFILE[1024] = CONFIGFILE; /**< Location of smb.conf file. **/ /** Log file directory. **/ -pstring dyn_LOGFILEBASE = LOGFILEBASE; +char dyn_LOGFILEBASE[1024] = LOGFILEBASE; /** Statically configured LanMan hosts. **/ -pstring dyn_LMHOSTSFILE = LMHOSTSFILE; +char dyn_LMHOSTSFILE[1024] = LMHOSTSFILE; /** * @brief Samba data directory. * * @sa data_path() to get the path to a file inside the CODEPAGEDIR. **/ -pstring dyn_CODEPAGEDIR = CODEPAGEDIR; +char dyn_CODEPAGEDIR[1024] = CODEPAGEDIR; /** * @brief Samba library directory. * * @sa lib_path() to get the path to a file inside the LIBDIR. **/ -pstring dyn_LIBDIR = LIBDIR; +char dyn_LIBDIR[1024] = LIBDIR; fstring dyn_SHLIBEXT = SHLIBEXT; /** @@ -71,11 +72,11 @@ fstring dyn_SHLIBEXT = SHLIBEXT; * * Not writable, but used to set a default in the parameter table. **/ -pstring dyn_LOCKDIR = LOCKDIR; -pstring dyn_PIDDIR = PIDDIR; +char dyn_LOCKDIR[1024] = LOCKDIR; +char dyn_PIDDIR[1024] = PIDDIR; -pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE; -pstring dyn_PRIVATE_DIR = PRIVATE_DIR; +char dyn_SMB_PASSWD_FILE[1024] = SMB_PASSWD_FILE; +char dyn_PRIVATE_DIR[1024] = PRIVATE_DIR; /* In non-FHS mode, these should be configurable using 'lock dir ='; -- cgit From 7faee02d0d351c5c039e8f1be7e82ce3a93cbe96 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2007 11:30:37 -0800 Subject: Remove the char[1024] strings from dynconfig. Replace them with malloc'ing accessor functions. Should save a lot of static space :-). Jeremy. (This used to be commit 52dc5eaef2106015b3a8b659e818bdb15ad94b05) --- source3/dynconfig.c | 251 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 231 insertions(+), 20 deletions(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index c9dcea5204..ab0dd48da7 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -1,18 +1,19 @@ -/* +/* Unix SMB/CIFS implementation. Copyright (C) 2001 by Martin Pool Copyright (C) 2003 by Jim McDonough - + Copyright (C) 2007 by Jeremy Allison + 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 . */ @@ -39,52 +40,262 @@ * table? There's kind of a chicken-and-egg situation there... **/ -char const *dyn_SBINDIR = SBINDIR, - *dyn_BINDIR = BINDIR, - *dyn_SWATDIR = SWATDIR; +#if 0 +static char const *dyn_SBINDIR = SBINDIR; +static char const *dyn_BINDIR = BINDIR; +static char const *dyn_SWATDIR = SWATDIR; +#endif + +#define DEFINE_DYN_CONFIG_PARAM(name) \ +static char *dyn_##name; \ +\ + const char *get_dyn_##name(void) \ +{\ + if (dyn_##name == NULL) {\ + return name;\ + }\ + return dyn_##name;\ +}\ +\ + const char *set_dyn_##name(const char *newpath) \ +{\ + if (dyn_##name) {\ + SAFE_FREE(dyn_##name);\ + }\ + dyn_##name = SMB_STRDUP(newpath);\ + return dyn_##name;\ +} + +DEFINE_DYN_CONFIG_PARAM(SBINDIR) +DEFINE_DYN_CONFIG_PARAM(BINDIR) +DEFINE_DYN_CONFIG_PARAM(SWATDIR) +DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/ +DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/ +DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/ +DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR) +DEFINE_DYN_CONFIG_PARAM(LIBDIR) +DEFINE_DYN_CONFIG_PARAM(SHLIBEXT) +DEFINE_DYN_CONFIG_PARAM(LOCKDIR) +DEFINE_DYN_CONFIG_PARAM(PIDDIR) +DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE) +DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR) + +#if 0 +static char *dyn_CONFIGFILE; /**< Location of smb.conf file. **/ + +const char *get_dyn_CONFIGFILE(void) +{ + if (dyn_CONFIGFILE == NULL) { + return CONFIGFILE; + } + return dyn_CONFIGFILE; +} -/* JRA - FIXME - these should be dynamic char * */ -char dyn_CONFIGFILE[1024] = CONFIGFILE; /**< Location of smb.conf file. **/ +const char *set_dyn_CONFIGFILE(const char *newpath) +{ + if (dyn_CONFIGFILE) { + SAFE_FREE(dyn_CONFIGFILE); + } + dyn_CONFIGFILE = SMB_STRDUP(newpath); + return dyn_CONFIGFILE; +} /** Log file directory. **/ -char dyn_LOGFILEBASE[1024] = LOGFILEBASE; +static char *dyn_LOGFILEBASE; + +const char *get_dyn_LOGFILEBASE(void) +{ + if (dyn_LOGFILEBASE == NULL) { + return LOGFILEBASE; + } + return dyn_LOGFILEBASE; +} + +const char *set_dyn_LOGFILEBASE(const char *newpath) +{ + if (dyn_LOGFILEBASE) { + SAFE_FREE(dyn_LOGFILEBASE); + } + dyn_LOGFILEBASE = SMB_STRDUP(newpath); + return dyn_LOGFILEBASE; +} /** Statically configured LanMan hosts. **/ -char dyn_LMHOSTSFILE[1024] = LMHOSTSFILE; +static char *dyn_LMHOSTSFILE; + +const char *get_dyn_LMHOSTSFILE(void) +{ + if (dyn_LMHOSTSFILE == NULL) { + return LMHOSTSFILE; + } + return dyn_LMHOSTSFILE; +} + +const char *set_dyn_LMHOSTSFILE(const char *newpath) +{ + if (dyn_LMHOSTSFILE) { + SAFE_FREE(dyn_LMHOSTSFILE); + } + dyn_LMHOSTSFILE = SMB_STRDUP(newpath); + return dyn_LMHOSTSFILE; +} /** * @brief Samba data directory. * * @sa data_path() to get the path to a file inside the CODEPAGEDIR. **/ -char dyn_CODEPAGEDIR[1024] = CODEPAGEDIR; +static char *dyn_CODEPAGEDIR; + +const char *get_dyn_CODEPAGEDIR(void) +{ + if (dyn_CODEPAGEDIR == NULL) { + return CODEPAGEDIR; + } + return dyn_CODEPAGEDIR; +} + +const char *set_dyn_CODEPAGEDIR(const char *newpath) +{ + if (dyn_CODEPAGEDIR) { + SAFE_FREE(dyn_CODEPAGEDIR); + } + dyn_CODEPAGEDIR = SMB_STRDUP(newpath); + return dyn_CODEPAGEDIR; +} /** * @brief Samba library directory. * * @sa lib_path() to get the path to a file inside the LIBDIR. **/ -char dyn_LIBDIR[1024] = LIBDIR; -fstring dyn_SHLIBEXT = SHLIBEXT; +static char *dyn_LIBDIR; + +const char *get_dyn_LIBDIR(void) +{ + if (dyn_LIBDIR == NULL) { + return LIBDIR; + } + return dyn_CODEPAGEDIR; +} + +const char *set_dyn_LIBDIR(const char *newpath) +{ + if (dyn_LIBDIR) { + SAFE_FREE(dyn_LIBDIR); + } + dyn_LIBDIR = SMB_STRDUP(newpath); + return dyn_LIBDIR; +} + +static char *dyn_SHLIBEXT; + +const char *get_dyn_SHLIBEXT(void) +{ + if (dyn_SHLIBEXT == NULL) { + return SHLIBEXT; + } + return dyn_SHLIBEXT; +} + +const char *set_dyn_SHLIBEXT(const char *newpath) +{ + if (dyn_SHLIBEXT) { + SAFE_FREE(dyn_SHLIBEXT); + } + dyn_SHLIBEXT = SMB_STRDUP(newpath); + return dyn_SHLIBEXT; +} /** * @brief Directory holding lock files. * * Not writable, but used to set a default in the parameter table. **/ -char dyn_LOCKDIR[1024] = LOCKDIR; -char dyn_PIDDIR[1024] = PIDDIR; -char dyn_SMB_PASSWD_FILE[1024] = SMB_PASSWD_FILE; -char dyn_PRIVATE_DIR[1024] = PRIVATE_DIR; +static char *dyn_LOCKDIR; + +const char *get_dyn_LOCKDIR(void) +{ + if (dyn_LOCKDIR == NULL) { + return LOCKDIR; + } + return dyn_LOCKDIR; +} + +const char *set_dyn_LOCKDIR(const char *newpath) +{ + if (dyn_LOCKDIR) { + SAFE_FREE(dyn_LOCKDIR); + } + dyn_LOCKDIR = SMB_STRDUP(newpath); + return dyn_LOCKDIR; +} + +static char *dyn_PIDDIR; + +const char *get_dyn_PIDDIR(void) +{ + if (dyn_PIDDIR == NULL) { + return PIDDIR; + } + return dyn_PIDDIR; +} +const char *set_dyn_PIDDIR(const char *newpath) +{ + if (dyn_PIDDIR) { + SAFE_FREE(dyn_PIDDIR); + } + dyn_PIDDIR = SMB_STRDUP(newpath); + return dyn_PIDDIR; +} + +static char *dyn_SMB_PASSWD_FILE; + +const char *get_dyn_SMB_PASSWD_FILE(void) +{ + if (dyn_SMB_PASSWD_FILE == NULL) { + return SMB_PASSWD_FILE; + } + return dyn_SMB_PASSWD_FILE; +} + +const char *set_dyn_SMB_PASSWD_FILE(const char *newpath) +{ + if (dyn_SMB_PASSWD_FILE) { + SAFE_FREE(dyn_SMB_PASSWD_FILE); + } + dyn_SMB_PASSWD_FILE = SMB_STRDUP(newpath); + return dyn_SMB_PASSWD_FILE; +} + +static char *dyn_PRIVATE_DIR; + +const char *get_dyn_PRIVATE_DIR(void) +{ + if (dyn_PRIVATE_DIR == NULL) { + return PRIVATE_DIR; + } + return dyn_PRIVATE_DIR; +} + +const char *set_dyn_PRIVATE_DIR(const char *newpath) +{ + if (dyn_PRIVATE_DIR) { + SAFE_FREE(dyn_PRIVATE_DIR); + } + dyn_PRIVATE_DIR = SMB_STRDUP(newpath); + return dyn_PRIVATE_DIR; +} +#endif /* In non-FHS mode, these should be configurable using 'lock dir ='; but in FHS mode, they are their own directory. Implement as wrapper functions so that everything can still be kept in dynconfig.c. */ -char *dyn_STATEDIR(void) +const char *get_dyn_STATEDIR(void) { #ifdef FHS_COMPATIBLE return STATEDIR; @@ -93,7 +304,7 @@ char *dyn_STATEDIR(void) #endif } -char *dyn_CACHEDIR(void) +const char *get_dyn_CACHEDIR(void) { #ifdef FHS_COMPATIBLE return CACHEDIR; -- cgit From 174100c30997e6ae70492528da998e30c1bfce60 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 4 Feb 2008 16:16:59 +0100 Subject: popt: Use SMB_CONF_PATH environment var if no other configfile is set. Now --configfile (or -s) will have precedence, if that's not given SMB_CONF_PATH is checked, otherwise the $(CONFIGDIR)/smb.conf default value is used. Thanks to Michael for his comments. (This used to be commit 92a9c6c56fa90aead3b7f4a07bf4f3973ba23555) --- source3/dynconfig.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index ab0dd48da7..57008ece44 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -64,6 +64,11 @@ static char *dyn_##name; \ }\ dyn_##name = SMB_STRDUP(newpath);\ return dyn_##name;\ +}\ +\ + bool is_default_dyn_##name(void) \ +{\ + return (dyn_##name == NULL);\ } DEFINE_DYN_CONFIG_PARAM(SBINDIR) -- cgit From b39040cfe2fd89388962299bd4b2b7fd492a9f2e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Aug 2008 00:58:47 +0200 Subject: dynconfig: remove commented-out old stuff from dynconfig.c and dynconfig.h Michael (This used to be commit 85a781fa0248fcd0cefcc4de25b3dea3e37d5844) --- source3/dynconfig.c | 216 ---------------------------------------------------- 1 file changed, 216 deletions(-) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 57008ece44..241a659a51 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -40,12 +40,6 @@ * table? There's kind of a chicken-and-egg situation there... **/ -#if 0 -static char const *dyn_SBINDIR = SBINDIR; -static char const *dyn_BINDIR = BINDIR; -static char const *dyn_SWATDIR = SWATDIR; -#endif - #define DEFINE_DYN_CONFIG_PARAM(name) \ static char *dyn_##name; \ \ @@ -85,216 +79,6 @@ DEFINE_DYN_CONFIG_PARAM(PIDDIR) DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE) DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR) -#if 0 -static char *dyn_CONFIGFILE; /**< Location of smb.conf file. **/ - -const char *get_dyn_CONFIGFILE(void) -{ - if (dyn_CONFIGFILE == NULL) { - return CONFIGFILE; - } - return dyn_CONFIGFILE; -} - -const char *set_dyn_CONFIGFILE(const char *newpath) -{ - if (dyn_CONFIGFILE) { - SAFE_FREE(dyn_CONFIGFILE); - } - dyn_CONFIGFILE = SMB_STRDUP(newpath); - return dyn_CONFIGFILE; -} - -/** Log file directory. **/ -static char *dyn_LOGFILEBASE; - -const char *get_dyn_LOGFILEBASE(void) -{ - if (dyn_LOGFILEBASE == NULL) { - return LOGFILEBASE; - } - return dyn_LOGFILEBASE; -} - -const char *set_dyn_LOGFILEBASE(const char *newpath) -{ - if (dyn_LOGFILEBASE) { - SAFE_FREE(dyn_LOGFILEBASE); - } - dyn_LOGFILEBASE = SMB_STRDUP(newpath); - return dyn_LOGFILEBASE; -} - -/** Statically configured LanMan hosts. **/ -static char *dyn_LMHOSTSFILE; - -const char *get_dyn_LMHOSTSFILE(void) -{ - if (dyn_LMHOSTSFILE == NULL) { - return LMHOSTSFILE; - } - return dyn_LMHOSTSFILE; -} - -const char *set_dyn_LMHOSTSFILE(const char *newpath) -{ - if (dyn_LMHOSTSFILE) { - SAFE_FREE(dyn_LMHOSTSFILE); - } - dyn_LMHOSTSFILE = SMB_STRDUP(newpath); - return dyn_LMHOSTSFILE; -} - -/** - * @brief Samba data directory. - * - * @sa data_path() to get the path to a file inside the CODEPAGEDIR. - **/ -static char *dyn_CODEPAGEDIR; - -const char *get_dyn_CODEPAGEDIR(void) -{ - if (dyn_CODEPAGEDIR == NULL) { - return CODEPAGEDIR; - } - return dyn_CODEPAGEDIR; -} - -const char *set_dyn_CODEPAGEDIR(const char *newpath) -{ - if (dyn_CODEPAGEDIR) { - SAFE_FREE(dyn_CODEPAGEDIR); - } - dyn_CODEPAGEDIR = SMB_STRDUP(newpath); - return dyn_CODEPAGEDIR; -} - -/** - * @brief Samba library directory. - * - * @sa lib_path() to get the path to a file inside the LIBDIR. - **/ -static char *dyn_LIBDIR; - -const char *get_dyn_LIBDIR(void) -{ - if (dyn_LIBDIR == NULL) { - return LIBDIR; - } - return dyn_CODEPAGEDIR; -} - -const char *set_dyn_LIBDIR(const char *newpath) -{ - if (dyn_LIBDIR) { - SAFE_FREE(dyn_LIBDIR); - } - dyn_LIBDIR = SMB_STRDUP(newpath); - return dyn_LIBDIR; -} - -static char *dyn_SHLIBEXT; - -const char *get_dyn_SHLIBEXT(void) -{ - if (dyn_SHLIBEXT == NULL) { - return SHLIBEXT; - } - return dyn_SHLIBEXT; -} - -const char *set_dyn_SHLIBEXT(const char *newpath) -{ - if (dyn_SHLIBEXT) { - SAFE_FREE(dyn_SHLIBEXT); - } - dyn_SHLIBEXT = SMB_STRDUP(newpath); - return dyn_SHLIBEXT; -} - -/** - * @brief Directory holding lock files. - * - * Not writable, but used to set a default in the parameter table. - **/ - -static char *dyn_LOCKDIR; - -const char *get_dyn_LOCKDIR(void) -{ - if (dyn_LOCKDIR == NULL) { - return LOCKDIR; - } - return dyn_LOCKDIR; -} - -const char *set_dyn_LOCKDIR(const char *newpath) -{ - if (dyn_LOCKDIR) { - SAFE_FREE(dyn_LOCKDIR); - } - dyn_LOCKDIR = SMB_STRDUP(newpath); - return dyn_LOCKDIR; -} - -static char *dyn_PIDDIR; - -const char *get_dyn_PIDDIR(void) -{ - if (dyn_PIDDIR == NULL) { - return PIDDIR; - } - return dyn_PIDDIR; -} - -const char *set_dyn_PIDDIR(const char *newpath) -{ - if (dyn_PIDDIR) { - SAFE_FREE(dyn_PIDDIR); - } - dyn_PIDDIR = SMB_STRDUP(newpath); - return dyn_PIDDIR; -} - -static char *dyn_SMB_PASSWD_FILE; - -const char *get_dyn_SMB_PASSWD_FILE(void) -{ - if (dyn_SMB_PASSWD_FILE == NULL) { - return SMB_PASSWD_FILE; - } - return dyn_SMB_PASSWD_FILE; -} - -const char *set_dyn_SMB_PASSWD_FILE(const char *newpath) -{ - if (dyn_SMB_PASSWD_FILE) { - SAFE_FREE(dyn_SMB_PASSWD_FILE); - } - dyn_SMB_PASSWD_FILE = SMB_STRDUP(newpath); - return dyn_SMB_PASSWD_FILE; -} - -static char *dyn_PRIVATE_DIR; - -const char *get_dyn_PRIVATE_DIR(void) -{ - if (dyn_PRIVATE_DIR == NULL) { - return PRIVATE_DIR; - } - return dyn_PRIVATE_DIR; -} - -const char *set_dyn_PRIVATE_DIR(const char *newpath) -{ - if (dyn_PRIVATE_DIR) { - SAFE_FREE(dyn_PRIVATE_DIR); - } - dyn_PRIVATE_DIR = SMB_STRDUP(newpath); - return dyn_PRIVATE_DIR; -} -#endif - /* In non-FHS mode, these should be configurable using 'lock dir ='; but in FHS mode, they are their own directory. Implement as wrapper functions so that everything can still be kept in dynconfig.c. -- cgit From cc83d5b9f114a6ff1a7d6e1f0ed08c2fc35f53a0 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Aug 2008 00:43:31 +0200 Subject: dynconfig: add support for MODULESDIR. Michael (This used to be commit 34309f097f5c7321930bf6c2ea2447de1008130c) --- source3/dynconfig.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/dynconfig.c') diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 241a659a51..3a54507599 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -73,6 +73,7 @@ DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/ DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/ DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR) DEFINE_DYN_CONFIG_PARAM(LIBDIR) +DEFINE_DYN_CONFIG_PARAM(MODULESDIR) DEFINE_DYN_CONFIG_PARAM(SHLIBEXT) DEFINE_DYN_CONFIG_PARAM(LOCKDIR) DEFINE_DYN_CONFIG_PARAM(PIDDIR) -- cgit