Update ACLs when renaming hosts or subnets
authorJamie Cameron <jcameron@webmin.com>
Wed, 14 Jan 2009 23:43:49 +0000 (23:43 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 14 Jan 2009 23:43:49 +0000 (23:43 +0000)
dhcpd/CHANGELOG
dhcpd/save_host.cgi
dhcpd/save_subnet.cgi

index ab06424..5ae96d0 100644 (file)
@@ -26,3 +26,5 @@ Support the new configuration file format for custom options, as used in DHCPd v
 ---- 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).
+---- Changes since 1.440 ----
+When a subnet or host is renamed, the user's ACL is updated to match.
index 4ed9200..fc10238 100755 (executable)
@@ -29,6 +29,7 @@ else {
        &error("$text{'eacl_np'} $text{'eacl_puh'}")
                unless &can('rw', \%access, $host) &&
                        (!$npar || &can('rw', \%access, $npar));
+       $oldname = $host->{'values'}->[0];
        }
 
 # save
@@ -139,6 +140,10 @@ else {
        elsif ($par eq $npar) {
                # Update host
                &save_directive($par, [ $host ], [ $host ], $indent);
+               if ($oldname ne $in{'name'}) {
+                       &drop_dhcpd_acl('hst', \%access, $oldname);
+                       &save_dhcpd_acl('rw', 'hst', \%access, $in{'name'});
+                       }
                }
        else {
                # Move this host
index 75b4d6f..2dd9db0 100755 (executable)
@@ -67,6 +67,7 @@ else {
                        &error("'$in{'network'}' $text{'ssub_invalidsubaddr'}");
                &check_ipaddress($in{'netmask'}) ||
                        &error("'$in{'netmask'}' $text{'ssub_invalidnmask'}");
+               $oldnetwork = $sub->{'values'}->[0];
                $sub->{'values'} = [ $in{'network'}, "netmask", $in{'netmask'} ];
                }
 
@@ -177,8 +178,14 @@ else {
                        &save_directive($npar, [ ], [ $sub ], $nindent);
                        }
                elsif ($par eq $npar) {
-                       # Update the subnet
+                       # Update the subnet in the current parent
                        &save_directive($par, [ $sub ], [ $sub ], $nindent);
+                       if ($in{'network'} ne $oldnetwork) {
+                               # Fix the ACL
+                               &drop_dhcpd_acl('sub', \%access, $oldnetwork);
+                               &save_dhcpd_acl('rw','sub',\%access,
+                                               $in{'network'});
+                               }
                        }
                else {
                        # Move the subnet