From: David Riley <d.riley@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: David Riley <d.riley@proxmox.com>
Subject: [PATCH pve-access-control 2/2] fix #7520: access-control: add SDN ACL cleanup helper
Date: Tue, 5 May 2026 16:22:07 +0200 [thread overview]
Message-ID: <20260505142207.2563052-3-d.riley@proxmox.com> (raw)
In-Reply-To: <20260505142207.2563052-1-d.riley@proxmox.com>
Add a helper to prune ACL nodes under the `/sdn/` path.
Traverse the internal tree to delete target nodes.
Signed-off-by: David Riley <d.riley@proxmox.com>
---
src/PVE/AccessControl.pm | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
index 10e1f27..fe0c7a8 100644
--- a/src/PVE/AccessControl.pm
+++ b/src/PVE/AccessControl.pm
@@ -1891,6 +1891,46 @@ sub roles {
return $roles;
}
+sub remove_sdn_resource_access {
+ # $paths is e.g. [ ['zones', '<zone>'], ['zones', '<zone>', '<vnet>'] ]
+ my ($paths) = @_;
+
+ my $delSDNResourceFn = sub {
+ my $usercfg = cfs_read_file("user.cfg");
+ my $modified = 0;
+
+ foreach my $segments (@$paths) {
+ my @full_path = ('sdn', @$segments);
+ my $current = $usercfg->{acl_root};
+ my $parent = undef;
+ my $last_key = undef;
+ my $found = 1;
+
+ foreach my $step (@full_path) {
+ if ($current->{children} && $current->{children}->{$step}) {
+ $parent = $current;
+ $last_key = $step;
+ $current = $current->{children}->{$step};
+ } else {
+ $found = 0;
+ last;
+ }
+ }
+
+ if ($found && $parent && $last_key) {
+ delete $parent->{children}->{$last_key};
+ $modified = 1;
+ }
+ }
+
+ if ($modified) {
+ cfs_write_file("user.cfg", $usercfg);
+ }
+ };
+
+ lock_user_config($delSDNResourceFn, "SDN ACL cleanup failed");
+}
+
sub remove_vm_access {
my ($vmid) = @_;
my $delVMaccessFn = sub {
--
2.47.3
prev parent reply other threads:[~2026-05-05 14:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 14:22 [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion David Riley
2026-05-05 14:22 ` [PATCH pve-network 1/2] " David Riley
2026-05-05 14:22 ` David Riley [this message]
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=20260505142207.2563052-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox