Handle hostnames with upper-case letters
[webmin.git] / webminlog / acl_security.pl
1
2 do 'webminlog-lib.pl';
3 &foreign_require("acl", "acl-lib.pl");
4
5 # acl_security_form(&options)
6 # Output HTML for editing security options for the acl module
7 sub acl_security_form
8 {
9 # Allowed modules
10 print "<tr> <td valign=top><b>$text{'acl_mods'}</b></td> <td>\n";
11 printf "<input type=radio name=mods_def value=1 %s> %s\n",
12         $_[0]->{'mods'} eq "*" ? "checked" : "", $text{'acl_all'};
13 printf "<input type=radio name=mods_def value=0 %s> %s<br>\n",
14         $_[0]->{'mods'} eq "*" ? "" : "checked", $text{'acl_sel'};
15 local %gotmod = map { $_, 1 } split(/\s+/, $_[0]->{'mods'});
16 print "<select name=mods multiple size=10 width=400>\n";
17 my $m;
18 foreach $m (sort { $a->{'desc'} cmp $b->{'desc'} } &get_all_module_infos()) {
19         printf "<option value=%s %s>%s\n",
20                 $m->{'dir'}, $gotmod{$m->{'dir'}} ? "selected" : "",
21                 $m->{'desc'};
22         }
23 print "</select></td> </tr>\n";
24
25 # Allowed users
26 print "<tr> <td valign=top><b>$text{'acl_users'}</b></td> <td>\n";
27 printf "<input type=radio name=users_def value=1 %s> %s\n",
28         $_[0]->{'users'} eq "*" ? "checked" : "", $text{'acl_all'};
29 printf "<input type=radio name=users_def value=0 %s> %s<br>\n",
30         $_[0]->{'users'} eq "*" ? "" : "checked", $text{'acl_sel'};
31 local %gotuser = map { $_, 1 } split(/\s+/, $_[0]->{'users'});
32 print "<select name=users multiple size=10 width=400>\n";
33 my $u;
34 foreach $u (sort { $a->{'name'} cmp $b->{'name'} } &acl::list_users()) {
35         printf "<option value=%s %s>%s\n",
36                 $u->{'name'}, $gotuser{$u->{'name'}} ? "selected" : "",
37                 $u->{'name'};
38         }
39 print "</select></td> </tr>\n";
40
41 # Rollback
42 print "<tr> <td><b>$text{'acl_rollback'}</b></td>\n";
43 print "<td>",&ui_radio("rollback", $_[0]->{'rollback'},
44                 [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]),"</td> </tr>\n";
45 }
46
47 # acl_security_save(&options)
48 # Parse the form for security options for the acl module
49 sub acl_security_save
50 {
51 $_[0]->{'mods'} = $in{'mods_def'} ? "*" : join(" ", split(/\0/, $in{'mods'}));
52 $_[0]->{'users'} = $in{'users_def'} ? "*" : join(" ", split(/\0/,$in{'users'}));
53 $_[0]->{'rollback'} = $in{'rollback'};
54 }
55