mirror of
https://github.com/webmin/webmin.git
synced 2026-05-26 08:00:31 +01:00
strict conversion
This commit is contained in:
@@ -71,6 +71,8 @@ save_euids=UIDs not to trust must be a comma-separated list of numbers or ranges
|
||||
save_egids=GIDs not to trust must be a comma-separated list of numbers or ranges
|
||||
save_pfs='$1' is already exported as a directory
|
||||
save_create_dir=Can't create the directory '$1'
|
||||
save_eanonuid=Invalid anonymous access username
|
||||
save_eanongid=Invalid anonymous access group name
|
||||
|
||||
exports_webnfs=WebNFS clients
|
||||
exports_ngroup=Netgroup $1
|
||||
|
||||
@@ -2,17 +2,24 @@
|
||||
# save_export.cgi
|
||||
# Save, create or delete an export
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
require './exports-lib.pl';
|
||||
our (%text, %in, %config);
|
||||
&ReadParse();
|
||||
&lock_file($config{'exports_file'});
|
||||
@exps = &list_exports();
|
||||
|
||||
&lock_file($config{'exports_file'});
|
||||
my @exps = &list_exports();
|
||||
|
||||
my %exp;
|
||||
if ($in{'delete'}) {
|
||||
# Deleting some export
|
||||
$exp = $exps[$in{'idx'}];
|
||||
my $exp = $exps[$in{'idx'}];
|
||||
&delete_export($exp);
|
||||
%exp = %$exp;
|
||||
}
|
||||
else {
|
||||
my ($oldexp, %opts);
|
||||
if (!$in{'new'}) {
|
||||
# Get old export
|
||||
$oldexp = $exps[$in{'idx'}];
|
||||
@@ -49,97 +56,125 @@ else {
|
||||
|
||||
# Authentication is in the host name
|
||||
# Only sys and krb5 for the moment
|
||||
local $auth = "";
|
||||
my $auth = "";
|
||||
if ($in{'auth'}) {
|
||||
if ($in{'sec'} == 0) { $auth = "krb5"; }
|
||||
if ($in{'sec'} == 1) { $auth = "krb5i"; }
|
||||
if ($in{'sec'} == 2) { $auth = "krb5p"; }
|
||||
}
|
||||
if ($auth ne "") { $exp{'host'} = "gss/$auth"; }
|
||||
if ($in{'sec'} == 0) { $auth = "krb5"; }
|
||||
if ($in{'sec'} == 1) { $auth = "krb5i"; }
|
||||
if ($in{'sec'} == 2) { $auth = "krb5p"; }
|
||||
}
|
||||
if ($auth ne "") {
|
||||
$exp{'host'} = "gss/$auth";
|
||||
}
|
||||
|
||||
# validate and parse options
|
||||
delete($opts{'rw'}); delete($opts{'ro'});
|
||||
# Validate and parse options
|
||||
delete($opts{'rw'});
|
||||
delete($opts{'ro'});
|
||||
if ($in{'ro'}) {
|
||||
$opts{'ro'} = "";
|
||||
} else {
|
||||
$opts{'rw'} = "";
|
||||
}
|
||||
$opts{'ro'} = "";
|
||||
}
|
||||
else {
|
||||
$opts{'rw'} = "";
|
||||
}
|
||||
|
||||
delete($opts{'secure'}); delete($opts{'insecure'});
|
||||
delete($opts{'secure'});
|
||||
delete($opts{'insecure'});
|
||||
$opts{'insecure'} = "" if ($in{'insecure'});
|
||||
|
||||
delete($opts{'no_subtree_check'}); delete($opts{'subtree_check'});
|
||||
delete($opts{'no_subtree_check'});
|
||||
delete($opts{'subtree_check'});
|
||||
$opts{'no_subtree_check'} = "" if ($in{'no_subtree_check'});
|
||||
|
||||
delete($opts{'nohide'}); delete($opts{'hide'});
|
||||
delete($opts{'nohide'});
|
||||
delete($opts{'hide'});
|
||||
$opts{'nohide'} = "" if ($in{'nohide'});
|
||||
|
||||
delete($opts{'sync'}); delete($opts{'async'});
|
||||
if ($in{'sync'} == 1) {
|
||||
$opts{'sync'} = "";
|
||||
} elsif ($in{'sync'} == 2) {
|
||||
$opts{'async'} = "";
|
||||
}
|
||||
$opts{'sync'} = "";
|
||||
}
|
||||
elsif ($in{'sync'} == 2) {
|
||||
$opts{'async'} = "";
|
||||
}
|
||||
|
||||
delete($opts{'root_squash'}); delete($opts{'no_root_squash'});
|
||||
delete($opts{'all_squash'}); delete($opts{'no_all_squash'});
|
||||
delete($opts{'root_squash'});
|
||||
delete($opts{'no_root_squash'});
|
||||
delete($opts{'all_squash'});
|
||||
delete($opts{'no_all_squash'});
|
||||
$opts{'no_root_squash'} = "" if ($in{'squash'} == 0);
|
||||
$opts{'all_squash'} = "" if ($in{'squash'} == 2);
|
||||
|
||||
if ($in{'anonuid_def'}) { delete($opts{'anonuid'}); }
|
||||
if ($in{'anonuid_def'}) {
|
||||
delete($opts{'anonuid'});
|
||||
}
|
||||
elsif ($in{'anonuid'} =~ /^-?[0-9]+$/) {
|
||||
$opts{'anonuid'} = $in{'anonuid'}; }
|
||||
else { $opts{'anonuid'} = getpwnam($in{'anonuid'}); }
|
||||
$opts{'anonuid'} = $in{'anonuid'};
|
||||
}
|
||||
else {
|
||||
$opts{'anonuid'} = getpwnam($in{'anonuid'});
|
||||
$opts{'anonuid'} || &error($text{'save_eanonuid'});
|
||||
}
|
||||
|
||||
if ($in{'anongid_def'}) { delete($opts{'anongid'}); }
|
||||
if ($in{'anongid_def'}) {
|
||||
delete($opts{'anongid'});
|
||||
}
|
||||
elsif ($in{'anongid'} =~ /^-?[0-9]+$/) {
|
||||
$opts{'anongid'} = $in{'anongid'}; }
|
||||
else { $opts{'anongid'} = getgrnam($in{'anongid'}); }
|
||||
$opts{'anongid'} = $in{'anongid'};
|
||||
}
|
||||
else {
|
||||
$opts{'anongid'} = getgrnam($in{'anongid'});
|
||||
$opts{'anongid'} || &error($text{'save_eanongid'});
|
||||
}
|
||||
|
||||
# NFSv2 specific options
|
||||
delete($opts{'link_relative'}); delete($opts{'link_absolute'});
|
||||
delete($opts{'link_relative'});
|
||||
delete($opts{'link_absolute'});
|
||||
delete($opts{'noaccess'});
|
||||
delete($opts{'squash_uids'});
|
||||
delete($opts{'squash_gids'});
|
||||
delete($opts{'map_daemon'});
|
||||
|
||||
if (nfs_max_version("localhost") == 2) {
|
||||
$opts{'link_relative'} = "" if ($in{'link_relative'});
|
||||
$opts{'noaccess'} = "" if ($in{'noaccess'});
|
||||
$opts{'link_relative'} = "" if ($in{'link_relative'});
|
||||
$opts{'noaccess'} = "" if ($in{'noaccess'});
|
||||
|
||||
if (!$in{'squash_uids_def'}) {
|
||||
if (!$in{'squash_uids_def'}) {
|
||||
if ($in{'squash_uids'} !~ /^[\d+\-\,]+$/) {
|
||||
&error($text{'save_euids'});
|
||||
} else {
|
||||
$opts{'squash_uids'} = $in{'squash_uids'};
|
||||
$opts{'map_daemon'} = "";
|
||||
&error($text{'save_euids'});
|
||||
}
|
||||
else {
|
||||
$opts{'squash_uids'} = $in{'squash_uids'};
|
||||
$opts{'map_daemon'} = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$in{'squash_gids_def'}) {
|
||||
if (!$in{'squash_gids_def'}) {
|
||||
if ($in{'squash_gids'} !~ /^[\d+\-\,]+$/) {
|
||||
&error($text{'save_egids'});
|
||||
} else {
|
||||
$opts{'squash_gids'} = $in{'squash_gids'};
|
||||
$opts{'map_daemon'} = "";
|
||||
&error($text{'save_egids'});
|
||||
}
|
||||
else {
|
||||
$opts{'squash_gids'} = $in{'squash_gids'};
|
||||
$opts{'map_daemon'} = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$exp{'options'} = \%opts;
|
||||
|
||||
# Create or update the export
|
||||
if ($in{'new'}) {
|
||||
if ($in{'via_pfs'} == 1) {
|
||||
&create_export_via_pfs(\%exp);
|
||||
} else {
|
||||
&create_export(\%exp);
|
||||
}
|
||||
} else {
|
||||
&modify_export(\%exp, $oldexp);
|
||||
if ($in{'via_pfs'} == 1) {
|
||||
&create_export_via_pfs(\%exp);
|
||||
}
|
||||
else {
|
||||
&create_export(\%exp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
&modify_export(\%exp, $oldexp);
|
||||
}
|
||||
}
|
||||
}
|
||||
&unlock_file($config{'exports_file'});
|
||||
|
||||
if ($in{'delete'}) {
|
||||
&webmin_log("delete", "export", $exp->{'dir'}, $exp);
|
||||
&webmin_log("delete", "export", $exp{'dir'}, \%exp);
|
||||
}
|
||||
elsif ($in{'new'}) {
|
||||
&webmin_log("create", "export", $exp{'dir'}, \%exp);
|
||||
|
||||
Reference in New Issue
Block a user