Always save some global options
authorJamie Cameron <jcameron@webmin.com>
Fri, 6 May 2011 04:37:33 +0000 (21:37 -0700)
committerJamie Cameron <jcameron@webmin.com>
Fri, 6 May 2011 04:37:33 +0000 (21:37 -0700)
postfix/postfix-lib.pl
postfix/save_opts_misc.cgi

index b74570c..9b868da 100755 (executable)
@@ -171,8 +171,8 @@ sub get_default_value
 sub set_current_value
 {
     my $value = $_[1];
-#    print "--".$value."--<br>";
-    if (($value eq "__DEFAULT_VALUE_IE_NOT_IN_CONFIG_FILE__" || $value eq &get_default_value($_[0])) && !$_[2])
+    if ($value eq "__DEFAULT_VALUE_IE_NOT_IN_CONFIG_FILE__" ||
+       $value eq &get_default_value($_[0]) && !$_[2])
     {
        # there is a special case in which there is no static default value ;
        # postfix will handle it correctly if I remove the line in `main.cf'
@@ -204,10 +204,13 @@ sub set_current_value
     }
     else
     {
-       $value =~ s/\$/\\\$/g;     # prepend a \ in front of every $ to protect from shell substitution
         local ($out, $ex);
-       $ex = &execute_command("$config{'postfix_config_command'} -c $config_dir -e $_[0]=\"$value\"", undef, \$out, \$out);
-       $ex && &error(&text('query_set_efailed', $_[0], $_[1], $out)."<br> $config{'postfix_config_command'} -c $config_dir -e $_[0]=\"$value\" 2>&1");
+       $ex = &execute_command(
+               "$config{'postfix_config_command'} -c $config_dir ".
+               "-e $_[0]=".quotemeta($value), undef, \$out, \$out);
+       $ex && &error(&text('query_set_efailed', $_[0], $_[1], $out).
+                     "<br> $config{'postfix_config_command'} -c $config_dir ".
+                    "-e $_[0]=\"$value\" 2>&1");
         &unflush_file_lines($config{'postfix_config_file'}); # Invalidate cache
     }
 }
@@ -538,7 +541,7 @@ foreach $e (@{$_[0]}) {
        }
 }
 
-# save_options(%options)
+# save_options(%options, [&always-save])
 #
 sub save_options
 {
@@ -560,7 +563,8 @@ sub save_options
                   }
                }
             }
-           &set_current_value($param, $value);
+           &set_current_value($param, $value,
+                              &indexof($param, @{$_[1]}) >= 0);
        }
     }
 }
index 06d09c6..5fbcb47 100755 (executable)
@@ -19,7 +19,7 @@ require './postfix-lib.pl';
 
 &lock_postfix_files();
 &before_save();
-&save_options(\%in);
+&save_options(\%in, [ "myhostname", "mydomain" ]);
 &ensure_map("relocated_maps");
 &after_save();
 &unlock_postfix_files();