Handle hostnames with upper-case letters
[webmin.git] / itsecur-firewall / acl_security.pl
1
2 if (!defined($services_file)) {
3         do 'itsecur-lib.pl';
4         }
5
6 # acl_security_form(&options)
7 # Output HTML for editing security options for the acl module
8 sub acl_security_form
9 {
10 # Work out which features can be edited and which can be read
11 local (@edit, @read);
12 if (defined($_[0]->{'edit'})) {
13         if ($_[0]->{'edit'}) {
14                 @edit = @read = split(/\s+/, $_[0]->{'features'});
15                 }
16         else {
17                 @read = split(/\s+/, $_[0]->{'features'});
18                 }
19         }
20 else {
21         @edit = split(/\s+/, $_[0]->{'features'});
22         @read = split(/\s+/, $_[0]->{'rfeatures'});
23         }
24
25 local $w;
26 foreach $w ([ \@edit, "features", "all" ],
27             [ \@read, "rfeatures", "rall" ]) {
28         local %can = map { $_, 1 } @{$w->[0]};
29         print "<tr> <td valign=top><b>",$text{'acl_'.$w->[1]},
30               "</b></td> <td>\n";
31         printf "<input type=radio name=$w->[2] value=1 %s> %s\n",
32                 $can{"*"} ? "checked" : "", $text{'acl_all'};
33         printf "<input type=radio name=$w->[2] value=0 %s> %s<br>\n",
34                 $can{"*"} ? "" : "checked", $text{'acl_sel'};
35         printf "<select name=$w->[1] multiple size=%d>\n",
36                 scalar(@opts);
37         foreach $o (@opts, 'apply', 'bootup') {
38                 printf "<option value=%s %s>%s\n",
39                         $o, $can{$o} ? "selected" : "",
40                         $text{"acl_".$o} || $text{$o."_title"};
41                 }
42         print "</select></td> </tr>\n";
43         }
44 }
45
46 # acl_security_save(&options)
47 # Parse the form for security options for the acl module
48 sub acl_security_save
49 {
50 $_[0]->{'features'} = $in{'all'} ? "*" :
51                         join(" ", split(/\0/, $in{'features'}));
52 $_[0]->{'rfeatures'} = $in{'rall'} ? "*" :
53                         join(" ", split(/\0/, $in{'rfeatures'}));
54 delete($_[0]->{'edit'});
55 }
56
57 1;
58