aboutsummaryrefslogtreecommitdiffstats
path: root/loadparm.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2009-01-18 22:40:58 -0800
committerWayne Davison <wayned@samba.org>2009-01-18 22:42:41 -0800
commit243e9a366db34f488325e94af1939eeac19f56da (patch)
tree15360741201bbce2c39ce2964c0264c415b5e8dd /loadparm.c
parentb53c202e450445070368c32b9d97ae8b179ba66f (diff)
downloadandroid_external_rsync-243e9a366db34f488325e94af1939eeac19f56da.tar.gz
android_external_rsync-243e9a366db34f488325e94af1939eeac19f56da.tar.bz2
android_external_rsync-243e9a366db34f488325e94af1939eeac19f56da.zip
Added a "Defaults" structure with both globals and locals in it.
Initialize both the Globals and Locals back to their default values when reading the config. This fixes a bug where locals set in the global section were not getting reset to their default value if the config item was removed from the file.
Diffstat (limited to 'loadparm.c')
-rw-r--r--loadparm.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/loadparm.c b/loadparm.c
index b473ce90..2a9d8b4c 100644
--- a/loadparm.c
+++ b/loadparm.c
@@ -31,8 +31,7 @@
* 1) add it to the global_vars or local_vars structure definition
* 2) add it to the parm_table
* 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
- * 4) If it's a global then initialise it in init_globals. If a local module
- * (ie. section) parameter then initialise it in the Locals structure
+ * 4) initialise it in the Defaults static stucture
*
* Notes:
* The configuration file is processed sequentially for speed. For this
@@ -155,16 +154,30 @@ typedef struct {
BOOL write_only;
} local_vars;
+static local_vars Locals;
+
typedef struct {
global_vars g;
local_vars l;
} all_vars;
-/* This is a default section used to prime a sections structure. In order
+/* This is used to reset all values before a config read. In order
* to make these easy to keep sorted in the same way as the variables
* above, use the variable name in the leading comment, including a
* trailing ';' (to avoid a sorting problem with trailing digits). */
-static local_vars Locals = {
+static const all_vars Defaults = {
+ /* ==== global_vars ==== */
+ {
+ /* bind_address; */ NULL,
+ /* motd_file; */ NULL,
+ /* pid_file; */ NULL,
+ /* socket_options; */ NULL,
+
+ /* rsync_port; */ 0,
+ },
+
+ /* ==== local_vars ==== */
+ {
/* auth_users; */ NULL,
/* charset; */ NULL,
/* comment; */ NULL,
@@ -208,6 +221,7 @@ static local_vars Locals = {
/* transfer_logging; */ False,
/* use_chroot; */ True,
/* write_only; */ False,
+ }
};
/* local variables */
@@ -339,16 +353,11 @@ static struct parm_struct parm_table[] =
{NULL, P_BOOL, P_NONE, NULL, NULL,0}
};
-/* Initialise the global parameter structure. */
-static void init_globals(void)
-{
- memset(&Globals, 0, sizeof Globals);
-}
-
-/* Initialise the Locals parameter structure. */
-static void init_locals(void)
+/* Initialise the Default all_vars structure. */
+static void reset_all_vars(void)
{
- /* Nothing needed yet... */
+ memcpy(&Globals, &Defaults.g, sizeof Globals);
+ memcpy(&Locals, &Defaults.l, sizeof Locals);
}
/* In this section all the functions that are used to access the
@@ -699,11 +708,10 @@ static BOOL do_section(char *sectionname)
isglobal = strwicmp(sectionname, GLOBAL_NAME) == 0;
- /* if we were in a global section then do the local inits */
+ /* At the end of the global section, add any --dparam items. */
if (bInGlobalSection && !isglobal) {
if (!section_list.count)
set_dparams(0);
- init_locals();
}
/* if we've just struck a global section, note the fact. */
@@ -742,7 +750,7 @@ int lp_load(char *pszFname, int globals_only)
{
bInGlobalSection = True;
- init_globals();
+ reset_all_vars();
/* We get sections first, so have to start 'behind' to make up. */
iSectionIndex = -1;