From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id F41EA1FF2C5 for ; Mon, 8 Jul 2024 13:55:59 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C56374B2C; Mon, 8 Jul 2024 13:56:20 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Mon, 8 Jul 2024 13:56:17 +0200 Message-Id: <20240708115617.58716-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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] [PATCH qemu-server] fix #5574: api: fix permission check for 'spice' usb port 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: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" With the last change in the permission check, I accidentally broke the check for 'spice' host value, since in the if/elsif/else this will fall through to the else case which was only intended for when neither 'host' nor 'mapping' was set. This made 'spice' only settable by root@pam since there we return early. To fix this, move the spice check into the 'host' branch, but only error out in case it's not spice. Fixes: e3971865 (enable cluster mapped USB devices for guests) Signed-off-by: Dominik Csapak --- PVE/API2/Qemu.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index efe69b5c..a3313f3a 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -661,8 +661,12 @@ my sub check_usb_perm { $rpcenv->check_vm_perm($authuser, $vmid, $pool, ['VM.Config.HWType']); my $device = PVE::JSONSchema::parse_property_string('pve-qm-usb', $value); - if ($device->{host} && $device->{host} !~ m/^spice$/i) { - die "only root can set '$opt' config for real devices\n"; + if ($device->{host}) { + if ($device->{host} =~ m/^spice$/i) { + # already checked generic permission above + } else { + die "only root can set '$opt' config for real devices\n"; + } } elsif ($device->{mapping}) { $rpcenv->check_full($authuser, "/mapping/usb/$device->{mapping}", ['Mapping.Use']); } else { -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel