]> git.proxmox.com Git - qemu-server.git/commitdiff
api: deletion: check also pending values for serial/usb
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 23 Sep 2019 08:50:21 +0000 (10:50 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 23 Sep 2019 09:24:57 +0000 (11:24 +0200)
otherwise a user with only VM.Config.HWType cannot
delete a 'pending' usbX: spice or serial: socket option

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/API2/Qemu.pm

index 3355c8b28f340029c7bb7159f1436126326f5dd8..5814f941dc4967710c762529f5268e14ab99e1c0 100644 (file)
@@ -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+$/) {
                    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";
                        $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+$/) {
                    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";
                        $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";