mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
use ui-lib and formal params
This commit is contained in:
@@ -5,62 +5,53 @@ require 'proc-lib.pl';
|
||||
# Output HTML for editing security options for the proc module
|
||||
sub acl_security_form
|
||||
{
|
||||
my ($o) = @_;
|
||||
|
||||
# Run as user
|
||||
print "<tr> <td><b>$text{'acl_manage'}</b></td> <td colspan=3>\n";
|
||||
local $u = $_[0]->{'uid'} < 0 ? undef : getpwuid($_[0]->{'uid'});
|
||||
printf "<input type=radio name=uid_def value=1 %s> %s\n",
|
||||
$_[0]->{'uid'} < 0 ? 'checked' : '', $text{'acl_manage_def'};
|
||||
printf "<input type=radio name=uid_def value=0 %s>\n",
|
||||
$_[0]->{'uid'} < 0 ? '' : 'checked';
|
||||
print "<input name=uid size=8 value='$u'> ",
|
||||
&user_chooser_button("uid", 0),"</td> </tr>\n";
|
||||
my $u = $o->{'uid'} < 0 ? undef : getpwuid($o->{'uid'});
|
||||
print &ui_table_row($text{'acl_manage'},
|
||||
&ui_radio("uid_def", $_[0]->{'uid'} < 0 ? 1 : 0,
|
||||
[ [ 1, $text{'acl_manage_def'} ],
|
||||
[ 0, &ui_user_textbox("uid", $u) ] ]), 3);
|
||||
|
||||
# Who can be managed
|
||||
if (!defined($_[0]->{'users'})) {
|
||||
$_[0]->{'users'} = $_[0]->{'uid'} < 0 ? "x" :
|
||||
$_[0]->{'uid'} == 0 ? "*" : getpwuid($_[0]->{'uid'});
|
||||
if (!defined($o->{'users'})) {
|
||||
$o->{'users'} = $o->{'uid'} < 0 ? "x" :
|
||||
$o->{'uid'} == 0 ? "*" : getpwuid($o->{'uid'});
|
||||
}
|
||||
local $who = $_[0]->{'users'} eq "x" ? 1 :
|
||||
$_[0]->{'users'} eq "*" ? 0 : 2;
|
||||
print "<tr> <td valign=top><b>$text{'acl_who'}</b></td> <td colspan=3>\n";
|
||||
print &ui_radio("who", $who,
|
||||
my $who = $o->{'users'} eq "x" ? 1 :
|
||||
$o->{'users'} eq "*" ? 0 : 2;
|
||||
print &ui_table_row($text{'acl_who'},
|
||||
&ui_radio("who", $who,
|
||||
[ [ 0, $text{'acl_who0'}."<br>\n" ],
|
||||
[ 1, $text{'acl_who1'}."<br>\n" ],
|
||||
[ 2, $text{'acl_who2'} ] ])." ".
|
||||
&ui_textbox("users", $who == 2 ? $_[0]->{'users'} : "",
|
||||
40),"</td> </tr>\n";
|
||||
40), 3);
|
||||
|
||||
# Can do stuff to processes?
|
||||
print "<tr> <td><b>$text{'acl_edit'}</b></td>\n";
|
||||
printf "<td colspan=3><input type=radio name=edit value=1 %s> %s\n",
|
||||
$_[0]->{'edit'} ? 'checked' : '', $text{'yes'};
|
||||
printf "<input type=radio name=edit value=0 %s> %s</td> </tr>\n",
|
||||
$_[0]->{'edit'} ? '' : 'checked', $text{'no'};
|
||||
print &ui_table_row($text{'acl_edit'},
|
||||
&ui_yesno_radio("edit", $o->{'edit'}), 3);
|
||||
|
||||
# Can run commands?
|
||||
print "<tr> <td><b>$text{'acl_run'}</b></td>\n";
|
||||
printf "<td colspan=3><input type=radio name=run value=1 %s> %s\n",
|
||||
$_[0]->{'run'} ? 'checked' : '', $text{'yes'};
|
||||
printf "<input type=radio name=run value=0 %s> %s</td> </tr>\n",
|
||||
$_[0]->{'run'} ? '' : 'checked', $text{'no'};
|
||||
print &ui_table_row($text{'acl_run'},
|
||||
&ui_yesno_radio("run", $o->{'run'}), 3);
|
||||
|
||||
# Can see other processes?
|
||||
print "<tr> <td><b>$text{'acl_only'}</b></td>\n";
|
||||
printf "<td colspan=3><input type=radio name=only value=1 %s> %s\n",
|
||||
$_[0]->{'only'} ? 'checked' : '', $text{'yes'};
|
||||
printf "<input type=radio name=only value=0 %s> %s</td> </tr>\n",
|
||||
$_[0]->{'only'} ? '' : 'checked', $text{'no'};
|
||||
print &ui_table_row($text{'acl_only'},
|
||||
&ui_yesno_radio("only", $o->{'only'}), 3);
|
||||
}
|
||||
|
||||
# acl_security_save(&options)
|
||||
# Parse the form for security options for the proc module
|
||||
sub acl_security_save
|
||||
{
|
||||
$_[0]->{'uid'} = $in{'uid_def'} ? -1 : getpwnam($in{'uid'});
|
||||
$_[0]->{'edit'} = $in{'edit'};
|
||||
$_[0]->{'run'} = $in{'run'};
|
||||
$_[0]->{'only'} = $in{'only'};
|
||||
$_[0]->{'users'} = $in{'who'} == 0 ? "*" :
|
||||
my ($o) = @_;
|
||||
$o->{'uid'} = $in{'uid_def'} ? -1 : getpwnam($in{'uid'});
|
||||
$o->{'edit'} = $in{'edit'};
|
||||
$o->{'run'} = $in{'run'};
|
||||
$o->{'only'} = $in{'only'};
|
||||
$o->{'users'} = $in{'who'} == 0 ? "*" :
|
||||
$in{'who'} == 1 ? "x" : $in{'users'};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user