2 require 'samba-lib.pl';
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the samba module
8 print "<tr>\n<td><b>$text{'acl_apply'}</b></td> <td>\n";
9 printf "<input type=radio name=apply value=1 %s> $text{'yes'}\n",
10 $_[0]->{'apply'} ? "checked" : "";
11 printf "<input type=radio name=apply value=0 %s> $text{'no'}</td>\n",
12 $_[0]->{'apply'} ? "" : "checked";
15 print "<tr>\n<td><b>$text{'acl_view_all_con'}</b></td> <td>\n";
16 printf "<input type=radio name=view_all_con value=1 %s> $text{'yes'}\n",
17 $_[0]->{'view_all_con'} ? "checked" : "";
18 printf "<input type=radio name=view_all_con value=0 %s> $text{'no'}</td>\n",
19 $_[0]->{'view_all_con'} ? "" : "checked";
22 print "<tr>\n<td><b>$text{'acl_kill_con'}</b></td> <td>\n";
23 printf "<input type=radio name=kill_con value=1 %s> $text{'yes'}\n",
24 $_[0]->{'kill_con'} ? "checked" : "";
25 printf "<input type=radio name=kill_con value=0 %s> $text{'no'}</td>\n",
26 $_[0]->{'kill_con'} ? "" : "checked";
29 print "<tr> <td colspan=4><hr></td> </tr>\n";
31 print "<tr>\n<td><b>$text{'acl_conf_net'}</b></td> <td>\n";
32 printf "<input type=radio name=conf_net value=1 %s> $text{'yes'}\n",
33 $_[0]->{'conf_net'} ? "checked" : "";
34 printf "<input type=radio name=conf_net value=0 %s> $text{'no'}</td>\n",
35 $_[0]->{'conf_net'} ? "" : "checked";
38 print "<tr>\n<td><b>$text{'acl_conf_smb'}</b></td> <td>\n";
39 printf "<input type=radio name=conf_smb value=1 %s> $text{'yes'}\n",
40 $_[0]->{'conf_smb'} ? "checked" : "";
41 printf "<input type=radio name=conf_smb value=0 %s> $text{'no'}</td>\n",
42 $_[0]->{'conf_smb'} ? "" : "checked";
45 print "<tr>\n<td><b>$text{'acl_conf_pass'}</b></td> <td>\n";
46 printf "<input type=radio name=conf_pass value=1 %s> $text{'yes'}\n",
47 $_[0]->{'conf_pass'} ? "checked" : "";
48 printf "<input type=radio name=conf_pass value=0 %s> $text{'no'}</td>\n",
49 $_[0]->{'conf_pass'} ? "" : "checked";
52 print "<tr>\n<td><b>$text{'acl_conf_print'}</b></td> <td>\n";
53 printf "<input type=radio name=conf_print value=1 %s> $text{'yes'}\n",
54 $_[0]->{'conf_print'} ? "checked" : "";
55 printf "<input type=radio name=conf_print value=0 %s> $text{'no'}</td>\n",
56 $_[0]->{'conf_print'} ? "" : "checked";
59 print "<tr>\n<td><b>$text{'acl_conf_misc'}</b></td> <td>\n";
60 printf "<input type=radio name=conf_misc value=1 %s> $text{'yes'}\n",
61 $_[0]->{'conf_misc'} ? "checked" : "";
62 printf "<input type=radio name=conf_misc value=0 %s> $text{'no'}</td>\n",
63 $_[0]->{'conf_misc'} ? "" : "checked";
66 print "<tr>\n<td><b>$text{'acl_swat'}</b></td> <td>\n";
67 printf "<input type=radio name=swat value=1 %s> $text{'yes'}\n",
68 $_[0]->{'swat'} ? "checked" : "";
69 printf "<input type=radio name=swat value=0 %s> $text{'no'}</td>\n",
70 $_[0]->{'swat'} ? "" : "checked";
73 print "<tr>\n<td><b>$text{'acl_manual'}</b></td> <td>\n";
74 printf "<input type=radio name=manual value=1 %s> $text{'yes'}\n",
75 $_[0]->{'manual'} ? "checked" : "";
76 printf "<input type=radio name=manual value=0 %s> $text{'no'}</td>\n",
77 $_[0]->{'manual'} ? "" : "checked";
80 print "<tr>\n<td><b>$text{'acl_winbind'}</b></td> <td>\n";
81 printf "<input type=radio name=winbind value=1 %s> $text{'yes'}\n",
82 $_[0]->{'winbind'} ? "checked" : "";
83 printf "<input type=radio name=winbind value=0 %s> $text{'no'}</td>\n",
84 $_[0]->{'winbind'} ? "" : "checked";
87 print "<tr> <td colspan=4><hr></td> </tr>\n";
90 print "<tr>\n<td $tb><b>$text{'acl_enc_passwd_opts'}</b></td></tr> \n";
92 print "<tr>\n<td><b>$text{'acl_view_users'}</b></td> <td>\n";
93 printf "<input type=radio name=view_users value=1 %s> $text{'yes'}\n",
94 $_[0]->{'view_users'} ? "checked" : "";
95 printf "<input type=radio name=view_users value=0 %s> $text{'no'}</td>\n",
96 $_[0]->{'view_users'} ? "" : "checked";
99 print "<tr>\n<td><b>$text{'acl_maint_users'}</b></td> <td>\n";
100 printf "<input type=radio name=maint_users value=1 %s> $text{'yes'}\n",
101 $_[0]->{'maint_users'} ? "checked" : "";
102 printf "<input type=radio name=maint_users value=0 %s> $text{'no'}</td>\n",
103 $_[0]->{'maint_users'} ? "" : "checked";
106 print "<tr>\n<td><b>$text{'acl_maint_makepass'}</b></td> <td>\n";
107 printf "<input type=radio name=maint_makepass value=1 %s> $text{'yes'}\n",
108 $_[0]->{'maint_makepass'} ? "checked" : "";
109 printf "<input type=radio name=maint_makepass value=0 %s> $text{'no'}</td>\n",
110 $_[0]->{'maint_makepass'} ? "" : "checked";
113 print "<tr>\n<td><b>$text{'acl_maint_sync'}</b></td> <td>\n";
114 printf "<input type=radio name=maint_sync value=1 %s> $text{'yes'}\n",
115 $_[0]->{'maint_sync'} ? "checked" : "";
116 printf "<input type=radio name=maint_sync value=0 %s> $text{'no'}</td>\n",
117 $_[0]->{'maint_sync'} ? "" : "checked";
120 print "<tr> <td colspan=4><hr></td> </tr>\n";
122 # encripted passwords
123 print "<tr>\n<td $tb><b>$text{'acl_group_opts'}</b></td></tr> \n";
125 print "<tr>\n<td><b>$text{'acl_maint_groups'}</b></td> <td>\n";
126 printf "<input type=radio name=maint_groups value=1 %s> $text{'yes'}\n",
127 $_[0]->{'maint_groups'} ? "checked" : "";
128 printf "<input type=radio name=maint_groups value=0 %s> $text{'no'}</td>\n",
129 $_[0]->{'maint_groups'} ? "" : "checked";
132 print "<tr>\n<td><b>$text{'acl_maint_gsync'}</b></td> <td>\n";
133 printf "<input type=radio name=maint_gsync value=1 %s> $text{'yes'}\n",
134 $_[0]->{'maint_gsync'} ? "checked" : "";
135 printf "<input type=radio name=maint_gsync value=0 %s> $text{'no'}</td>\n",
136 $_[0]->{'maint_gsync'} ? "" : "checked";
139 print "<tr> <td colspan=4><hr></td> </tr>\n";
142 print "<tr>\n<td><b>$text{'acl_hide'}</b></td> <td>\n";
143 printf "<input type=radio name=hide value=1 %s> $text{'yes'}\n",
144 $_[0]->{'hide'} == 1 ? "checked" : "";
145 printf "<input type=radio name=hide value=0 %s> $text{'no'}</td>\n",
146 $_[0]->{'hide'} == 0 ? "checked" : "";
149 print "<tr> <td colspan=4><hr></td> </tr>\n";
152 print "<tr>\n<td><b>$text{'acl_afs'}</b></td>\n";
153 print "<td colspan=3>\n";
154 printf "<input type=checkbox name=c_fs value=1 %s> %s\n",
155 $_[0]->{'c_fs'} ? "checked" : "", $text{"acl_c"};
156 printf "<input type=checkbox name=r_fs value=1 %s> %s\n",
157 $_[0]->{'r_fs'} ? "checked" : "", $text{"acl_r"};
158 printf "<input type=checkbox name=w_fs value=1 %s> %s\n",
159 $_[0]->{'w_fs'} ? "checked" : "", $text{"acl_w"};
160 print "</td> </tr>\n";
162 print "<tr>\n<td><b>$text{'acl_aps'}</b></td>\n";
163 print "<td colspan=3>\n";
164 printf "<input type=checkbox name=c_ps value=1 %s> %s\n",
165 $_[0]->{'c_ps'} ? "checked" : "", $text{"acl_c"};
166 printf "<input type=checkbox name=r_ps value=1 %s> %s\n",
167 $_[0]->{'r_ps'} ? "checked" : "", $text{"acl_r"};
168 printf "<input type=checkbox name=w_ps value=1 %s> %s\n",
169 $_[0]->{'w_ps'} ? "checked" : "", $text{"acl_w"};
170 print "</td> </tr>\n";
172 print "<tr>\n<td><b>$text{'acl_copy'}</b></td> <td>\n";
173 printf "<input type=radio name=copy value=1 %s> $text{'yes'}\n",
174 $_[0]->{'copy'} ? "checked" : "";
175 printf "<input type=radio name=copy value=0 %s> $text{'no'}</td>\n",
176 $_[0]->{'copy'} ? "" : "checked";
179 print "<tr> <td colspan=4><hr></td> </tr>\n";
182 print "<tr><td><b>$text{'acl_per_fs_acls'}</b></td> <td>\n";
183 printf "<input type=radio name=per_fs_acls value=1 %s> $text{'yes'}\n",
184 $_[0]->{'per_fs_acls'} ? "checked" : "";
185 printf "<input type=radio name=per_fs_acls value=0 %s> $text{'no'}\n",
186 $_[0]->{'per_fs_acls'} ? "" : "checked";
187 print "</td></tr>\n";
189 print "<tr><td><b>$text{'acl_per_ps_acls'}</b></td> <td>\n";
190 printf "<input type=radio name=per_ps_acls value=1 %s> $text{'yes'}\n",
191 $_[0]->{'per_ps_acls'} ? "checked" : "";
192 printf "<input type=radio name=per_ps_acls value=0 %s> $text{'no'}\n",
193 $_[0]->{'per_ps_acls'} ? "" : "checked";
194 print "</td></tr>\n";
196 print "<tr> <td colspan=4><hr></td> </tr>\n";
199 print "<tr> <td colspan=4>\n<table border width=100%>\n";
200 printf "<th $tb colspan=7><b>%s</b></th>\n", $text{'acl_per_share_acls'};
202 printf "<td rowspan=2><b>%s</b></td>\n", $text{'acl_sname'};
203 printf "<td rowspan=2><b>%s</b></td>\n", $text{'acl_saccess'};
204 printf "<td rowspan=2><b>%s</b></td>\n", $text{'acl_sconn'};
205 printf "<th colspan=4><b>%s</b></th>\n", $text{'acl_sopthdr'};
206 print "</tr>\n<tr $tb>\n";
207 printf "<td><b>%s</b></td>\n", $text{'acl_ssec'};
208 printf "<td><b>%s</b></td>\n", $text{'acl_sperm'};
209 printf "<td><b>%s</b></td>\n", $text{'acl_snaming'};
210 printf "<td><b>%s<br>%s</b></td>\n", $text{'acl_smisc'}, $text{'acl_sprn'};
213 foreach (&list_shares()) {
214 &display_acl_row($_[0], $_);
216 print "</table> </td> </tr>\n";
219 # acl_security_save(&options)
220 # Parse the form for security options for the samba module
221 sub acl_security_save
223 if ($in{'r_fs'} < $in{'w_fs'} || $in{'r_ps'} < $in{'w_ps'}) {
224 &error($text{'acl_ernow'});
226 $_[0]->{'apply'}=$in{'apply'};
227 $_[0]->{'view_all_con'}=$in{'view_all_con'};
228 $_[0]->{'kill_con'}=$in{'kill_con'};
229 $_[0]->{'conf_net'}=$in{'conf_net'};
230 $_[0]->{'conf_smb'}=$in{'conf_smb'};
231 $_[0]->{'conf_pass'}=$in{'conf_pass'};
232 $_[0]->{'conf_print'}=$in{'conf_print'};
233 $_[0]->{'conf_misc'}=$in{'conf_misc'};
234 $_[0]->{'swat'}=$in{'swat'};
235 $_[0]->{'manual'}=$in{'manual'};
236 $_[0]->{'hide'}=$in{'hide'};
237 $_[0]->{'per_fs_acls'}=$in{'per_fs_acls'};
238 $_[0]->{'per_ps_acls'}=$in{'per_ps_acls'};
239 $_[0]->{'c_fs'}=$in{'c_fs'};
240 $_[0]->{'r_fs'}=$in{'r_fs'};
241 $_[0]->{'w_fs'}=$in{'w_fs'};
242 $_[0]->{'c_ps'}=$in{'c_ps'};
243 $_[0]->{'r_ps'}=$in{'r_ps'};
244 $_[0]->{'w_ps'}=$in{'w_ps'};
245 $_[0]->{'copy'}=$in{'copy'};
246 $_[0]->{'view_users'}=$in{'view_users'};
247 $_[0]->{'maint_users'}=$in{'maint_users'};
248 $_[0]->{'maint_makepass'}=$in{'maint_makepass'};
249 $_[0]->{'maint_sync'}=$in{'maint_sync'};
250 $_[0]->{'maint_groups'}=$in{'maint_groups'};
251 $_[0]->{'maint_gsync'}=$in{'maint_gsync'};
252 $_[0]->{'winbind'}=$in{'winbind'};
255 $_[0]->{$1} .= $in{$_} if /^\w\w_(ACL\w\w_\w+)$/;
259 # display_acl_row(\%access, $share_name)
262 local($acc,$name)=@_;
265 local $stype=&istrue('printable') ? 'ps' : 'fs';
266 local $aclname='ACL' . $stype . '_' . $name;
270 printf $stype eq 'fs' ? "<td><b>%s</b></td>\n" :
271 "<td><b><i>%s</i></td>\n", $name;
272 &display_acl_cell($acc, $name, 'r', 'w', $aclname,
273 $text{'acl_na'}, $text{'acl_r1'}, $text{'acl_rw'});
274 &display_acl_cell($acc, $name, 'v', 'V', $aclname,
275 $text{'acl_na'}, $text{'acl_view'}, $text{'acl_kill'});
276 &display_acl_cell($acc, $name, 's', 'S', $aclname,
277 $text{'acl_na'}, $text{'acl_view'}, $text{'acl_edit'});
278 $stype eq 'fs' ? &display_acl_cell($acc, $name, 'p', 'P', $aclname,
279 $text{'acl_na'}, $text{'acl_view'}, $text{'acl_edit'}) :
280 print "<td> </td>\n";
281 $stype eq 'fs' ? &display_acl_cell($acc, $name, 'n', 'N', $aclname,
282 $text{'acl_na'}, $text{'acl_view'}, $text{'acl_edit'}) :
283 print "<td> </td>\n";
284 &display_acl_cell($acc, $name, 'o', 'O', $aclname,
285 $text{'acl_na'}, $text{'acl_view'}, $text{'acl_edit'});
289 #display_acl_cell(\%access, $name,
290 # $rperm, $wperm, $aclname,
291 # $text1, $text2, $text3)
294 local ($acc, $name, $rp, $wp, $aclname, $text1, $text2, $text3) = @_;
295 local $rn = $rp . $wp . '_' . $aclname;
298 if($acc->{$aclname}) {
299 printf "<input type=radio name=$rn value='' %s> %s<br>\n",
300 !&perm_to($rp, $acc, $aclname) ?
301 "checked" : "", $text1;
302 printf "<input type=radio name=$rn value='$rp' %s> %s<br>\n",
303 &perm_to($rp, $acc, $aclname) &&
304 !&perm_to($rp.$wp, $acc, $aclname) ?
305 "checked" : "",$text2;
306 printf "<input type=radio name=$rn value='$rp$wp' %s> %s\n",
307 &perm_to($rp.$wp, $acc, $aclname) ?
308 "checked" : "", $text3;
311 printf "<input type=radio name=$rn value='' checked> %s<br>\n",
313 printf "<input type=radio name=$rn value='$rp'> %s<br>\n",
315 printf "<input type=radio name=$rn value='$rp$wp'> %s\n",
321 # perm_to($permissions_string,\%access,$ACLname)
322 # check only per-share permissions
325 local $acl=$_[1]->{$_[2]};
326 foreach (split //,$_[0]) {
327 return 0 if index($acl,$_) == -1;