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 7A7C81FF0E3 for ; Tue, 21 Jul 2026 16:40:43 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 801F421469; Tue, 21 Jul 2026 16:40:42 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 21 Jul 2026 16:40:37 +0200 Message-Id: Subject: Re: [PATCH access-control 1/2] fix #6510: api: acl: allow deleting ACLs for non-existent entities From: "Daniel Kral" To: "Elias Huhsovitz" , X-Mailer: aerc 0.21.0-147-g43ac7b685014-dirty References: <20260720134535.136172-1-e.huhsovitz@proxmox.com> <20260720134535.136172-2-e.huhsovitz@proxmox.com> In-Reply-To: <20260720134535.136172-2-e.huhsovitz@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1784644811501 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.218 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: HLJJCQEDKT2FFTLHGRHQ5Y4UDP3EAYFW X-Message-ID-Hash: HLJJCQEDKT2FFTLHGRHQ5Y4UDP3EAYFW X-MailFrom: d.kral@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: On Mon Jul 20, 2026 at 3:45 PM CEST, Elias Huhsovitz wrote: > When a user, group, or API token is deleted, the system usually cleans > up the associated ACLs. However, edge cases like > manual configuration edits can leave orphaned ACL entries in the > cluster configuration. > > Currently, the `update_acl` API endpoint strictly validates the > existence of the target entity before processing any request. If the > entity is missing, the API throws an error (e.g., "user 'foo@pve' does > not exist") and aborts the operation. This prevents administrators from > cleaning up leftover ACLs through the API. > > Bypass the existence check when the `delete` flag is set. This change > allows the API to remove orphaned ACL entries. > > Signed-off-by: Elias Huhsovitz > --- > src/PVE/API2/ACL.pm | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/src/PVE/API2/ACL.pm b/src/PVE/API2/ACL.pm > index c57dd38..01329f7 100644 > --- a/src/PVE/API2/ACL.pm > +++ b/src/PVE/API2/ACL.pm > @@ -224,7 +224,7 @@ __PACKAGE__->register_method({ > foreach my $group (split_list($param->{groups})) { > =20 > die "group '$group' does not exist\n" > - if !$cfg->{groups}->{$group}; > + if !$param->{delete} && !$cfg->{groups}->{$g= roup}; > =20 > if ($param->{delete}) { > delete($node->{groups}->{$group}->{$role}); > @@ -237,7 +237,7 @@ __PACKAGE__->register_method({ > my $username =3D PVE::AccessControl::verify_user= name($userid); > =20 > die "user '$username' does not exist\n" > - if !$cfg->{users}->{$username}; > + if !$param->{delete} && !$cfg->{users}->{$us= ername}; > =20 > if ($param->{delete}) { > delete($node->{users}->{$username}->{$role})= ; > @@ -248,7 +248,7 @@ __PACKAGE__->register_method({ > =20 > foreach my $tokenid (split_list($param->{tokens})) { > my ($username, $token) =3D PVE::AccessControl::s= plit_tokenid($tokenid); > - PVE::AccessControl::check_token_exist($cfg, $use= rname, $token); > + PVE::AccessControl::check_token_exist($cfg, $use= rname, $token) if !$param->{delete}; This line is a bit too long, please run `make tidy` on the individual patches before sending. > =20 > if ($param->{delete}) { > delete $node->{tokens}->{$tokenid}->{$role}; Otherwise, this looks good to me and works as expected testing with some ACLs and removing non-existing users, groups or tokens from ACL paths, so modulo the make tidy consider this as: Reviewed-by: Daniel Kral Tested-by: Daniel Kral