use File::chdir instead of Cwd
To avoid errors in taint mode.
This commit is contained in:
@ -2,7 +2,7 @@ package PVE::Storage::Plugin;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Cwd;
|
use File::chdir;
|
||||||
use File::Path;
|
use File::Path;
|
||||||
use PVE::Tools qw(run_command);
|
use PVE::Tools qw(run_command);
|
||||||
use PVE::JSONSchema qw(get_standard_option);
|
use PVE::JSONSchema qw(get_standard_option);
|
||||||
@ -506,10 +506,9 @@ sub clone_image {
|
|||||||
|
|
||||||
my $path = $class->path($scfg, $newvol);
|
my $path = $class->path($scfg, $newvol);
|
||||||
|
|
||||||
# Note: we use relative paths, so we need to call chdir before qemu-img
|
# Note: we use relative paths, so we need to call chdir before qemu-img
|
||||||
my $oldcwd = cwd();
|
|
||||||
eval {
|
eval {
|
||||||
chdir $imagedir;
|
local $CWD = $imagedir;
|
||||||
|
|
||||||
my $cmd = ['/usr/bin/qemu-img', 'create', '-b', "../$basevmid/$basename",
|
my $cmd = ['/usr/bin/qemu-img', 'create', '-b', "../$basevmid/$basename",
|
||||||
'-f', 'qcow2', $path];
|
'-f', 'qcow2', $path];
|
||||||
@ -518,8 +517,6 @@ sub clone_image {
|
|||||||
};
|
};
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
|
|
||||||
chdir $oldcwd;
|
|
||||||
|
|
||||||
die $err if $err;
|
die $err if $err;
|
||||||
|
|
||||||
return $newvol;
|
return $newvol;
|
||||||
|
|||||||
Reference in New Issue
Block a user