loadparm: make it possible to just load the config without following "include ="...
authorStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2008 08:20:01 +0000 (10:20 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2008 12:43:07 +0000 (14:43 +0200)
metze
(This used to be commit 6b5c76bf1e880ec60d6b044c58115940549049e5)

source3/param/loadparm.c

index 9595ebdb18035af7b28c2eaad2a1c9abd3b32425..84e8c1a2b7af717806136f7f748ffa84e6250b28 100644 (file)
@@ -6727,11 +6727,16 @@ static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **pt
 /***************************************************************************
  Handle the include operation.
 ***************************************************************************/
+static bool bNoIncludes = false;
 
 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
 {
        char *fname;
 
+       if (bNoIncludes) {
+               return true;
+       }
+
        if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
                if (bInGlobalSection) {
                        return process_registry_globals();
@@ -8651,11 +8656,12 @@ bool lp_is_in_client(void)
  False on failure.
 ***************************************************************************/
 
-bool lp_load(const char *pszFname,
-             bool global_only,
-             bool save_defaults,
-            bool add_ipc,
-             bool initialize_globals)
+bool lp_load_ex(const char *pszFname,
+               bool global_only,
+               bool save_defaults,
+               bool add_ipc,
+               bool initialize_globals,
+               bool no_includes)
 {
        char *n2 = NULL;
        bool bRetval;
@@ -8663,10 +8669,11 @@ bool lp_load(const char *pszFname,
 
        bRetval = False;
 
-       DEBUG(3, ("lp_load: refreshing parameters\n"));
+       DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
 
        bInGlobalSection = True;
        bGlobalOnly = global_only;
+       bNoIncludes = no_includes;
 
        init_globals(! initialize_globals);
        debug_init();
@@ -8694,7 +8701,7 @@ bool lp_load(const char *pszFname,
                                        current_user_info.domain,
                                        pszFname);
                if (!n2) {
-                       smb_panic("lp_load: out of memory");
+                       smb_panic("lp_load_ex: out of memory");
                }
 
                add_to_file_list(pszFname, n2);
@@ -8722,12 +8729,12 @@ bool lp_load(const char *pszFname,
                         */
                        config_backend = CONFIG_BACKEND_REGISTRY;
                        /* start over */
-                       DEBUG(1, ("lp_load: changing to config backend "
+                       DEBUG(1, ("lp_load_ex: changing to config backend "
                                  "registry\n"));
                        init_globals(false);
                        lp_kill_all_services();
-                       return lp_load(pszFname, global_only, save_defaults,
-                                      add_ipc, initialize_globals);
+                       return lp_load_ex(pszFname, global_only, save_defaults,
+                                         add_ipc, initialize_globals, no_includes);
                }
        } else if (lp_config_backend_is_registry()) {
                bRetval = process_registry_globals();
@@ -8762,9 +8769,35 @@ bool lp_load(const char *pszFname,
 
        init_iconv();
 
+       bNoIncludes = false;
+
        return (bRetval);
 }
 
+bool lp_load(const char *pszFname,
+            bool global_only,
+            bool save_defaults,
+            bool add_ipc,
+            bool initialize_globals)
+{
+       return lp_load_ex(pszFname,
+                         global_only,
+                         save_defaults,
+                         add_ipc,
+                         initialize_globals,
+                         false);
+}
+
+bool lp_load_initial_only(const char *pszFname)
+{
+       return lp_load_ex(pszFname,
+                         true,
+                         false,
+                         false,
+                         true,
+                         true);
+}
+
 /***************************************************************************
  Reset the max number of services.
 ***************************************************************************/