Always quote string custom options
authorJamie Cameron <jcameron@webmin.com>
Fri, 27 Mar 2009 20:23:12 +0000 (20:23 +0000)
committerJamie Cameron <jcameron@webmin.com>
Fri, 27 Mar 2009 20:23:12 +0000 (20:23 +0000)
dhcpd/CHANGELOG
dhcpd/save_options.cgi

index 57fd025..6b05064 100644 (file)
@@ -30,3 +30,4 @@ Custom option types defined at a higher level (such as in a subnet) can be used
 When a subnet or host is renamed, the user's ACL is updated to match.
 ---- Changes since 1.470 ----
 Added a Module Config option to specify an alternate file to add new top-level objects (like subnets) to. This must be referenced by an include directive in the main dhcpd.conf though.
+String custom options are now always quoted.
index 06eb30d..3e9efe7 100755 (executable)
@@ -132,11 +132,15 @@ if ($config{'dhcpd_version'} >= 3) {
                       @{$client->{'members'}};
        for($i=0; defined($in{"cname_$i"}); $i++) {
                next if ($in{"cname_$i"} eq "");
+               local $o = $optdef{$in{"cname_$i"}};
                local $cv = $in{"cval_$i"};
                $cv =~ /\S/ || &error(&text('sopt_ecval', $in{"cname_$i"}));
-               $cv = "\"$cv\""
-                       if ($cv !~ /^([0-9a-fA-F]{1,2}:)*[0-9a-fA-F]{1,2}$/ &&
-                           !&check_ipaddress($cv));
+               if ($o && $o->{'values'}->[4] eq 'string' ||
+                   $cv !~ /^([0-9a-fA-F]{1,2}:)*[0-9a-fA-F]{1,2}$/ &&
+                   !&check_ipaddress($cv)) {
+                       # Quote if type is a string, or unknown and not an IP
+                       $cv = "\"$cv\"";
+                       }
                push(@newcustom, { 'name' => 'option',
                                   'values' => [ $in{"cname_$i"}, $cv ] } );
                }