Handle hostnames with upper-case letters
[webmin.git] / acl / edit_unix.cgi
1 #!/usr/local/bin/perl
2 # edit_unix.cgi
3 # Choose a user whose permissions will be used for logins that don't
4 # match any webmin user, but have unix accounts
5
6 require './acl-lib.pl';
7 $access{'unix'} && $access{'create'} && $access{'delete'} ||
8         &error($text{'unix_ecannot'});
9 &ui_print_header(undef, $text{'unix_title'}, "");
10
11 print "$text{'unix_desc'}<p>\n";
12 &get_miniserv_config(\%miniserv);
13
14 print "<form action=save_unix.cgi>\n";
15 print "<table>\n";
16
17 # Enable Unix auth
18 @unixauth = &get_unixauth(\%miniserv);
19 print "<tr> <td colspan=2>\n";
20 print &ui_radio("unix_def", @unixauth ? 0 : 1,
21         [ [ 1, $text{'unix_def'} ], [ 0, $text{'unix_sel'} ] ]),"<br>\n";
22 print &ui_columns_start([ $text{'unix_mode'}, $text{'unix_who'},
23                           $text{'unix_to'} ]);
24 $i = 0;
25 @webmins = map { [ $_->{'name'} ] }
26                sort { $a->{'name'} cmp $b->{'name'} } &list_users();
27 foreach $ua (@unixauth, [ ], [ ]) {
28         print &ui_columns_row([
29                 &ui_select("mode_$i", $ua->[0] eq "" ? 0 :
30                                       $ua->[0] eq "*" ? 1 :
31                                       $ua->[0] =~ /^\@/ ? 2 : 3,
32                            [ [ 0, " " ],
33                              [ 1, $text{'unix_mall'} ],
34                              [ 2, $text{'unix_group'} ],
35                              [ 3, $text{'unix_user'} ] ]),
36                 &ui_textbox("who_$i", $ua->[0] eq "*" || $ua->[0] eq "" ? "" :
37                               $ua->[0] =~ /^\@(.*)$/ ? $1 : $ua->[0], 20),
38                 &ui_select("to_$i", $ua->[1], \@webmins),
39                 ]);
40         $i++;
41         }
42 print &ui_columns_end(),"\n";
43
44 # Allow users who can sudo to root?
45 print &ui_checkbox("sudo", 1, $text{'unix_sudo'},
46                    $miniserv{'sudo'}),"<br>\n";
47
48 # Allow PAM-only users?
49 print &ui_checkbox("pamany", 1, &text('unix_pamany',
50                                       &ui_select("pamany_user",
51                                                  $miniserv{'pamany'}, 
52                                                  \@webmins)),
53                    $miniserv{'pamany'}),"<br>\n";
54 print "</td> </tr>\n";
55
56 print "<tr> <td colspan=2><hr></td> </tr>\n";
57 print "<tr> <td colspan=2>$text{'unix_restrict'}<p></td> </tr>\n";
58
59 # Who can do Unix auth?
60 print "<tr> <td valign=top>\n";
61 printf "<input type=radio name=access value=0 %s>\n",
62         $miniserv{"allowusers"} || $miniserv{"denyusers"} ? "" : "checked";
63 print "$text{'unix_all'}<br>\n";
64 printf "<input type=radio name=access value=1 %s>\n",
65         $miniserv{"allowusers"} ? "checked" : "";
66 print "$text{'unix_allow'}<br>\n";
67 printf "<input type=radio name=access value=2 %s>\n",
68         $miniserv{"denyusers"} ? "checked" : "";
69 print "$text{'unix_deny'}<br>\n";
70 print "</td> <td valign=top>\n";
71 printf "<textarea name=users rows=6 cols=30>%s</textarea></td> </tr>\n",
72  $miniserv{"allowusers"} ? join("\n", split(/\s+/, $miniserv{"allowusers"})) :
73  $miniserv{"denyusers"} ? join("\n", split(/\s+/, $miniserv{"denyusers"})) : "";
74
75 # Block login by shell?
76 print "<tr> <td colspan=2>\n";
77 printf "<input type=checkbox name=shells_deny value=1 %s> %s\n",
78         $miniserv{'shells_deny'} ? "checked" : "",$text{'unix_shells'};
79 printf "<input name=shells size=25 value='%s'> %s</td> </tr>\n",
80         $miniserv{'shells_deny'} || "/etc/shells",
81         &file_chooser_button("shells");
82
83 print "</table>\n";
84 print "<input type=submit value='$text{'save'}'></form>\n";
85
86 &ui_print_footer("", $text{'index_return'});
87