From: Oguz Bektas <o.bektas@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v1 manager 4/5] change 'root@pam' checks with 'SuperUser' capability check
Date: Tue, 8 Feb 2022 14:10:10 +0100 [thread overview]
Message-ID: <20220208131011.752134-5-o.bektas@proxmox.com> (raw)
In-Reply-To: <20220208131011.752134-1-o.bektas@proxmox.com>
'root@pam' has the privilege by default (since it's an SA), so we can
drop the string comparisons all around and check that privilege instead
when deciding to enable/disable buttons or views
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
---
www/manager6/Utils.js | 3 ++-
www/manager6/dc/Config.js | 2 +-
www/manager6/dc/UserView.js | 2 +-
www/manager6/lxc/Options.js | 2 +-
www/manager6/lxc/Resources.js | 2 +-
www/manager6/node/Config.js | 2 +-
www/manager6/window/Migrate.js | 4 ++--
7 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index aafe359a..31ab94e8 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1656,7 +1656,8 @@ Ext.define('PVE.Utils', {
showCephInstallOrMask: function(container, msg, nodename, callback) {
if (msg.match(/not (installed|initialized)/i)) {
- if (Proxmox.UserName === 'root@pam') {
+ let caps = Ext.state.Manager.get('GuiCap');
+ if (caps.node.SuperUser) {
container.el.mask();
if (!container.down('pveCephInstallWindow')) {
var isInstalled = !!msg.match(/not initialized/i);
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 9c54b19d..917c426f 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -197,7 +197,7 @@ Ext.define('PVE.dc.Config', {
});
}
- if (Proxmox.UserName === 'root@pam') {
+ if (caps.dc.SuperUser) {
me.items.push({
xtype: 'pveACMEClusterView',
title: 'ACME',
diff --git a/www/manager6/dc/UserView.js b/www/manager6/dc/UserView.js
index bbfc4f7c..fe0c0149 100644
--- a/www/manager6/dc/UserView.js
+++ b/www/manager6/dc/UserView.js
@@ -29,7 +29,7 @@ Ext.define('PVE.dc.UserView', {
selModel: sm,
baseurl: '/access/users/',
dangerous: true,
- enableFn: rec => caps.access['User.Modify'] && rec.data.userid !== 'root@pam',
+ enableFn: rec => caps.access['User.Modify'] && !caps.access.SuperUser,
callback: () => reload(),
});
let run_editor = function() {
diff --git a/www/manager6/lxc/Options.js b/www/manager6/lxc/Options.js
index f2661dfc..f8eb8a5c 100644
--- a/www/manager6/lxc/Options.js
+++ b/www/manager6/lxc/Options.js
@@ -136,7 +136,7 @@ Ext.define('PVE.lxc.Options', {
features: {
header: gettext('Features'),
defaultValue: Proxmox.Utils.noneText,
- editor: Proxmox.UserName === 'root@pam' || caps.vms['VM.Allocate']
+ editor: caps.vms.SuperUser || caps.vms['VM.Allocate']
? 'PVE.lxc.FeaturesEdit' : undefined,
},
hookscript: {
diff --git a/www/manager6/lxc/Resources.js b/www/manager6/lxc/Resources.js
index 15ee3c67..2081b4a2 100644
--- a/www/manager6/lxc/Resources.js
+++ b/www/manager6/lxc/Resources.js
@@ -257,7 +257,7 @@ Ext.define('PVE.lxc.RessourceView', {
var isUsedDisk = isDisk && !isUnusedDisk;
var noedit = rec.data.delete || !rowdef.editor;
- if (!noedit && Proxmox.UserName !== 'root@pam' && key.match(/^mp\d+$/)) {
+ if (!noedit && !caps.vms.SuperUser && key.match(/^mp\d+$/)) {
var mp = PVE.Parser.parseLxcMountPoint(value);
if (mp.type !== 'volume') {
noedit = true;
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index 68f80391..9f49f0dd 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -236,7 +236,7 @@ Ext.define('PVE.node.Config', {
itemId: 'apt',
upgradeBtn: {
xtype: 'pveConsoleButton',
- disabled: Proxmox.UserName !== 'root@pam',
+ disabled: !caps.nodes.SuperUser,
text: gettext('Upgrade'),
consoleType: 'upgrade',
nodename: nodename,
diff --git a/www/manager6/window/Migrate.js b/www/manager6/window/Migrate.js
index 1c23abb3..20fcf81d 100644
--- a/www/manager6/window/Migrate.js
+++ b/www/manager6/window/Migrate.js
@@ -52,8 +52,8 @@ Ext.define('PVE.window.Migrate', {
}
},
setLocalResourceCheckboxHidden: function(get) {
- if (get('running') || !get('migration.hasLocalResources') ||
- Proxmox.UserName !== 'root@pam') {
+ let caps = Ext.state.Manager.get('GuiCap');
+ if (get('running') || !get('migration.hasLocalResources') || caps.vms.SuperUser) {
return true;
} else {
return false;
--
2.30.2
next prev parent reply other threads:[~2022-02-08 13:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 13:10 [pve-devel] [PATCH v1 access-control++ 0/5] SuperUser privilege Oguz Bektas
2022-02-08 13:10 ` [pve-devel] [PATCH v1 access-control 1/5] add default "SuperAdministrator" role with the new "SuperUser" privilege Oguz Bektas
2022-02-08 13:10 ` [pve-devel] [PATCH v1 access-control 2/5] tfa: allow superusers to edit root@pam tfa Oguz Bektas
[not found] ` <<20220208131011.752134-3-o.bektas@proxmox.com>
2022-02-10 15:30 ` Fabian Grünbichler
2022-02-08 13:10 ` [pve-devel] [PATCH v1 container 3/5] fix #2582: api: add checks for 'SuperUser' privilege for root-only options Oguz Bektas
[not found] ` <<20220208131011.752134-4-o.bektas@proxmox.com>
2022-02-10 15:30 ` Fabian Grünbichler
2022-02-08 13:10 ` Oguz Bektas [this message]
[not found] ` <<20220208131011.752134-5-o.bektas@proxmox.com>
2022-02-10 15:29 ` [pve-devel] [PATCH v1 manager 4/5] change 'root@pam' checks with 'SuperUser' capability check Fabian Grünbichler
2022-02-25 10:13 ` Dominik Csapak
2022-02-25 12:24 ` Thomas Lamprecht
2022-02-08 13:10 ` [pve-devel] [PATCH v1 qemu-server 5/5] add SuperUser privilege checks for root-only options Oguz Bektas
[not found] ` <<20220208131011.752134-6-o.bektas@proxmox.com>
2022-02-10 15:29 ` Fabian Grünbichler
2022-02-10 15:28 ` [pve-devel] [PATCH v1 access-control++ 0/5] SuperUser privilege Fabian Grünbichler
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=20220208131011.752134-5-o.bektas@proxmox.com \
--to=o.bektas@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 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.