From: Friedrich Weber <f.weber@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] ui: qemu: hardware view: fix hwrng cap check for unprivileged users
Date: Tue, 8 Apr 2025 18:38:56 +0200 [thread overview]
Message-ID: <20250408163856.116576-1-f.weber@proxmox.com> (raw)
Currently, as an unprivileged user with role PVEVMUser the GUI breaks
with an error after navigating to a VM's hardware tab. The reason is
that the frontend checks the GUI capabilites via `caps.mapping.hwrng`,
but `caps.mapping` does not actually have a property called `hwrng`.
The reason this does not trigger for more privileged users is that all
expressions involving `caps.mapping.hwrng` are short-circuited if the
user has privilege `VM.Config.Type`, so `caps.mapping.hwrng` is never
evaluated.
Fixes: a47a8afb ("ui: let non-root users configure VirtIO RNG devices")
Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
Notes:
I wasn't actually sure whether `caps` may have such a 2-level structure
in some cases, but it doesn't seem like it. After applying this patch
to pve-manager:
% ag 'caps\.[^\[.]+\.' | wc -l
0
www/manager6/qemu/HardwareView.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js
index 4ce9908c..b949264f 100644
--- a/www/manager6/qemu/HardwareView.js
+++ b/www/manager6/qemu/HardwareView.js
@@ -316,8 +316,8 @@ Ext.define('PVE.qemu.HardwareView', {
rows.rng0 = {
group: 45,
tdCls: 'pve-itype-icon-die',
- editor: caps.vms['VM.Config.HWType'] || caps.mapping.hwrng['Mapping.Use'] ? 'PVE.qemu.RNGEdit' : undefined,
- never_delete: !caps.vms['VM.Config.HWType'] && !caps.mapping.hwrng['Mapping.Use'],
+ editor: caps.vms['VM.Config.HWType'] || caps.mapping['Mapping.Use'] ? 'PVE.qemu.RNGEdit' : undefined,
+ never_delete: !caps.vms['VM.Config.HWType'] && !caps.mapping['Mapping.Use'],
header: gettext("VirtIO RNG"),
};
for (let i = 0; i < PVE.Utils.hardware_counts.virtiofs; i++) {
@@ -757,7 +757,7 @@ Ext.define('PVE.qemu.HardwareView', {
text: gettext("VirtIO RNG"),
itemId: 'addRng',
iconCls: 'pve-itype-icon-die',
- disabled: !caps.vms['VM.Config.HWType'] && !caps.mapping.hwrng['Mapping.Use'],
+ disabled: !caps.vms['VM.Config.HWType'] && !caps.mapping['Mapping.Use'],
handler: editorFactory('RNGEdit'),
},
{
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next reply other threads:[~2025-04-08 16:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 16:38 Friedrich Weber [this message]
2025-04-08 16:51 ` Stefan Hanreich
2025-04-08 16:54 ` Friedrich Weber
2025-04-08 17:59 ` Stoiko Ivanov
2025-04-08 18:27 ` [pve-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250408163856.116576-1-f.weber@proxmox.com \
--to=f.weber@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal