Option types inherit down
authorJamie Cameron <jcameron@webmin.com>
Tue, 21 Oct 2008 06:46:19 +0000 (06:46 +0000)
committerJamie Cameron <jcameron@webmin.com>
Tue, 21 Oct 2008 06:46:19 +0000 (06:46 +0000)
dhcpd/CHANGELOG
dhcpd/edit_options.cgi

index 9b158d6..ab06424 100644 (file)
@@ -25,3 +25,4 @@ Clashes between hosts with the same IP address, MAC address or hostname are no l
 Support the new configuration file format for custom options, as used in DHCPd version 3.
 ---- Changes since 1.430 ----
 Fixed bug that can cause option definitions and values to be incorrectly ordered.
+Custom option types defined at a higher level (such as in a subnet) can be used in the Edit Options page at lower levels (such as in a host).
index d9aeb48..4fc6778 100755 (executable)
@@ -11,8 +11,10 @@ $conf = &get_config();
 &error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
 
 $client = &get_parent_config();
+push(@parents, $client);
 foreach $i ($in{'sidx'}, $in{'uidx'}, $in{'gidx'}, $in{'idx'}) {
        $client = $client->{'members'}->[$i] if ($i ne '');
+       push(@parents, $client);
        }
 
 if ($client->{'name'} eq 'subnet') {
@@ -134,7 +136,6 @@ if ($config{'dhcpd_version'} >= 3) {
        @defs = grep { $_->{'values'}->[1] eq 'code' &&
                       $_->{'values'}->[3] eq '=' } @opts;
        push(@defs, undef);
-       %optdef = ( );
        for($i=0; $i<@defs; $i++) {
                $o = $defs[$i];
                print "<tr>\n";
@@ -149,7 +150,18 @@ if ($config{'dhcpd_version'} >= 3) {
                printf "<input name=dtype_$i size=10 value='%s'>\n",
                        $o->{'values'}->[4];
                print "</td> </tr>\n";
-               $optdef{$o->{'values'}->[0]} = $o if ($o->{'values'}->[0]);
+               }
+
+       # Find option definitions at higher levels
+       %optdef = ( );
+       foreach $p (@parents) {
+               @popts = &find("option", $p->{'members'});
+               @pdefs = grep { $_->{'values'}->[1] eq 'code' &&
+                               $_->{'values'}->[3] eq '=' } @popts;
+               foreach $o (@pdefs) {
+                       $optdef{$o->{'values'}->[0]} = $o
+                               if ($o->{'values'}->[0]);
+                       }
                }
 
        # Show values for custom options