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 4D15E1FF0E9 for ; Thu, 16 Jul 2026 12:44:27 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 082AC2143A; Thu, 16 Jul 2026 12:44:26 +0200 (CEST) From: David Riley To: pve-devel@lists.proxmox.com Subject: [PATCH pve-access-control v6 2/8] fix #7520: sdn: add pruning SDN resources ACLs Date: Thu, 16 Jul 2026 12:42:41 +0200 Message-ID: <20260716104247.29047-3-d.riley@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260716104247.29047-1-d.riley@proxmox.com> References: <20260716104247.29047-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: 1784198613505 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.168 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) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust 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: 74MFXUQO54Y2SJ6FVDJLVFQKCB2A2CMW X-Message-ID-Hash: 74MFXUQO54Y2SJ6FVDJLVFQKCB2A2CMW 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 a cleanup routine to remove ACLs under the '/sdn/' path when the corresponding resources are deleted. This is a preparatory change that does not have an immediate effect on its own, but lays the foundation for preventing dangling permission states and ensures configuration consistency. Signed-off-by: David Riley Reviewed-by: Stefan Hanreich Tested-by: Stefan Hanreich Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7520 --- src/PVE/AccessControl.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm index a47495e..9ad7c40 100644 --- a/src/PVE/AccessControl.pm +++ b/src/PVE/AccessControl.pm @@ -2005,6 +2005,33 @@ sub remove_vm_from_pool { lock_user_config($delVMfromPoolFn, "pool cleanup for VM $vmid failed"); } +sub remove_sdn_resource_access { + my ($paths) = @_; # [ 'zones/', 'zones//' ] + + my $delete_resource_fn = sub { + my $usercfg = cfs_read_file("user.cfg"); + my $modified = 0; + + for my $path (@$paths) { + my $full_path = "sdn/$path"; + + my $current = $usercfg->{acl_root}; + my ($parent, $last_key) = find_acl_tree_node_parent($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"); +} + my $USER_CONTROLLED_TFA_TYPES = { u2f => 1, oath => 1, -- 2.47.3