From: Dominik Csapak Date: Mon, 23 Sep 2019 08:50:21 +0000 (+0200) Subject: api: deletion: check also pending values for serial/usb X-Git-Url: https://git.proxmox.com/?p=qemu-server.git;a=commitdiff_plain;h=4c1f3929eabf4a118ef7109938eb2c9088332c60 api: deletion: check also pending values for serial/usb otherwise a user with only VM.Config.HWType cannot delete a 'pending' usbX: spice or serial: socket option Signed-off-by: Dominik Csapak --- diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 3355c8b..5814f94 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1202,7 +1202,7 @@ my $update_vm_api = sub { PVE::QemuServer::vmconfig_delete_pending_option($conf, $opt, $force); PVE::QemuConfig->write_config($vmid, $conf); } elsif ($opt =~ m/^serial\d+$/) { - if ($conf->{$opt} eq 'socket') { + if ($conf->{$opt} eq 'socket' || (!$conf->{$opt} && $conf->{pending}->{$opt} eq 'socket')) { $rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.HWType']); } elsif ($authuser ne 'root@pam') { die "only root can delete '$opt' config for real devices\n"; @@ -1210,7 +1210,7 @@ my $update_vm_api = sub { PVE::QemuServer::vmconfig_delete_pending_option($conf, $opt, $force); PVE::QemuConfig->write_config($vmid, $conf); } elsif ($opt =~ m/^usb\d+$/) { - if ($conf->{$opt} =~ m/spice/) { + if ($conf->{$opt} =~ m/spice/ || (!$conf->{$opt} && $conf->{pending}->{$opt} =~ m/spice/)) { $rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.HWType']); } elsif ($authuser ne 'root@pam') { die "only root can delete '$opt' config for real devices\n";