mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
Fix user edit form
This commit is contained in:
@@ -14,78 +14,71 @@ require './samba-lib.pl';
|
||||
@ulist = &list_users();
|
||||
$u = $ulist[$in{'idx'}];
|
||||
|
||||
print "<form action=save_euser.cgi>\n";
|
||||
print "<input type=hidden name=idx value=\"$in{'idx'}\">\n";
|
||||
print "<table border width=100%>\n";
|
||||
print "<tr $tb> <td><b>$text{'euser_title'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table width=100%>\n";
|
||||
print &ui_form_start("save_euser.cgi", "post");
|
||||
print &ui_hidden("idx", $in{'idx'});
|
||||
print &ui_table_start($text{'euser_title'}, undef, 2);
|
||||
|
||||
print "<tr> <td align=right><b>$text{'euser_name'}</b></td>\n";
|
||||
print "<td><tt>$u->{'name'}</tt></td>\n";
|
||||
print &ui_table_row($text{'euser_name'},
|
||||
"<tt>".&html_escape($u->{'name'})."</tt>");
|
||||
|
||||
print "<td align=right><b>$text{'euser_uid'}</b></td>\n";
|
||||
print "<td><input name=uid size=5 value=\"$u->{'uid'}\"></td> </tr>\n";
|
||||
print &ui_table_row($text{'euser_uid'},
|
||||
&ui_textbox("uid", $u->{'uid'}, 6));
|
||||
|
||||
print "<tr> <td align=right><b>$text{'euser_passwd'}</b></td>\n";
|
||||
if ($samba_version >= 3) {
|
||||
# In the new Samba, the password field is not really used for locking
|
||||
# accounts any more, so don't both with the no access/no password
|
||||
# options.
|
||||
print "<td colspan=3><input type=radio name=ptype value=2 checked> ",
|
||||
"$text{'euser_currpw'}\n";
|
||||
$pwfield = &ui_radio("ptype", 2,
|
||||
[ [ 2, $text{'euser_currpw'} ],
|
||||
[ 3, $text{'euser_newpw'}." ".
|
||||
&ui_password("pass", undef, 20) ] ]);
|
||||
}
|
||||
else {
|
||||
# In the old Samba, you can set the password to deny a login to the
|
||||
# account or allow logins without a password
|
||||
$locked = ($u->{'pass1'} eq ("X" x 32));
|
||||
$nopass = ($u->{'pass1'} =~ /^NO PASSWORD/);
|
||||
printf "<td colspan=3><input type=radio name=ptype value=0 %s> $text{'euser_noaccess'}\n",
|
||||
$locked ? "checked" : "";
|
||||
printf "<input type=radio name=ptype value=1 %s> $text{'euser_nopw'}\n",
|
||||
$nopass ? "checked" : "";
|
||||
printf "<input type=radio name=ptype value=2 %s> $text{'euser_currpw'}\n",
|
||||
$locked||$nopass ? "" : "checked";
|
||||
$pwfield = &ui_radio("ptype", $locked ? 0 : $nopass ? 1 : 2,
|
||||
[ [ 0, $text{'euser_noaccess'} ],
|
||||
[ 1, $text{'euser_nopw'} ],
|
||||
[ 2, $text{'euser_currpw'} ],
|
||||
[ 3, $text{'euser_newpw'}." ".
|
||||
&ui_password("pass", undef, 20) ] ]);
|
||||
}
|
||||
print "<input type=radio name=ptype value=3> $text{'euser_newpw'}\n";
|
||||
print "<input type=password name=pass size=20></td> </tr>\n";
|
||||
print &ui_table_row($text{'euser_passwd'}, $pwfield);
|
||||
|
||||
if (!$u->{'opts'}) {
|
||||
# Old-style samba user
|
||||
print "<tr> <td align=right><b>$text{'euser_realname'}</b></td> <td colspan=3>\n";
|
||||
print "<input name=realname size=40 value='$u->{'real'}'></td> </tr>\n";
|
||||
print &ui_table_row($text{'euser_realname'},
|
||||
&ui_textbox("realname", $u->{'real'}, 40));
|
||||
|
||||
print "<tr> <td align=right><b>$text{'euser_homedir'}</b></td>\n";
|
||||
print "<td><input name=homedir size=30 value='$u->{'home'}'></td>\n";
|
||||
print &ui_table_row($text{'euser_homedir'},
|
||||
&ui_textbox("homedir", $u->{'home'}, 40));
|
||||
|
||||
print "<td align=right><b>$text{'euser_shell'}</b></td>\n";
|
||||
printf "<td><input name=shell size=15 value='%s'></td> </tr>\n",
|
||||
$u->{'shell'};
|
||||
print &ui_table_row($text{'euser_shell'},
|
||||
&ui_textbox("shell", $u->{'shell'}, 15));
|
||||
}
|
||||
else {
|
||||
# New-style samba user
|
||||
print "<input type=hidden name=new value=1>\n";
|
||||
print &ui_hidden("new", 1);
|
||||
map { $opt{uc($_)}++ } @{$u->{'opts'}};
|
||||
print "<tr> <td valign=top align=right><b>$text{'euser_option'}</b></td> <td colspan=3>\n";
|
||||
@ol = ($text{'euser_normal'}, "U", $text{'euser_nopwrequired'}, "N",
|
||||
$text{'euser_disable'}, "D", $text{'euser_locked'}, "L" ,$text{'euser_noexpire'}, "X", $text{'euser_trust'}, "W");
|
||||
for($i=0; $i<@ol; $i+=2) {
|
||||
printf "<input type=checkbox name=opts value=%s %s> %s<br>\n",
|
||||
$ol[$i+1], $opt{$ol[$i+1]} ? "checked" : "", $ol[$i];
|
||||
push(@checks, &ui_checkbox("opts", $ol[$i+1], $ol[$i],
|
||||
$opt{$ol[$i+1]}));
|
||||
delete($opt{$ol[$i+1]});
|
||||
}
|
||||
print &ui_table_row($text{'euser_option'},
|
||||
join("<br>\n", @checks));
|
||||
foreach $oo (keys %opt) {
|
||||
print "<input type=hidden name=opts value=$oo>\n";
|
||||
print &ui_hidden("opts", $oo);
|
||||
}
|
||||
print "</td> </tr>\n";
|
||||
}
|
||||
|
||||
print "</table></td></tr></table>\n";
|
||||
print "<table width=100%>\n";
|
||||
print "<tr> <td><input type=submit value=$text{'save'}></td>\n";
|
||||
print "</form><form action=\"delete_euser.cgi\">\n";
|
||||
print "<input type=hidden name=idx value=\"$in{'idx'}\">\n";
|
||||
print "<td align=right><input type=submit value=$text{'delete'}></td> </tr>\n";
|
||||
print "</form></table><p>\n";
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'save'} ],
|
||||
[ 'delete', $text{'delete'} ] ]);
|
||||
|
||||
&ui_print_footer("edit_epass.cgi", $text{'index_userlist'},
|
||||
"", $text{'index_sharelist'});
|
||||
|
||||
@@ -4,11 +4,18 @@
|
||||
|
||||
require './samba-lib.pl';
|
||||
&ReadParse();
|
||||
# check acls
|
||||
|
||||
if ($in{'delete'}) {
|
||||
# Just redirect to delete page
|
||||
&redirect("delete_euser.cgi?idx=$in{'idx'}");
|
||||
return;
|
||||
}
|
||||
|
||||
# check acls
|
||||
&error_setup("$text{'eacl_aviol'}ask_epass.cgi");
|
||||
&error("$text{'eacl_np'} $text{'eacl_pmusers'}")
|
||||
unless $access{'maint_users'} && $access{'view_users'};
|
||||
|
||||
# save
|
||||
&error_setup($text{'saveuser_fail'});
|
||||
&lock_file($config{'smb_passwd'});
|
||||
|
||||
Reference in New Issue
Block a user