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 19EF11FF16F for ; Fri, 29 Nov 2024 09:59:57 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4500A14053; Fri, 29 Nov 2024 09:59:57 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Date: Fri, 29 Nov 2024 09:59:08 +0100 Message-Id: <20241129085908.44049-1-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.007 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [notifications.pm, proxmox.com, rpcenvironment.pm] Subject: [pve-devel] [PATCH pve-manager] api: notification targets: fix permission check for POST/PUT 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" This fixes the error: unknown permission test at /usr/share/perl5/PVE/RPCEnvironment.pm line 536. (500) which occured when trying to create or update a notification target. The cause was a permission 'check' parameter for the API handlers which was nested one level too deep by accident. This regression was introduced in a previous commit which raised the needed permissions for notification target management. It likely went unnoticed because the permission check is skipped for root@pam, so the error occurs only if using another user. Reported in the community forum: https://forum.proxmox.com/threads/158101 Fixes: a3fe9c54 ("api: notifications: require powerful privileges for target management") Signed-off-by: Lukas Wagner --- PVE/API2/Cluster/Notifications.pm | 96 +++++++++++++------------------ 1 file changed, 40 insertions(+), 56 deletions(-) diff --git a/PVE/API2/Cluster/Notifications.pm b/PVE/API2/Cluster/Notifications.pm index 50ee5662..a61ab839 100644 --- a/PVE/API2/Cluster/Notifications.pm +++ b/PVE/API2/Cluster/Notifications.pm @@ -500,13 +500,11 @@ __PACKAGE__->register_method ({ method => 'POST', description => 'Create a new sendmail endpoint', permissions => { - check => [ - ['and', - ['perm', '/mapping/notifications', ['Mapping.Modify']], - ['or', - ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], - ['perm', '/', [ 'Sys.AccessNetwork' ]], - ], + check => ['and', + ['perm', '/mapping/notifications', ['Mapping.Modify']], + ['or', + ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + ['perm', '/', [ 'Sys.AccessNetwork' ]], ], ], }, @@ -556,13 +554,11 @@ __PACKAGE__->register_method ({ method => 'PUT', description => 'Update existing sendmail endpoint', permissions => { - check => [ - ['and', - ['perm', '/mapping/notifications', ['Mapping.Modify']], - ['or', - ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], - ['perm', '/', [ 'Sys.AccessNetwork' ]], - ], + check => ['and', + ['perm', '/mapping/notifications', ['Mapping.Modify']], + ['or', + ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + ['perm', '/', [ 'Sys.AccessNetwork' ]], ], ], }, @@ -780,13 +776,11 @@ __PACKAGE__->register_method ({ method => 'POST', description => 'Create a new gotify endpoint', permissions => { - check => [ - ['and', - ['perm', '/mapping/notifications', ['Mapping.Modify']], - ['or', - ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], - ['perm', '/', [ 'Sys.AccessNetwork' ]], - ], + check => ['and', + ['perm', '/mapping/notifications', ['Mapping.Modify']], + ['or', + ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + ['perm', '/', [ 'Sys.AccessNetwork' ]], ], ], }, @@ -832,13 +826,11 @@ __PACKAGE__->register_method ({ method => 'PUT', description => 'Update existing gotify endpoint', permissions => { - check => [ - ['and', - ['perm', '/mapping/notifications', ['Mapping.Modify']], - ['or', - ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], - ['perm', '/', [ 'Sys.AccessNetwork' ]], - ], + check => ['and', + ['perm', '/mapping/notifications', ['Mapping.Modify']], + ['or', + ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + ['perm', '/', [ 'Sys.AccessNetwork' ]], ], ], }, @@ -1099,13 +1091,11 @@ __PACKAGE__->register_method ({ method => 'POST', description => 'Create a new smtp endpoint', permissions => { - check => [ - ['and', - ['perm', '/mapping/notifications', ['Mapping.Modify']], - ['or', - ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], - ['perm', '/', [ 'Sys.AccessNetwork' ]], - ], + check => ['and', + ['perm', '/mapping/notifications', ['Mapping.Modify']], + ['or', + ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + ['perm', '/', [ 'Sys.AccessNetwork' ]], ], ], }, @@ -1165,13 +1155,11 @@ __PACKAGE__->register_method ({ method => 'PUT', description => 'Update existing smtp endpoint', permissions => { - check => [ - ['and', - ['perm', '/mapping/notifications', ['Mapping.Modify']], - ['or', - ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], - ['perm', '/', [ 'Sys.AccessNetwork' ]], - ], + check => ['and', + ['perm', '/mapping/notifications', ['Mapping.Modify']], + ['or', + ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + ['perm', '/', [ 'Sys.AccessNetwork' ]], ], ], }, @@ -1423,13 +1411,11 @@ __PACKAGE__->register_method ({ method => 'POST', description => 'Create a new webhook endpoint', permissions => { - check => [ - ['and', - ['perm', '/mapping/notifications', ['Mapping.Modify']], - ['or', - ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], - ['perm', '/', [ 'Sys.AccessNetwork' ]], - ], + check => ['and', + ['perm', '/mapping/notifications', ['Mapping.Modify']], + ['or', + ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + ['perm', '/', [ 'Sys.AccessNetwork' ]], ], ], }, @@ -1464,13 +1450,11 @@ __PACKAGE__->register_method ({ method => 'PUT', description => 'Update existing webhook endpoint', permissions => { - check => [ - ['and', - ['perm', '/mapping/notifications', ['Mapping.Modify']], - ['or', - ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], - ['perm', '/', [ 'Sys.AccessNetwork' ]], - ], + check => ['and', + ['perm', '/mapping/notifications', ['Mapping.Modify']], + ['or', + ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + ['perm', '/', [ 'Sys.AccessNetwork' ]], ], ], }, -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel