make parametic options case insensitive
[kai/samba.git] / source3 / param / loadparm.c
index 5774b22795548191536a504c6244f87fca115eb5..9698feb06097f15693f1e9df740900f6c8427432 100644 (file)
@@ -263,6 +263,7 @@ struct global {
        int ldap_passwd_sync;
        int ldap_replication_sleep;
        int ldap_timeout; /* This is initialised in init_globals */
+       int ldap_connection_timeout;
        int ldap_page_size;
        bool ldap_delete_dn;
        bool bMsAddPrinterWizard;
@@ -3561,6 +3562,15 @@ static struct parm_struct parm_table[] = {
                .enum_list      = NULL,
                .flags          = FLAG_ADVANCED,
        },
+       {
+               .label          = "ldap connection timeout",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .ptr            = &Globals.ldap_connection_timeout,
+               .special        = NULL,
+               .enum_list      = NULL,
+               .flags          = FLAG_ADVANCED,
+       },
        {
                .label          = "ldap page size",
                .type           = P_INTEGER,
@@ -4755,7 +4765,8 @@ static void init_globals(bool first_time_only)
        Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
        Globals.ldap_delete_dn = False;
        Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
-       Globals.ldap_timeout = LDAP_CONNECT_DEFAULT_TIMEOUT;
+       Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
+       Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
        Globals.ldap_page_size = LDAP_PAGE_SIZE;
 
        Globals.ldap_debug_level = 0;
@@ -5074,6 +5085,7 @@ FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
+FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
 FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
@@ -5368,7 +5380,7 @@ static param_opt_struct *get_parametrics(int snum, const char *type, const char
        }
 
        while (data) {
-               if (strcmp(data->key, param_key) == 0) {
+               if (strcasecmp(data->key, param_key) == 0) {
                        string_free(&param_key);
                        return data;
                }
@@ -6516,6 +6528,10 @@ static bool process_registry_service(struct smbconf_service *service)
                return false;
        }
 
+       ret = do_section(service->name, NULL);
+       if (ret != true) {
+               return false;
+       }
        for (count = 0; count < service->num_params; count++) {
                ret = do_parameter(service->param_names[count],
                                   service->param_values[count],
@@ -6542,6 +6558,11 @@ static bool process_registry_globals(void)
                goto done;
        }
 
+       ret = do_parameter("registry shares", "yes", NULL);
+       if (!ret) {
+               goto done;
+       }
+
        if (!smbconf_share_exists(conf_ctx, GLOBAL_NAME)) {
                /* nothing to read from the registry yet but make sure lp_load
                 * doesn't return false */
@@ -6559,7 +6580,45 @@ static bool process_registry_globals(void)
                goto done;
        }
 
-       ret = do_parameter("registry shares", "yes", NULL);
+       /* store the csn */
+       smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
+
+done:
+       TALLOC_FREE(mem_ctx);
+       return ret;
+}
+
+static bool process_registry_shares(void)
+{
+       WERROR werr;
+       uint32_t count;
+       struct smbconf_service **service = NULL;
+       uint32_t num_shares = 0;
+       TALLOC_CTX *mem_ctx = talloc_stackframe();
+       struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
+       bool ret = false;
+
+       if (conf_ctx == NULL) {
+               goto done;
+       }
+
+       werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
+       if (!W_ERROR_IS_OK(werr)) {
+               goto done;
+       }
+
+       ret = true;
+
+       for (count = 0; count < num_shares; count++) {
+               if (strequal(service[count]->name, GLOBAL_NAME)) {
+                       continue;
+               }
+               ret = process_registry_service(service[count]);
+               if (!ret) {
+                       goto done;
+               }
+       }
+
        /* store the csn */
        smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
 
@@ -6784,7 +6843,7 @@ static bool handle_include(int snum, const char *pszParmValue, char **ptr)
 
        DEBUG(2, ("Can't find include file %s\n", fname));
        SAFE_FREE(fname);
-       return false;
+       return true;
 }
 
 /***************************************************************************
@@ -7149,8 +7208,8 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
 
        /* if it is a special case then go ahead */
        if (parm_table[parmnum].special) {
-               parm_table[parmnum].special(snum, pszParmValue, (char **)parm_ptr);
-               return (True);
+               return parm_table[parmnum].special(snum, pszParmValue,
+                                                  (char **)parm_ptr);
        }
 
        /* now switch on the type of variable it is */
@@ -8682,7 +8741,8 @@ bool lp_load_ex(const char *pszFname,
                bool save_defaults,
                bool add_ipc,
                bool initialize_globals,
-               bool allow_include_registry)
+               bool allow_include_registry,
+               bool allow_registry_shares)
 {
        char *n2 = NULL;
        bool bRetval;
@@ -8704,6 +8764,9 @@ bool lp_load_ex(const char *pszFname,
                lp_save_defaults();
        }
 
+       /* We get sections first, so have to start 'behind' to make up */
+       iServiceIndex = -1;
+
        if (Globals.param_opt != NULL) {
                data = Globals.param_opt;
                while (data) {
@@ -8727,8 +8790,6 @@ bool lp_load_ex(const char *pszFname,
 
                add_to_file_list(pszFname, n2);
 
-               /* We get sections first, so have to start 'behind' to make up */
-               iServiceIndex = -1;
                bRetval = pm_process(n2, do_section, do_parameter, NULL);
                SAFE_FREE(n2);
 
@@ -8756,7 +8817,8 @@ bool lp_load_ex(const char *pszFname,
                        lp_kill_all_services();
                        return lp_load_ex(pszFname, global_only, save_defaults,
                                          add_ipc, initialize_globals,
-                                         allow_include_registry);
+                                         allow_include_registry,
+                                         allow_registry_shares);
                }
        } else if (lp_config_backend_is_registry()) {
                bRetval = process_registry_globals();
@@ -8766,6 +8828,10 @@ bool lp_load_ex(const char *pszFname,
                bRetval = false;
        }
 
+       if (bRetval && lp_registry_shares() && allow_registry_shares) {
+               bRetval = process_registry_shares();
+       }
+
        lp_add_auto_services(lp_auto_services());
 
        if (add_ipc) {
@@ -8807,7 +8873,7 @@ bool lp_load(const char *pszFname,
                          save_defaults,
                          add_ipc,
                          initialize_globals,
-                         true);
+                         true, false);
 }
 
 bool lp_load_initial_only(const char *pszFname)
@@ -8817,9 +8883,25 @@ bool lp_load_initial_only(const char *pszFname)
                          false,
                          false,
                          true,
+                         false,
                          false);
 }
 
+bool lp_load_with_registry_shares(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,
+                         true,
+                         true);
+}
+
 /***************************************************************************
  Reset the max number of services.
 ***************************************************************************/