public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 manager] ui: lxc options: disable features edit as non-root when container is privileged
Date: Fri, 13 Aug 2021 11:10:12 +0200	[thread overview]
Message-ID: <20210813091012.29410-1-f.ebner@proxmox.com> (raw)

The backend won't allow any edits in this case, so better just disable
the edit button altogether.

Co-developed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

Changes from v1:
    * split cases based on 'key'
    * keep logic for {dis,en}abling edit button for features in one
      place

 www/manager6/lxc/Options.js | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/www/manager6/lxc/Options.js b/www/manager6/lxc/Options.js
index f2661dfc..d0a53fc7 100644
--- a/www/manager6/lxc/Options.js
+++ b/www/manager6/lxc/Options.js
@@ -136,8 +136,7 @@ Ext.define('PVE.lxc.Options', {
 	    features: {
 		header: gettext('Features'),
 		defaultValue: Proxmox.Utils.noneText,
-		editor: Proxmox.UserName === 'root@pam' || caps.vms['VM.Allocate']
-		    ? 'PVE.lxc.FeaturesEdit' : undefined,
+		editor: 'PVE.lxc.FeaturesEdit',
 	    },
 	    hookscript: {
 		header: gettext('Hookscript'),
@@ -174,7 +173,15 @@ Ext.define('PVE.lxc.Options', {
 	    var pending = rec.data.delete || me.hasPendingChanges(key);
 	    var rowdef = rows[key];
 
-	    edit_btn.setDisabled(!rowdef.editor);
+	    if (key === 'features') {
+		let unprivileged = me.getStore().getById('unprivileged').data.value;
+		let root = Proxmox.UserName === 'root@pam';
+		let vmalloc = caps.vms['VM.Allocate'];
+		edit_btn.setDisabled(!(root || (vmalloc && unprivileged)));
+	    } else {
+		edit_btn.setDisabled(!rowdef.editor);
+	    }
+
 	    revert_btn.setDisabled(!pending);
 	};
 
-- 
2.30.2





             reply	other threads:[~2021-08-13  9:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13  9:10 Fabian Ebner [this message]
2022-03-16 15:24 ` [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=20210813091012.29410-1-f.ebner@proxmox.com \
    --to=f.ebner@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