Handle hostnames with upper-case letters
[webmin.git] / dnsadmin / acl_security.pl
1
2 require 'dns-lib.pl';
3
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the dnsadmin module
6 sub acl_security_form
7 {
8 print "<tr> <td valign=top rowspan=5><b>Domains this user can edit</b></td>\n";
9 print "<td rowspan=5 valign=top>\n";
10 printf "<input type=radio name=zones_def value=1 %s> %s\n",
11         $_[0]->{'zones'} eq '*' ? 'checked' : '', "All zones";
12 printf "<input type=radio name=zones_def value=0 %s> %s<br>\n",
13         $_[0]->{'zones'} eq '*' ? '' : 'checked', "Selected..";
14 print "<select name=zones multiple size=5>\n";
15 local $conf = &get_config();
16 local @zones = ( &find_config("primary", $conf),
17                  &find_config("secondary", $conf) );
18 local ($z, %zcan);
19 map { $zcan{$_}++ } split(/\s+/, $_[0]->{'zones'});
20 foreach $z (sort { $a->{'value'} cmp $b->{'value'} } @zones) {
21         local $v = $z->{'values'}->[0];
22         printf "<option value='%s' %s>%s\n",
23                 $v, $zcan{$v} ? "selected" : "",
24                 &arpa_to_ip($v);
25         }
26 print "</select></td>\n";
27
28 print "<td><b>Can create master zones?</b></td> <td>\n";
29 printf "<input type=radio name=master value=1 %s> Yes\n",
30         $_[0]->{'master'} ? "checked" : "";
31 printf "<input type=radio name=master value=0 %s> No</td> </tr>\n",
32         $_[0]->{'master'} ? "" : "checked";
33
34 print "<tr> <td><b>Can create slave zones?</b></td> <td>\n";
35 printf "<input type=radio name=slave value=1 %s> Yes\n",
36         $_[0]->{'slave'} ? "checked" : "";
37 printf "<input type=radio name=slave value=0 %s> No</td> </tr>\n",
38         $_[0]->{'slave'} ? "" : "checked";
39
40 print "<tr> <td><b>Can edit master zone defaults?</b></td> <td>\n";
41 printf "<input type=radio name=defaults value=1 %s> Yes\n",
42         $_[0]->{'defaults'} ? "checked" : "";
43 printf "<input type=radio name=defaults value=0 %s> No</td> </tr>\n",
44         $_[0]->{'defaults'} ? "" : "checked";
45
46 print "<tr> <td><b>Can update reverse addresses in any domain?</b></td> <td>\n";
47 printf "<input type=radio name=reverse value=1 %s> Yes\n",
48         $_[0]->{'reverse'} ? "checked" : "";
49 printf "<input type=radio name=reverse value=0 %s> No</td> </tr>\n",
50         $_[0]->{'reverse'} ? "" : "checked";
51
52 print "<tr> <td><b>Can multiple addresses have the same IP?</b></td> <td>\n";
53 printf "<input type=radio name=multiple value=1 %s> Yes\n",
54         $_[0]->{'multiple'} ? "checked" : "";
55 printf "<input type=radio name=multiple value=0 %s> No</td> </tr>\n",
56         $_[0]->{'multiple'} ? "" : "checked";
57
58 print "<tr> <td><b>Restrict zone files to directory</b></td>\n";
59 printf "<td colspan=3><input name=dir size=30 value='%s'> %s</td> </tr>\n",
60         $_[0]->{'dir'}, &file_chooser_button("dir", 1);
61 }
62
63 # acl_security_save(&options)
64 # Parse the form for security options for the dnsadmin module
65 sub acl_security_save
66 {
67 if ($in{'zones_def'}) {
68         $_[0]->{'zones'} = "*";
69         }
70 else {
71         $_[0]->{'zones'} = join(" ", split(/\0/, $in{'zones'}));
72         }
73 $_[0]->{'master'} = $in{'master'};
74 $_[0]->{'slave'} = $in{'slave'};
75 $_[0]->{'defaults'} = $in{'defaults'};
76 $_[0]->{'reverse'} = $in{'reverse'};
77 $_[0]->{'multiple'} = $in{'multiple'};
78 $_[0]->{'dir'} = $in{'dir'};
79 }
80