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 v3 1/5] fix: #7520: sdn: prune orphaned ACLs on resource deletion
Date: Wed, 3 Jun 2026 16:55:19 +0200 [thread overview]
Message-ID: <20260603145523.120075-2-d.riley@proxmox.com> (raw)
In-Reply-To: <20260603145523.120075-1-d.riley@proxmox.com>
Add a helper routine to prune ACL entries under the '/sdn/' path when
the corresponding resources are deleted. Compare the running
configuration against the newly compiled state during config commit.
This prevents dangling permission states and ensures configuration
consistency across manual API/UI applies as well as automatic reloads
during system boot.
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7520
Signed-off-by: David Riley <d.riley@proxmox.com>
---
src/PVE/AccessControl.pm | 46 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
index 0d632b3..7581394 100644
--- a/src/PVE/AccessControl.pm
+++ b/src/PVE/AccessControl.pm
@@ -1974,6 +1974,52 @@ sub remove_vm_from_pool {
lock_user_config($delVMfromPoolFn, "pool cleanup for VM $vmid failed");
}
+sub remove_sdn_resource_access {
+ my ($paths) = @_; # [ ['zones', '<zone>'], ['zones', '<zone>', '<vnet>'] ]
+
+ my $delete_resource_fn = 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, $last_key) = lookup_acl_node($current, \@full_path);
+
+ if ($parent && $last_key) {
+ delete $parent->{children}->{$last_key};
+ $modified = 1;
+ }
+ }
+
+ if ($modified) {
+ cfs_write_file("user.cfg", $usercfg);
+ }
+ };
+
+ lock_user_config($delete_resource_fn, "SDN ACL cleanup failed");
+}
+
+sub lookup_acl_node {
+ my ($root, $path) = @_;
+
+ my $current = $root;
+ my $parent = undef;
+ my $last_key = undef;
+
+ foreach my $step (@$path) {
+ if ($current->{children} && $current->{children}->{$step}) {
+ $parent = $current;
+ $last_key = $step;
+ $current = $current->{children}->{$step};
+ } else {
+ return;
+ }
+ }
+
+ return ($parent, $last_key, $current);
+}
+
my $USER_CONTROLLED_TFA_TYPES = {
u2f => 1,
oath => 1,
--
2.47.3
next prev parent reply other threads:[~2026-06-03 14:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 14:55 [PATCH access-control/network v3 0/5] fix #7520: sdn: prune orphaned ACLs and handle VNet migrations David Riley
2026-06-03 14:55 ` David Riley [this message]
2026-06-03 14:55 ` [PATCH pve-access-control v3 2/5] fix #7520: test: add unit tests for sdn acl pruning logic David Riley
2026-06-03 14:55 ` [PATCH pve-access-control v3 3/5] fix: #7520: sdn: add VNet ACL migration David Riley
2026-06-03 14:55 ` [PATCH pve-access-control v3 4/5] fix #7520: test: add unit tests for sdn acl migration logic David Riley
2026-06-03 14:55 ` [PATCH pve-network v3 5/5] fix #7520: config: prune orphaned ACLs and relocate moved VNets 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=20260603145523.120075-2-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