forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_subnets.cgi
executable file
·59 lines (53 loc) · 1.62 KB
/
delete_subnets.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/local/bin/perl
# Delete one or more subnets or shared networks
require './dhcpd-lib.pl';
require './params-lib.pl';
&ReadParse();
&error_setup($text{'sdelete_err'});
@d = split(/\0/, $in{'d'});
@d || &error($text{'sdelete_enone'});
%access = &get_module_acl();
# Work out what is being done
&lock_file($config{'dhcpd_conf'});
$parent = &get_parent_config();
foreach $d (@d) {
local ($idx, $pidx) = split(/\//, $d);
local $par = $parent;
if ($pidx ne "") {
# Under a shared network
$par = $par->{'members'}->[$pidx];
}
$del = $par->{'members'}->[$idx];
&error("$text{'eacl_np'} $text{'eacl_pds'}")
if !&can('rw', \%access, $del, 1);
next if ($already{$par}); # don't delete subnet if parent is being
push(@deleting, [ $par, $del ]);
$already{$del}++;
$subnet_count++ if ($del->{'name'} eq 'subnet');
$shared_count++ if ($del->{'name'} eq 'shared-network');
}
if ($in{'confirm'}) {
# Do it!
foreach $pardel (@deleting) {
&save_directive($pardel->[0], [ $pardel->[1] ], [ ], 0);
}
&flush_file_lines();
&unlock_file($config{'dhcpd_conf'});
&webmin_log("delete", "subnets", scalar(@d));
&redirect("");
}
else {
# Ask first
&ui_print_header(undef, $text{'sdelete_title'}, "");
print "<center>\n";
print &ui_form_start("delete_subnets.cgi", "post");
foreach $d (@d) {
print &ui_hidden("d", $d),"\n";
}
$msg = $subnet_count && $shared_count ? 'sdelete_rusure1' :
$subnet_count ? 'sdelete_rusure2' : 'sdelete_rusure3';
print &text($msg, $subnet_count, $shared_count),"<p>\n";
print &ui_form_end([ [ "confirm", $text{'sdelete_ok'} ] ]);
print "</center>\n";
&ui_print_footer("", $text{'index_return'});
}