From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6976768F83 for ; Mon, 22 Feb 2021 17:40:40 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 50A0ECBCF for ; Mon, 22 Feb 2021 17:40:10 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 227C3CBBF for ; Mon, 22 Feb 2021 17:40:09 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E3D7A44F98 for ; Mon, 22 Feb 2021 17:40:08 +0100 (CET) Message-ID: <85079f1e-8d88-c6d0-d6f1-ad86fbf8d02d@proxmox.com> Date: Mon, 22 Feb 2021 17:40:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Thunderbird/86.0 Content-Language: en-US To: Proxmox VE development discussion , Aaron Lauterer References: <20210212155751.16045-1-a.lauterer@proxmox.com> <20210212155751.16045-4-a.lauterer@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20210212155751.16045-4-a.lauterer@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.057 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] applied: [PATCH v2 qemu-server] API: update_vm_api: check for CDROM on disk delete X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Feb 2021 16:40:40 -0000 On 12.02.21 16:57, Aaron Lauterer wrote: > Since CDRoms and disks share the same config keys, we need to check if > it actually is a CDRom and then check the permissions accordingly. > > Otherwise it is possible for someone without VM.Config.CDROM > permissions, but with VM.Config.Disk permissions to remove a CD drive > while being unable to create a CDRom drive. > > Signed-off-by: Aaron Lauterer > --- > > Since it is possible to delete a CDRom while not having the permissions > to create them, I consider this a bug. > > With this patch it is also possible to now remove a CDRom drive with > only the VM.Config.CDROM permissions which needed VM.Config.Disk > permissions before. Creating them with the CDRom permissions has already > been possible before. > > PVE/API2/Qemu.pm | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > applied, thanks! For the record: technically this is, in the widest sense, a backward incompatible change and I even had a commit here prepared which would allow any of those permissions (see below), but I dropped it, this is such a niche use case that I just cannot believe that anybody will be affected by it - one needs to have CDROM for adding, so basically a CDROM dev would need to be there, then a user with a role containing 'VM.Config.Disk' but *not* 'VM.Config.CDROM', whom only needs to remove CDROM devices but not add them, cannot do that anymore, yeah, no, really not worth the hassle. obsoleted dropped diff for the record only: diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index feb9ea8..c932571 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1237,7 +1237,8 @@ my $update_vm_api = sub { PVE::QemuConfig->check_protection($conf, "can't remove drive '$opt'"); my $drive = PVE::QemuServer::parse_drive($opt, $val); if (PVE::QemuServer::drive_is_cdrom($drive)) { - $rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.CDROM']); + # FIXME: remove 'VM.Config.Disk' and $any flag for PVE 7 + $rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.CDROM', 'VM.Config.Disk'], 1); } else { $rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.Disk']); }