From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 176911FF146 for ; Tue, 07 Jul 2026 14:05:21 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id DB63921442; Tue, 07 Jul 2026 14:05:20 +0200 (CEST) From: David Riley To: pve-devel@lists.proxmox.com Subject: [PATCH pve-access-control v5 4/7] permission: add helper to check for active permissions Date: Tue, 7 Jul 2026 14:04:01 +0200 Message-ID: <20260707120404.73072-5-d.riley@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260707120404.73072-1-d.riley@proxmox.com> References: <20260707120404.73072-1-d.riley@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783425898164 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.033 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: VVELBB2KEOX6T3EYVJUSMCL3RJ5FYREI X-Message-ID-Hash: VVELBB2KEOX6T3EYVJUSMCL3RJ5FYREI X-MailFrom: d.riley@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add recursive helper to determine if a specific node or any of its descendants in the ACL tree contain configured permissions. This is in preparation for subsequent SDN VNet ACL migration changes. Signed-off-by: David Riley --- src/PVE/AccessControl.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm index 8e2b4f2..1047226 100644 --- a/src/PVE/AccessControl.pm +++ b/src/PVE/AccessControl.pm @@ -977,6 +977,25 @@ sub iterate_acl_tree { } } +# recursively checks a node and all its children for active permissions +sub acl_tree_has_permissions { + my ($node) = @_; + + for my $key (keys %$node) { + if ($key ne 'children') { + return 1; + } + } + + for my $child_key (keys $node->{children}->%*) { + if (acl_tree_has_permissions($node->{children}->{$child_key})) { + return 1; + } + } + + return 0; +} + # find ACL node corresponding to normalized $path under $root sub find_acl_tree_node { my ($root, $path) = @_; -- 2.47.3