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 D7BCB1FF141 for ; Tue, 05 May 2026 16:22:46 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5D4A55543; Tue, 5 May 2026 16:22:44 +0200 (CEST) From: David Riley To: pve-devel@lists.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 Message-ID: <20260505142207.2563052-3-d.riley@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260505142207.2563052-1-d.riley@proxmox.com> References: <20260505142207.2563052-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: 1777990850540 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.398 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 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. [accesscontrol.pm] Message-ID-Hash: LR5M5YU4LHSTB3DRDPRYXYJPRPXZOXDA X-Message-ID-Hash: LR5M5YU4LHSTB3DRDPRYXYJPRPXZOXDA 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 CC: David Riley 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 a helper to prune ACL nodes under the `/sdn/` path. Traverse the internal tree to delete target nodes. Signed-off-by: David Riley --- 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', ''], ['zones', '', ''] ] + 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