[pve-devel] [PATCH qemu-server 2/2] fix #2175: PVE/API2/Qemu: update_vm_api: check old drive for permissions too

Dominik Csapak d.csapak at proxmox.com
Thu Jun 24 16:25:11 CEST 2021


otherwise a user with only VM.Config.CDROM can detach a disk from a VM
by updating it to a cdrom drive

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
this is breaking api change, but fits more in line what we would
want for the permissions

 PVE/API2/Qemu.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 057b8ff..1e540f5 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1346,6 +1346,12 @@ my $update_vm_api  = sub {
 		my $arch = PVE::QemuServer::get_vm_arch($conf);
 
 		if (PVE::QemuServer::is_valid_drivename($opt)) {
+		    # old drive
+		    if ($conf->{$opt}) {
+			$check_drive_perms->($opt, $conf->{$opt});
+		    }
+
+		    # new drive
 		    $check_drive_perms->($opt, $param->{$opt});
 		    PVE::QemuServer::vmconfig_register_unused_drive($storecfg, $vmid, $conf, PVE::QemuServer::parse_drive($opt, $conf->{pending}->{$opt}))
 			if defined($conf->{pending}->{$opt});
-- 
2.20.1






More information about the pve-devel mailing list