X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PVE%2FAPI2%2FQemu.pm;h=cd63cfba4c07a3177259adad326a2d2517d4c627;hb=5b9d692ae7765e2dd0bf07e773f2fe31778191f9;hp=957a39881b55405b013c730c6d4cb4286b627486;hpb=bc4dcb99a1e12d4d991d668ebec111508dbac487;p=qemu-server.git diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 957a398..cd63cfb 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -2,6 +2,7 @@ package PVE::API2::Qemu; use strict; use warnings; +use Cwd 'abs_path'; use PVE::Cluster; use PVE::SafeSyslog; @@ -145,8 +146,20 @@ __PACKAGE__->register_method({ my $keystr = join(' ', keys %$param); raise_param_exc({ archive => "option conflicts with other options ($keystr)"}) if $keystr; - die "pipe requires cli environment\n" - if $archive eq '-' && $rpcenv->{type} ne 'cli'; + if ($archive eq '-') { + die "pipe requires cli environment\n" + && $rpcenv->{type} ne 'cli'; + } else { + if (PVE::Storage::parse_volume_id($archive, 1)) { + $archive = PVE::Storage::path($storecfg, $archive); + } else { + raise_param_exc({ archive => "Only root can pass arbitrary paths." }) + if $user ne 'root@pam'; + + $archive = abs_path($archive); + } + die "can't find file '$archive'\n" if ! -f $archive; + } } my $restorefn = sub {