s3-param Fix up lp_set_cmdline() not to re-store cmdline options on each reload
authorAndrew Bartlett <abartlet@samba.org>
Tue, 2 Nov 2010 04:33:42 +0000 (15:33 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 2 Nov 2010 05:19:17 +0000 (05:19 +0000)
The previous code was buggy in that it did not honour the 'store'
argument to lp_set_cmdline_helper(), and would use the stored
parameter after freeing it when handling overwritten values.

Andrew Bartlett

Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Tue Nov  2 05:19:17 UTC 2010 on sn-devel-104

source3/param/loadparm.c

index 8dadebfa8915d97e040e230af84decde299fc5b7..1d3c7353ed75ac9958ad24030ec672dabc13f99f 100644 (file)
@@ -4983,8 +4983,9 @@ static struct lp_stored_option *stored_options;
  */
 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
 {
-       struct lp_stored_option *entry = NULL;
-       for (entry = stored_options; entry != NULL; entry = entry->next) {
+       struct lp_stored_option *entry, *entry_next;
+       for (entry = stored_options; entry != NULL; entry = entry_next) {
+               entry_next = entry->next;
                if (strcmp(pszParmName, entry->label) == 0) {
                        DLIST_REMOVE(stored_options, entry);
                        talloc_free(entry);
@@ -7887,14 +7888,18 @@ static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmVa
                }
                parm_table[parmnum].flags |= FLAG_CMDLINE;
 
-               store_lp_set_cmdline(pszParmName, pszParmValue);
+               if (store_values) {
+                       store_lp_set_cmdline(pszParmName, pszParmValue);
+               }
                return true;
        }
 
        /* it might be parametric */
        if (strchr(pszParmName, ':') != NULL) {
                set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
-               store_lp_set_cmdline(pszParmName, pszParmValue);
+               if (store_values) {
+                       store_lp_set_cmdline(pszParmName, pszParmValue);
+               }
                return true;
        }