all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: David Riley <d.riley@proxmox.com>
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	[thread overview]
Message-ID: <20260707120404.73072-5-d.riley@proxmox.com> (raw)
In-Reply-To: <20260707120404.73072-1-d.riley@proxmox.com>

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 <d.riley@proxmox.com>
---
 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





  parent reply	other threads:[~2026-07-07 12:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 12:03 [PATCH access-control/network v5 0/7] fix #7520: sdn: prune orphaned ACLs and handle VNet migrations David Riley
2026-07-07 12:03 ` [PATCH pve-access-control v5 1/7] permission: add acl tree node parent lookup without node creation David Riley
2026-07-07 12:03 ` [PATCH pve-access-control v5 2/7] fix #7520: sdn: add pruning SDN resources ACLs David Riley
2026-07-07 12:04 ` [PATCH pve-access-control v5 3/7] test: add sdn acl pruning tests David Riley
2026-07-07 12:04 ` David Riley [this message]
2026-07-07 12:04 ` [PATCH pve-access-control v5 5/7] fix #7520: sdn: add VNet ACL migration David Riley
2026-07-07 12:04 ` [PATCH pve-access-control v5 6/7] test: add sdn acl migration tests David Riley
2026-07-07 12:04 ` [PATCH pve-network v5 7/7] fix #7520: config: prune orphaned and relocate moved VNet ACLs David Riley

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=20260707120404.73072-5-d.riley@proxmox.com \
    --to=d.riley@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal