Handle hostnames with upper-case letters
[webmin.git] / proc / acl_security.pl
1
2 require 'proc-lib.pl';
3
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the proc module
6 sub acl_security_form
7 {
8 # Run as user
9 print "<tr> <td><b>$text{'acl_manage'}</b></td> <td colspan=3>\n";
10 local $u = $_[0]->{'uid'} < 0 ? undef : getpwuid($_[0]->{'uid'});
11 printf "<input type=radio name=uid_def value=1 %s> %s\n",
12         $_[0]->{'uid'} < 0 ? 'checked' : '', $text{'acl_manage_def'};
13 printf "<input type=radio name=uid_def value=0 %s>\n",
14         $_[0]->{'uid'} < 0 ? '' : 'checked';
15 print "<input name=uid size=8 value='$u'> ",
16         &user_chooser_button("uid", 0),"</td> </tr>\n";
17
18 # Who can be managed
19 if (!defined($_[0]->{'users'})) {
20         $_[0]->{'users'} = $_[0]->{'uid'} < 0 ? "x" :
21                            $_[0]->{'uid'} == 0 ? "*" : getpwuid($_[0]->{'uid'});
22         }
23 local $who = $_[0]->{'users'} eq "x" ? 1 :
24              $_[0]->{'users'} eq "*" ? 0 : 2;
25 print "<tr> <td valign=top><b>$text{'acl_who'}</b></td> <td colspan=3>\n";
26 print &ui_radio("who", $who,
27                 [ [ 0, $text{'acl_who0'}."<br>\n" ],
28                   [ 1, $text{'acl_who1'}."<br>\n" ],
29                   [ 2, $text{'acl_who2'} ] ])." ".
30                        &ui_textbox("users", $who == 2 ? $_[0]->{'users'} : "",
31                                    40),"</td> </tr>\n";
32
33 # Can do stuff to processes?
34 print "<tr> <td><b>$text{'acl_edit'}</b></td>\n";
35 printf "<td colspan=3><input type=radio name=edit value=1 %s> %s\n",
36         $_[0]->{'edit'} ? 'checked' : '', $text{'yes'};
37 printf "<input type=radio name=edit value=0 %s> %s</td> </tr>\n",
38         $_[0]->{'edit'} ? '' : 'checked', $text{'no'};
39
40 # Can run commands?
41 print "<tr> <td><b>$text{'acl_run'}</b></td>\n";
42 printf "<td colspan=3><input type=radio name=run value=1 %s> %s\n",
43         $_[0]->{'run'} ? 'checked' : '', $text{'yes'};
44 printf "<input type=radio name=run value=0 %s> %s</td> </tr>\n",
45         $_[0]->{'run'} ? '' : 'checked', $text{'no'};
46
47 # Can see other processes?
48 print "<tr> <td><b>$text{'acl_only'}</b></td>\n";
49 printf "<td colspan=3><input type=radio name=only value=1 %s> %s\n",
50         $_[0]->{'only'} ? 'checked' : '', $text{'yes'};
51 printf "<input type=radio name=only value=0 %s> %s</td> </tr>\n",
52         $_[0]->{'only'} ? '' : 'checked', $text{'no'};
53 }
54
55 # acl_security_save(&options)
56 # Parse the form for security options for the proc module
57 sub acl_security_save
58 {
59 $_[0]->{'uid'} = $in{'uid_def'} ? -1 : getpwnam($in{'uid'});
60 $_[0]->{'edit'} = $in{'edit'};
61 $_[0]->{'run'} = $in{'run'};
62 $_[0]->{'only'} = $in{'only'};
63 $_[0]->{'users'} = $in{'who'} == 0 ? "*" :
64                    $in{'who'} == 1 ? "x" : $in{'users'};
65 }
66