all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH v2 manager] ui: lxc options: disable features edit as non-root when container is privileged
@ 2021-08-13  9:10 Fabian Ebner
  2022-03-16 15:24 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Ebner @ 2021-08-13  9:10 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH v2 manager] ui: lxc options: disable features edit as non-root when container is privileged
  2021-08-13  9:10 [pve-devel] [PATCH v2 manager] ui: lxc options: disable features edit as non-root when container is privileged Fabian Ebner
@ 2022-03-16 15:24 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2022-03-16 15:24 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Ebner

On 13.08.21 11:10, Fabian Ebner wrote:
> 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(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-16 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-13  9:10 [pve-devel] [PATCH v2 manager] ui: lxc options: disable features edit as non-root when container is privileged Fabian Ebner
2022-03-16 15:24 ` [pve-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal