Added the "reverse lookup" daemon-config parameter.
[rsync/rsync.git] / loadparm.c
index 2af7b8d..b3197a8 100644 (file)
@@ -17,7 +17,7 @@
  * and Karl Auer.  Some of the changes are:
  *
  * Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
- * Copyright (C) 2003-2008 Wayne Davison <wayned@samba.org>
+ * Copyright (C) 2003-2009 Wayne Davison <wayned@samba.org>
  */
 
 /* Load parameters.
  */
 
 #include "rsync.h"
-#include "ifuncs.h"
+#include "itypes.h"
+
+extern item_list dparam_list;
+
 #define strequal(a, b) (strcasecmp(a, b)==0)
 #define BOOLSTR(b) ((b) ? "Yes" : "No")
 
@@ -146,6 +149,7 @@ typedef struct {
        BOOL munge_symlinks;
        BOOL numeric_ids;
        BOOL read_only;
+       BOOL reverse_lookup;
        BOOL strict_modes;
        BOOL transfer_logging;
        BOOL use_chroot;
@@ -200,6 +204,7 @@ static section sDefault = {
  /* munge_symlinks; */         (BOOL)-1,
  /* numeric_ids; */            (BOOL)-1,
  /* read_only; */              True,
+ /* reverse_lookup; */         True,
  /* strict_modes; */           True,
  /* transfer_logging; */       False,
  /* use_chroot; */             True,
@@ -324,6 +329,7 @@ static struct parm_struct parm_table[] =
 #endif
  {"read only",         P_BOOL,   P_LOCAL, &sDefault.read_only,         NULL,0},
  {"refuse options",    P_STRING, P_LOCAL, &sDefault.refuse_options,    NULL,0},
+ {"reverse lookup",    P_BOOL,   P_LOCAL, &sDefault.reverse_lookup,    NULL,0},
  {"secrets file",      P_STRING, P_LOCAL, &sDefault.secrets_file,      NULL,0},
  {"strict modes",      P_BOOL,   P_LOCAL, &sDefault.strict_modes,      NULL,0},
  {"syslog facility",   P_ENUM,   P_LOCAL, &sDefault.syslog_facility,enum_facilities,0},
@@ -414,6 +420,7 @@ FN_LOCAL_BOOL(lp_list, list)
 FN_LOCAL_BOOL(lp_munge_symlinks, munge_symlinks)
 FN_LOCAL_BOOL(lp_numeric_ids, numeric_ids)
 FN_LOCAL_BOOL(lp_read_only, read_only)
+FN_LOCAL_BOOL(lp_reverse_lookup, reverse_lookup)
 FN_LOCAL_BOOL(lp_strict_modes, strict_modes)
 FN_LOCAL_BOOL(lp_transfer_logging, transfer_logging)
 FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
@@ -699,8 +706,11 @@ static BOOL do_section(char *sectionname)
        isglobal = strwicmp(sectionname, GLOBAL_NAME) == 0;
 
        /* if we were in a global section then do the local inits */
-       if (bInGlobalSection && !isglobal)
+       if (bInGlobalSection && !isglobal) {
+               if (!section_list.count)
+                       set_dparams(0);
                init_locals();
+       }
 
        /* if we've just struck a global section, note the fact. */
        bInGlobalSection = isglobal;
@@ -745,6 +755,30 @@ int lp_load(char *pszFname, int globals_only)
        return pm_process(pszFname, globals_only ? NULL : do_section, do_parameter);
 }
 
+BOOL set_dparams(int syntax_check_only)
+{
+       char *equal, *val, **params = dparam_list.items;
+       unsigned j;
+
+       for (j = 0; j < dparam_list.count; j++) {
+               equal = strchr(params[j], '='); /* options.c verified this */
+               *equal = '\0';
+               if (syntax_check_only) {
+                       if (map_parameter(params[j]) < 0) {
+                               rprintf(FERROR, "Unknown parameter \"%s\"\n", params[j]);
+                               *equal = '=';
+                               return False;
+                       }
+               } else {
+                       for (val = equal+1; isSpace(val); val++) {}
+                       do_parameter(params[j], val);
+               }
+               *equal = '=';
+       }
+
+       return True;
+}
+
 /* Return the max number of modules (sections). */
 int lp_num_modules(void)
 {