Handle hostnames with upper-case letters
[webmin.git] / custom / acl_security.pl
1
2 require 'custom-lib.pl';
3
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the custom module
6 sub acl_security_form
7 {
8 local $mode = $_[0]->{'cmds'} eq '*' ? 1 :
9               $_[0]->{'cmds'} =~ /^\!/ ? 2 : 0;
10 print "<tr> <td valign=top><b>$text{'acl_cmds'}</b></td> <td>\n";
11 printf "<input type=radio name=cmds_def value=1 %s> %s\n",
12         $mode == 1 ? 'checked' : '', $text{'acl_call'};
13 printf "<input type=radio name=cmds_def value=0 %s> %s\n",
14         $mode == 0 ? 'checked' : '', $text{'acl_csel'};
15 printf "<input type=radio name=cmds_def value=2 %s> %s<br>\n",
16         $mode == 2 ? 'checked' : '', $text{'acl_cexcept'};
17 print "<select name=cmds size=10 multiple width=200>\n";
18 local @cmds = &sort_commands(&list_commands());
19 local ($c, %ccan);
20 map { $ccan{$_}++ } split(/\s+/, $_[0]->{'cmds'});
21 foreach $c (@cmds) {
22         printf "<option value=%s %s> %s\n",
23                 $c->{'id'},
24                 $ccan{$c->{'id'}} ? "selected" : "",
25                 $c->{'desc'};
26         }
27 print "</select></td> </tr>\n";
28
29 print "<tr> <td><b>$text{'acl_edit'}</b></td> <td>\n";
30 printf "<input type=radio name=edit value=1 %s> $text{'yes'}\n",
31         $_[0]->{'edit'} ? "checked" : "";
32 printf "<input type=radio name=edit value=0 %s> $text{'no'}</td> </tr>\n",
33         $_[0]->{'edit'} ? "" : "checked";
34 }
35
36 # acl_security_save(&options)
37 # Parse the form for security options for the custom module
38 sub acl_security_save
39 {
40 if ($in{'cmds_def'} == 1) {
41         $_[0]->{'cmds'} = "*";
42         }
43 elsif ($in{'cmds_def'} == 0) {
44         $_[0]->{'cmds'} = join(" ", split(/\0/, $in{'cmds'}));
45         }
46 else {
47         $_[0]->{'cmds'} = join(" ", "!", split(/\0/, $in{'cmds'}));
48         }
49 $_[0]->{'edit'} = $in{'edit'};
50 }
51