From f9be9137fc87bd69e7f703a6c39d3475486db324 Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Wed, 30 Mar 2022 12:24:37 +0200 Subject: [PATCH] api: create/modify: add content type checks Signed-off-by: Fabian Ebner --- PVE/API2/Qemu.pm | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index cb6973f1..1dd0cf28 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -104,7 +104,14 @@ my $check_storage_access = sub { raise_param_exc({ storage => "storage '$storeid' does not support vm images"}) if !$scfg->{content}->{images}; } else { - PVE::Storage::check_volume_access($rpcenv, $authuser, $storecfg, $vmid, $volid); + PVE::Storage::check_volume_access( + $rpcenv, + $authuser, + $storecfg, + $vmid, + $volid, + 'images', + ); } }); @@ -230,7 +237,14 @@ my $create_disks = sub { delete $disk->{format}; # no longer needed $res->{$ds} = PVE::QemuServer::print_drive($disk); } else { - PVE::Storage::check_volume_access($rpcenv, $authuser, $storecfg, $vmid, $volid); + PVE::Storage::check_volume_access( + $rpcenv, + $authuser, + $storecfg, + $vmid, + $volid, + 'images', + ); PVE::Storage::activate_volumes($storecfg, [ $volid ]) if $storeid; @@ -645,7 +659,14 @@ __PACKAGE__->register_method({ die "pipe requires cli environment\n" if $rpcenv->{type} ne 'cli'; $archive = { type => 'pipe' }; } else { - PVE::Storage::check_volume_access($rpcenv, $authuser, $storecfg, $vmid, $archive); + PVE::Storage::check_volume_access( + $rpcenv, + $authuser, + $storecfg, + $vmid, + $archive, + 'backup', + ); $archive = $parse_restore_archive->($storecfg, $archive); }