vzdump: move restricted API parameters check

for better visibility and earlier error detection
This commit is contained in:
Fabian Grünbichler 2016-10-12 15:30:20 +02:00 committed by Dietmar Maurer
parent b89cb3a628
commit a92ef54134

View File

@ -56,6 +56,11 @@ __PACKAGE__->register_method ({
if $param->{stdout};
}
foreach my $key (qw(maxfiles tmpdir dumpdir script bwlimit ionice)) {
raise_param_exc({ $key => "Only root may set this option."})
if defined($param->{$key}) && ($user ne 'root@pam');
}
# by default we set --rsyncable for gzip
local $ENV{GZIP} = "--rsyncable" if !$ENV{GZIP};
@ -112,11 +117,6 @@ __PACKAGE__->register_method ({
die "you can only backup a single VM with option --stdout\n"
if $param->{stdout} && scalar(@vmids) != 1;
foreach my $key (qw(maxfiles tmpdir dumpdir script bwlimit ionice)) {
raise_param_exc({ $key => "Only root may set this option."})
if defined($param->{$key}) && ($user ne 'root@pam');
}
$rpcenv->check($user, "/storage/$param->{storage}", [ 'Datastore.AllocateSpace' ])
if $param->{storage};