Handle hostnames with upper-case letters
[webmin.git] / itsecur-firewall / edit_user.cgi
1 #!/usr/bin/perl
2 # edit_user.cgi
3 # Show one Webmin user
4
5 require './itsecur-lib.pl';
6 &foreign_require("acl", "acl-lib.pl");
7 &can_use_error("users");
8 @users = &acl::list_users();
9 &ReadParse();
10
11 if ($in{'new'}) {
12         &header($text{'user_title1'}, "",
13                 undef, undef, undef, undef, &apply_button());
14         %gotmods = ( $module_name, 1 );
15         }
16 else {
17         &header($text{'user_title2'}, "",
18                 undef, undef, undef, undef, &apply_button());
19         ($user) = grep { $_->{'name'} eq $in{'name'} } @users;
20         %gotmods = map { $_, 1 } @{$user->{'modules'}};
21         }
22 print "<hr>\n";
23
24 print "<form action=save_user.cgi>\n";
25 print "<input type=hidden name=new value='$in{'new'}'>\n";
26 print "<input type=hidden name=old value='$in{'name'}'>\n";
27 print "<table border>\n";
28 print "<tr $tb> <td><b>$text{'user_header'}</b></td> </tr>\n";
29 print "<tr $cb> <td><table>\n";
30
31 # Show username
32 print "<tr> <td nowrap><b>$text{'user_name'}</b></td> <td>\n";
33 printf "<input name=name size=20 value='%s'></td> </tr>\n",
34         $user->{'name'};
35
36 # Show password
37 print "<tr> <td nowrap><b>$text{'user_pass'}</b></td> <td>\n";
38 if (!$in{'new'}) {
39         print "<input type=radio name=same value=1 checked> ",
40               "$text{'user_same'}\n";
41         print "<input type=radio name=same value=0> ",
42               "$text{'user_change'}\n";
43         }
44 print "<input name=pass type=password size=20></td> </tr>\n";
45
46 # Show enabled flag
47 print "<tr> <td nowrap><b>$text{'user_enabled'}</b></td> <td>\n";
48 printf "<input type=radio name=enabled value=1 %s> %s\n",
49         $user->{'pass'} =~ /^\*LK\*/ ? "" : "checked", $text{'yes'};
50 printf "<input type=radio name=enabled value=0 %s> %s</td> </tr>\n",
51         $user->{'pass'} =~ /^\*LK\*/ ? "checked" : "", $text{'no'};
52
53 # Show allowed IPS
54 print "<tr> <td valign=top nowrap><b>$acl::text{'edit_ips'}</b></td>\n";
55 print "<td><table><tr>\n";
56 printf "<td nowrap><input name=ipmode type=radio value=0 %s> %s<br>\n",
57         $user->{'allow'} || $user->{'deny'} ? '' : 'checked',
58         $acl::text{'edit_all'};
59 printf "<input name=ipmode type=radio value=1 %s> %s<br>\n",
60         $user->{'allow'} ? 'checked' : '', $acl::text{'edit_allow'};
61 printf "<input name=ipmode type=radio value=2 %s> %s</td> <td>\n",
62         $user->{'deny'} ? 'checked' : '', $acl::text{'edit_deny'};
63 print "<textarea name=ips rows=4 cols=30>",
64       join("\n", split(/\s+/, $user->{'allow'} ? $user->{'allow'}
65                                              : $user->{'deny'})),
66       "</textarea></td>\n";
67 print "</tr></table></td> </tr>\n";
68
69 # Show allowed modules (from list for *this* user)
70 print "<tr> <td valign=top nowrap><b>$text{'user_mods'}</b></td>\n";
71 &read_acl(\%acl);
72 @mymods = grep { $acl{$base_remote_user,$_->{'dir'}} } &get_all_module_infos();
73 print "<td><select name=mods size=5 multiple>\n";
74 foreach $m (sort { $a->{'desc'} cmp $b->{'desc'} } @mymods) {
75         printf "<option value=%s %s>%s\n",
76                 $m->{'dir'}, $gotmods{$m->{'dir'}} ? "selected" : "",
77                 $m->{'desc'};
78         }
79 print "</select></td> </tr>\n";
80
81 # Show access control
82 print "<tr> <td colspan=2><hr></td> </tr>\n";
83 require "./acl_security.pl";
84 if ($in{'new'}) {
85         %uaccess = ( 'features' => 'rules services groups nat pat spoof logs apply',
86                      'rfeatures' => 'rules services groups nat pat spoof logs apply',
87                      'edit' => 1 );
88         }
89 else {
90         %uaccess = &get_module_acl($user->{'name'});
91         }
92 &acl_security_form(\%uaccess);
93
94 print "</table></td></tr></table>\n";
95 if ($in{'new'}) {
96         print "<input type=submit value='$text{'create'}'>\n";
97         }
98 else {
99         print "<input type=submit value='$text{'save'}'>\n";
100         print "<input type=submit name=delete value='$text{'delete'}'>\n";
101         }
102 print "</form>\n";
103 &can_edit_disable("users");
104
105 print "<hr>\n";
106 &footer("list_users.cgi", $text{'users_return'});
107