2 # Save control interface options
4 require './bind8-lib.pl';
5 $access{'defaults'} || &error($text{'controls_ecannot'});
6 &error_setup($text{'controls_err'});
9 # Validate and store inputs
10 &lock_file(&make_chroot($config{'named_conf'}));
11 $parent = &get_config_parent();
12 $conf = &get_config();
13 $controls = &find("controls", $conf);
15 $controls = { 'name' => 'controls', 'type' => 1 };
16 &save_directive($parent, "controls", [ $controls ]);
18 $inet = &find("inet", $controls->{'members'});
19 $unix = &find("unix", $controls->{'members'});
21 # Save inet control options
23 $inet ||= { 'name' => 'inet', 'type' => 2 };
24 &check_ipaddress($in{'ip'}) || &error($text{'controls_einetip'});
25 $in{'port'} =~ /^\d+$/ && $in{'port'} > 0 && $in{'port'} < 65536 ||
26 &error($text{'controls_einetport'});
27 $inet->{'values'} = [ $in{'ip'}, "port", $in{'port'} ];
28 @allow = split(/\s+/, $in{'allow'});
30 &check_ipaddress($a) ||
31 &error(&text('controls_einetallow', $a));
33 @allow || &error($text{'controls_einetallows'});
34 $inet->{'members'}->{'allow'} =
35 [ map { { 'name' => $_ } } @allow ];
36 @keys = split(/\s+/, $in{'keys'});
38 $inet->{'members'}->{'keys'} =
39 [ map { { 'name' => $_ } } @keys ];
42 delete($inet->{'members'}->{'keys'});
44 &save_directive($controls, "inet", [ $inet ], 1);
47 &save_directive($controls, "inet", [ ], 1);
50 # Save local control options
52 $unix ||= { 'name' => 'unix', 'type' => 0 };
53 $in{'path'} =~ /^\/\S+$/ || &error($text{'controls_eunixpath'});
54 $in{'perm'} =~ /^[0-7]{3,4}$/ || &error($text{'controls_eunixperm'});
55 $owner = getpwnam($in{'owner'});
56 defined($owner) || &error($text{'controls_eunixowner'});
57 $group = getgrnam($in{'group'});
58 defined($group) || &error($text{'controls_eunixgroup'});
59 $unix->{'values'} = [ $in{'path'}, "perm", $in{'perm'},
60 "owner", $owner, "group", $group ];
61 &save_directive($controls, "unix", [ $unix ], 1);
64 &save_directive($controls, "unix", [ ], 1);
68 &unlock_file(&make_chroot($config{'named_conf'}));
69 &webmin_log("controls", undef, undef, \%in);