Handle hostnames with upper-case letters
[webmin.git] / acl / acl_security.pl
1
2 do 'acl-lib.pl';
3
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the acl module
6 sub acl_security_form
7 {
8 my ($o) = @_;
9 print "<tr> <td valign=top><b>$text{'acl_users'}</b></td>\n";
10 print "<td valign=top>\n";
11 printf "<input type=radio name=users_def value=1 %s> %s\n",
12         $o->{'users'} eq '*' ? 'checked' : '', $text{'acl_uall'};
13 printf "<input type=radio name=users_def value=2 %s> %s<br>\n",
14         $o->{'users'} eq '~' ? 'checked' : '', $text{'acl_uthis'};
15 printf "<input type=radio name=users_def value=0 %s> %s<br>\n",
16         $o->{'users'} eq '*' || $o->{'users'} eq '~' ? '' : 'checked',
17         $text{'acl_usel'};
18 print "<select name=users multiple size=6 width=150>\n";
19 map { $ucan{$_}++ } split(/\s+/, $o->{'users'});
20 foreach $u (&list_users()) {
21         printf "<option %s>%s\n",
22                 $ucan{$u->{'name'}} ? 'selected' : '',
23                 $u->{'name'};
24         }
25 foreach $g (&list_groups()) {
26         printf "<option %s value=%s>%s\n",
27                 $ucan{'_'.$g->{'name'}} ? 'selected' : '',
28                 '_'.$g->{'name'}, &text('acl_gr', $g->{'name'});
29         }
30 print "</select></td>\n";
31
32 print "<td valign=top><b>$text{'acl_mods'}</b></td> ",
33       "<td valign=top>\n";
34 printf "<input type=radio name=mode value=0 %s> %s&nbsp;\n",
35         $o->{'mode'} == 0 ? 'checked' : '', $text{'acl_all'};
36 printf "<input type=radio name=mode value=1 %s> %s<br>\n",
37         $o->{'mode'} == 1 ? 'checked' : '', $text{'acl_own'};
38 printf "<input type=radio name=mode value=2 %s> %s<br>\n",
39         $o->{'mode'} == 2 ? 'checked' : '', $text{'acl_sel'};
40 print "&nbsp;&nbsp;&nbsp;<select name=mods multiple size=6>\n";
41 map { $mcan{$_}++ } split(/\s+/, $o->{'mods'});
42 foreach $m (&list_module_infos()) {
43         printf "<option value=%s %s>%s\n",
44                 $m->{'dir'}, $mcan{$m->{'dir'}} ? 'selected' :'',
45                 $m->{'desc'};
46         }
47 print "</select></td> </tr>\n";
48
49 print "<tr> <td><b>$text{'acl_create'}</b></td> <td>\n";
50 printf "<input type=radio name=create value=1 %s> $text{'yes'}\n",
51         $o->{'create'} ? 'checked' : '';
52 printf "<input type=radio name=create value=0 %s> $text{'no'}</td>\n",
53         $o->{'create'} ? '' : 'checked';
54
55 print "<td><b>$text{'acl_delete'}</b></td> <td>\n";
56 printf "<input type=radio name=delete value=1 %s> $text{'yes'}\n",
57         $o->{'delete'} ? 'checked' : '';
58 printf "<input type=radio name=delete value=0 %s> $text{'no'}</td> </tr>\n",
59         $o->{'delete'} ? '' : 'checked';
60
61 print "<tr> <td><b>$text{'acl_rename'}</b></td> <td>\n";
62 printf "<input type=radio name=rename value=1 %s> $text{'yes'}\n",
63         $o->{'rename'} ? 'checked' : '';
64 printf "<input type=radio name=rename value=0 %s> $text{'no'}</td>\n",
65         $o->{'rename'} ? '' : 'checked';
66
67 print "<td><b>$text{'acl_acl'}</b></td> <td>\n";
68 printf "<input type=radio name=acl value=1 %s> $text{'yes'}\n",
69         $o->{'acl'} ? 'checked' : '';
70 printf "<input type=radio name=acl value=0 %s> $text{'no'}</td> </tr>\n",
71         $o->{'acl'} ? '' : 'checked';
72
73 print "<tr> <td><b>$text{'acl_cert'}</b></td> <td>\n";
74 printf "<input type=radio name=cert value=1 %s> $text{'yes'}\n",
75         $o->{'cert'} ? 'checked' : '';
76 printf "<input type=radio name=cert value=0 %s> $text{'no'}</td>\n",
77         $o->{'cert'} ? '' : 'checked';
78
79 print "<td><b>$text{'acl_others'}</b></td> <td>\n";
80 printf "<input type=radio name=others value=1 %s> $text{'yes'}\n",
81         $o->{'others'} ? 'checked' : '';
82 printf "<input type=radio name=others value=0 %s> $text{'no'}</td> </tr>\n",
83         $o->{'others'} ? '' : 'checked';
84
85 print "<tr> <td><b>$text{'acl_chcert'}</b></td> <td>\n";
86 printf "<input type=radio name=chcert value=1 %s> $text{'yes'}\n",
87         $o->{'chcert'} ? 'checked' : '';
88 printf "<input type=radio name=chcert value=0 %s> $text{'no'}</td>\n",
89         $o->{'chcert'} ? '' : 'checked';
90
91 print "<td><b>$text{'acl_lang'}</b></td> <td>\n";
92 printf "<input type=radio name=lang value=1 %s> $text{'yes'}\n",
93         $o->{'lang'} ? 'checked' : '';
94 printf "<input type=radio name=lang value=0 %s> $text{'no'}</td> </tr>\n",
95         $o->{'lang'} ? '' : 'checked';
96
97 print "<tr> <td><b>$text{'acl_cats'}</b></td> <td>\n";
98 printf "<input type=radio name=cats value=1 %s> $text{'yes'}\n",
99         $o->{'cats'} ? 'checked' : '';
100 printf "<input type=radio name=cats value=0 %s> $text{'no'}</td>\n",
101         $o->{'cats'} ? '' : 'checked';
102
103 print "<td><b>$text{'acl_theme'}</b></td> <td>\n";
104 printf "<input type=radio name=theme value=1 %s> $text{'yes'}\n",
105         $o->{'theme'} ? 'checked' : '';
106 printf "<input type=radio name=theme value=0 %s> $text{'no'}</td> </tr>\n",
107         $o->{'theme'} ? '' : 'checked';
108
109 print "<tr> <td><b>$text{'acl_ips'}</b></td> <td>\n";
110 printf "<input type=radio name=ips value=1 %s> $text{'yes'}\n",
111         $o->{'ips'} ? 'checked' : '';
112 printf "<input type=radio name=ips value=0 %s> $text{'no'}</td>\n",
113         $o->{'ips'} ? '' : 'checked';
114
115 print "<tr> <td><b>$text{'acl_perms'}</b></td> <td colspan=3>\n";
116 printf "<input type=radio name=perms value=1 %s> $text{'acl_perms_1'}\n",
117         $o->{'perms'} ? 'checked' : '';
118 printf "<input type=radio name=perms value=0 %s> $text{'acl_perms_0'}</td>\n",
119         $o->{'perms'} ? '' : 'checked';
120 print "</tr>\n";
121
122 print "<tr> <td><b>$text{'acl_sync'}</b></td> <td>\n";
123 printf "<input type=radio name=sync value=1 %s> $text{'yes'}\n",
124         $o->{'sync'} ? 'checked' : '';
125 printf "<input type=radio name=sync value=0 %s> $text{'no'}</td>\n",
126         $o->{'sync'} ? '' : 'checked';
127
128 print "<td><b>$text{'acl_unix'}</b></td> <td>\n";
129 printf "<input type=radio name=unix value=1 %s> $text{'yes'}\n",
130         $o->{'unix'} ? 'checked' : '';
131 printf "<input type=radio name=unix value=0 %s> $text{'no'}</td> </tr>\n",
132         $o->{'unix'} ? '' : 'checked';
133
134 print "<tr> <td><b>$text{'acl_sessions'}</b></td> <td>\n";
135 printf "<input type=radio name=sessions value=1 %s> $text{'yes'}\n",
136         $o->{'sessions'} ? 'checked' : '';
137 printf "<input type=radio name=sessions value=0 %s> $text{'no'}</td>\n",
138         $o->{'sessions'} ? '' : 'checked';
139
140 print "<td><b>$text{'acl_switch'}</b></td> <td>\n";
141 printf "<input type=radio name=switch value=1 %s> $text{'yes'}\n",
142         $o->{'switch'} ? 'checked' : '';
143 printf "<input type=radio name=switch value=0 %s> $text{'no'}</td> </tr>\n",
144         $o->{'switch'} ? '' : 'checked';
145
146 print "<tr> <td><b>$text{'acl_times'}</b></td> <td>\n";
147 printf "<input type=radio name=times value=1 %s> $text{'yes'}\n",
148         $o->{'times'} ? 'checked' : '';
149 printf "<input type=radio name=times value=0 %s> $text{'no'}</td>\n",
150         $o->{'times'} ? '' : 'checked';
151
152 print "<td><b>$text{'acl_pass'}</b></td> <td>\n";
153 printf "<input type=radio name=pass value=1 %s> $text{'yes'}\n",
154         $o->{'pass'} ? 'checked' : '';
155 printf "<input type=radio name=pass value=0 %s> $text{'no'}</td> </tr>\n",
156         $o->{'pass'} ? '' : 'checked';
157
158 print "<tr> <td><b>$text{'acl_sqls'}</b></td> <td>\n";
159 printf "<input type=radio name=sqls value=1 %s> $text{'yes'}\n",
160         $o->{'sqls'} ? 'checked' : '';
161 printf "<input type=radio name=sqls value=0 %s> $text{'no'}</td>\n",
162         $o->{'sqls'} ? '' : 'checked';
163
164 print "</tr>\n";
165
166 print "<tr> <td colspan=4><hr></td> </tr>\n";
167
168 print "<tr> <td valign=top><b>$text{'acl_groups'}</b></td> <td valign=top>\n";
169 printf "<input type=radio name=groups value=1 %s> $text{'yes'}\n",
170         $o->{'groups'} == 1 ? 'checked' : '';
171 printf "<input type=radio name=groups value=0 %s> $text{'no'}</td>\n",
172         $o->{'groups'} == 0 ? 'checked' : '';
173
174 print "<td valign=top><b>$text{'acl_gassign'}</b></td> <td>\n";
175 printf "<input type=radio name=gassign_def value=1 %s> %s\n",
176         $o->{'gassign'} eq '*' ? 'checked' : '', $text{'acl_gall'};
177 printf "<input type=radio name=gassign_def value=0 %s> %s<br>\n",
178         $o->{'gassign'} eq '*' ? '' : 'checked', $text{'acl_gsel'};
179 print "<select name=gassign multiple size=3 width=150>\n";
180 map { $gcan{$_}++ } split(/\s+/, $o->{'gassign'});
181 printf "<option value=_none %s>&lt;%s&gt;\n",
182         $gcan{'_none'} ? 'selected' : '', $text{'acl_gnone'};
183 foreach $g (&list_groups()) {
184         printf "<option %s>%s\n",
185                 $gcan{$g->{'name'}} ? 'selected' : '', $g->{'name'};
186         }
187 print "</select></td> </tr>\n";
188 }
189
190 # acl_security_save(&options)
191 # Parse the form for security options for the acl module
192 sub acl_security_save
193 {
194 if ($in{'users_def'} == 1) {
195         $_[0]->{'users'} = '*';
196         }
197 elsif ($in{'users_def'} == 2) {
198         $_[0]->{'users'} = '~';
199         }
200 else {
201         $_[0]->{'users'} = join(" ", split(/\0/, $in{'users'}));
202         }
203 $_[0]->{'mode'} = $in{'mode'};
204 $_[0]->{'mods'} = $in{'mode'} == 2 ? join(" ", split(/\0/, $in{'mods'}))
205                                    : undef;
206 $_[0]->{'create'} = $in{'create'};
207 $_[0]->{'groups'} = $in{'groups'};
208 $_[0]->{'delete'} = $in{'delete'};
209 $_[0]->{'rename'} = $in{'rename'};
210 $_[0]->{'acl'} = $in{'acl'};
211 $_[0]->{'others'} = $in{'others'};
212 $_[0]->{'cert'} = $in{'cert'};
213 $_[0]->{'chcert'} = $in{'chcert'};
214 $_[0]->{'lang'} = $in{'lang'};
215 $_[0]->{'perms'} = $in{'perms'};
216 $_[0]->{'gassign'} = $in{'gassign_def'} ? '*' :
217                      join(" ", split(/\0/, $in{'gassign'}));
218 $_[0]->{'sync'} = $in{'sync'};
219 $_[0]->{'unix'} = $in{'unix'};
220 $_[0]->{'switch'} = $in{'switch'};
221 $_[0]->{'sessions'} = $in{'sessions'};
222 $_[0]->{'cats'} = $in{'cats'};
223 $_[0]->{'theme'} = $in{'theme'};
224 $_[0]->{'ips'} = $in{'ips'};
225 $_[0]->{'times'} = $in{'times'};
226 $_[0]->{'pass'} = $in{'pass'};
227 $_[0]->{'sql'} = $in{'sql'};
228 }
229