require 'file-lib.pl';
do '../ui-lib.pl';
# acl_security_form(&options)
# Output HTML for editing security options for the file module
sub acl_security_form
{
print "
$text{'acl_user'} \n";
local $u = $_[0]->{'uid'} < 0 ? '' : getpwuid($_[0]->{'uid'});
printf " %s\n",
$_[0]->{'uid'} < 0 ? 'checked' : '', $text{'acl_user_def'};
printf " \n",
$_[0]->{'uid'} < 0 ? '' : 'checked';
print " ",
&user_chooser_button("uid", 0)," \n";
print " $text{'acl_umask'} \n";
print " \n";
print " $text{'acl_follow'} \n";
printf " $text{'yes'}\n",
$_[0]->{'follow'} == 1 ? "checked" : "";
printf " $text{'acl_fyes'}\n",
$_[0]->{'follow'} == 2 ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'follow'} == 0 ? "checked" : "";
print " $text{'acl_ro'} \n";
printf " $text{'yes'}\n",
$_[0]->{'ro'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'ro'} ? "" : "checked";
print " $text{'acl_max'} \n";
printf " %s\n",
$_[0]->{'max'} ? "" : "checked", $text{'acl_unlim'};
printf " \n",
$_[0]->{'max'} ? "checked" : "";
printf " %s \n",
$_[0]->{'max'}, $text{'acl_b'};
print " $text{'acl_archive'} \n";
printf " $text{'yes'}\n",
$_[0]->{'archive'} == 1 ? "checked" : "";
printf " $text{'acl_archmax'}\n",
$_[0]->{'archive'} == 2 ? "checked" : "";
printf " %s\n",
$_[0]->{'archmax'}, $text{'acl_b'};
printf " $text{'no'} \n",
$_[0]->{'archive'} == 0 ? "checked" : "";
print " $text{'acl_unarchive'} \n";
printf " %s\n",
$_[0]->{'unarchive'} == 2 ? "checked" : "", $text{'acl_unarchive2'};
printf " %s\n",
$_[0]->{'unarchive'} == 1 ? "checked" : "", $text{'acl_unarchive1'};
printf " %s \n",
$_[0]->{'unarchive'} == 0 ? "checked" : "", $text{'acl_unarchive0'};
print " $text{'acl_dostounix'} \n";
printf " %s\n",
$_[0]->{'dostounix'} == 1 ? "checked" : "", $text{'yes'};
printf " %s \n",
$_[0]->{'dostounix'} == 0 ? "checked" : "", $text{'no'};
print " $text{'acl_buttons'} \n";
foreach $b (@file_buttons) {
printf " %s \n",
$b, $_[0]->{'button_'.$b} ? "checked" : "",
$text{'acl_button_'.$b};
}
print " \n";
print " $text{'acl_noperms'} \n";
print "",&ui_radio("noperms", int($_[0]->{'noperms'}),
[ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ])," \n";
print "$text{'acl_nousers'} \n";
print "",&ui_radio("nousers", int($_[0]->{'nousers'}),
[ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ])," \n";
print " $text{'acl_filesystems'} \n";
print "",&ui_yesno_radio("filesystems",
int($_[0]->{'filesystems'}))," \n";
print "$text{'acl_contents'} \n";
print "",&ui_yesno_radio("contents",
int($_[0]->{'contents'}))," \n";
print " $text{'acl_chroot'} \n";
printf " \n",
$_[0]->{'chroot'};
print " $text{'acl_dirs'} $text{'acl_relto'} \n";
print " \n";
printf " %s \n",
$_[0]->{'home'} ? 'checked' : '', $text{'acl_home'};
printf " %s \n",
$_[0]->{'goto'} ? 'checked' : '', $text{'acl_goto'};
print " $text{'acl_nodirs'} $text{'acl_relto'} \n";
print " \n";
}
# acl_security_save(&options)
# Parse the form for security options for the file module
sub acl_security_save
{
$_[0]->{'uid'} = $in{'uid_def'} ? -1 : getpwnam($in{'uid'});
$in{'root'} =~ s/\r//g;
local @root = split(/\s+/, $in{'root'});
map { s/\/+/\//g } @root;
map { s/([^\/])\/+$/$1/ } @root;
$_[0]->{'root'} = join(" ", @root);
$in{'noroot'} =~ s/\r//g;
local @noroot = split(/\s+/, $in{'noroot'});
map { s/\/+/\//g } @noroot;
map { s/([^\/])\/+$/$1/ } @noroot;
$_[0]->{'noroot'} = join(" ", @noroot);
$_[0]->{'follow'} = $in{'follow'};
$_[0]->{'ro'} = $in{'ro'};
$in{'umask'} =~ /^[0-7]{3}$/ || &error("Invalid umask");
$_[0]->{'umask'} = $in{'umask'};
$_[0]->{'home'} = $in{'home'};
$_[0]->{'goto'} = $in{'goto'};
$_[0]->{'max'} = $in{'max_def'} ? undef : $in{'max'};
$_[0]->{'archive'} = $in{'archive'};
$_[0]->{'archmax'} = $in{'archmax'};
foreach $b (@file_buttons) {
$_[0]->{"button_$b"} = $in{"button_$b"};
}
$_[0]->{'unarchive'} = $in{'unarchive'};
$_[0]->{'dostounix'} = $in{'dostounix'};
$_[0]->{'chroot'} = $in{'chroot'};
$_[0]->{'noperms'} = $in{'noperms'};
$_[0]->{'nousers'} = $in{'nousers'};
$_[0]->{'filesystems'} = $in{'filesystems'};
$_[0]->{'contents'} = $in{'contents'};
}