require 'proc-lib.pl';
# acl_security_form(&options)
# Output HTML for editing security options for the proc module
sub acl_security_form
{
# Run as user
print "
$text{'acl_manage'} \n";
local $u = $_[0]->{'uid'} < 0 ? undef : getpwuid($_[0]->{'uid'});
printf " %s\n",
$_[0]->{'uid'} < 0 ? 'checked' : '', $text{'acl_manage_def'};
printf " \n",
$_[0]->{'uid'} < 0 ? '' : 'checked';
print " ",
&user_chooser_button("uid", 0)," \n";
# Who can be managed
if (!defined($_[0]->{'users'})) {
$_[0]->{'users'} = $_[0]->{'uid'} < 0 ? "x" :
$_[0]->{'uid'} == 0 ? "*" : getpwuid($_[0]->{'uid'});
}
local $who = $_[0]->{'users'} eq "x" ? 1 :
$_[0]->{'users'} eq "*" ? 0 : 2;
print " $text{'acl_who'} \n";
print &ui_radio("who", $who,
[ [ 0, $text{'acl_who0'}." \n" ],
[ 1, $text{'acl_who1'}." \n" ],
[ 2, $text{'acl_who2'} ] ])." ".
&ui_textbox("users", $who == 2 ? $_[0]->{'users'} : "",
40)," \n";
# Can do stuff to processes?
print " $text{'acl_edit'} \n";
printf " %s\n",
$_[0]->{'edit'} ? 'checked' : '', $text{'yes'};
printf " %s \n",
$_[0]->{'edit'} ? '' : 'checked', $text{'no'};
# Can run commands?
print " $text{'acl_run'} \n";
printf " %s\n",
$_[0]->{'run'} ? 'checked' : '', $text{'yes'};
printf " %s \n",
$_[0]->{'run'} ? '' : 'checked', $text{'no'};
# Can see other processes?
print " $text{'acl_only'} \n";
printf " %s\n",
$_[0]->{'only'} ? 'checked' : '', $text{'yes'};
printf " %s \n",
$_[0]->{'only'} ? '' : 'checked', $text{'no'};
}
# 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 ? "*" :
$in{'who'} == 1 ? "x" : $in{'users'};
}