forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_slave.cgi
executable file
·36 lines (32 loc) · 1.17 KB
/
save_slave.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
#!/usr/local/bin/perl
# save_slave.cgi
# Save changes to slave zone options in named.boot
require './dns-lib.pl';
&ReadParse();
&lock_file($config{'named_boot_file'});
$zconf = &get_config()->[$in{'index'}];
$whatfailed = "Failed to save slave zone";
%access = &get_module_acl();
&can_edit_zone(\%access, $zconf->{'values'}->[0]) ||
&error("You are not allowed to edit this zone");
@mast = split(/\s+/, $in{'masters'});
foreach $m (@mast) {
&check_ipaddress($m) ||
&error("'$m' is not a valid master server IP address");
}
if (!@mast) { &error("You must enter at least one master server address"); }
$in{'file_def'} || $in{'file'} =~ /^\S+$/ ||
&error("'$in{'file'}' is not a valid records filename");
push(@vals, $zconf->{'values'}->[0]);
push(@vals, @mast);
if (!$in{'file_def'}) {
$file = $in{'file'};
$file = &base_directory($conf)."/".$file if ($file !~ /^\//);
&allowed_zone_file(\%access, $file) ||
&error("'$in{'file'}' is not an allowable records file");
push(@vals, $in{'file'});
}
&modify_zone($zconf, { 'name' => 'secondary', 'values' => \@vals });
&unlock_file($config{'named_boot_file'});
&webmin_log("opts", undef, $zconf->{'values'}->[0], \%in);
&redirect("");