From: "Daniel Kral" <d.kral@proxmox.com>
To: "Elias Huhsovitz" <e.huhsovitz@proxmox.com>,
<pve-devel@lists.proxmox.com>
Subject: Re: [PATCH access-control 1/2] fix #6510: api: acl: allow deleting ACLs for non-existent entities
Date: Tue, 21 Jul 2026 16:40:37 +0200 [thread overview]
Message-ID: <DK4BSO7SXBBB.4HHN2P4WIH4B@proxmox.com> (raw)
In-Reply-To: <20260720134535.136172-2-e.huhsovitz@proxmox.com>
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 <e.huhsovitz@proxmox.com>
> ---
> 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})) {
>
> die "group '$group' does not exist\n"
> - if !$cfg->{groups}->{$group};
> + if !$param->{delete} && !$cfg->{groups}->{$group};
>
> if ($param->{delete}) {
> delete($node->{groups}->{$group}->{$role});
> @@ -237,7 +237,7 @@ __PACKAGE__->register_method({
> my $username = PVE::AccessControl::verify_username($userid);
>
> die "user '$username' does not exist\n"
> - if !$cfg->{users}->{$username};
> + if !$param->{delete} && !$cfg->{users}->{$username};
>
> if ($param->{delete}) {
> delete($node->{users}->{$username}->{$role});
> @@ -248,7 +248,7 @@ __PACKAGE__->register_method({
>
> foreach my $tokenid (split_list($param->{tokens})) {
> my ($username, $token) = PVE::AccessControl::split_tokenid($tokenid);
> - PVE::AccessControl::check_token_exist($cfg, $username, $token);
> + PVE::AccessControl::check_token_exist($cfg, $username, $token) if !$param->{delete};
This line is a bit too long, please run `make tidy` on the individual
patches before sending.
>
> 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 <d.kral@proxmox.com>
Tested-by: Daniel Kral <d.kral@proxmox.com>
next prev parent reply other threads:[~2026-07-21 14:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 13:45 [PATCH access-control 0/2] fix: #6510: Allow deleting ACLs for non-existent entities & add API tests Elias Huhsovitz
2026-07-20 13:45 ` [PATCH access-control 1/2] fix #6510: api: acl: allow deleting ACLs for non-existent entities Elias Huhsovitz
2026-07-21 14:40 ` Daniel Kral [this message]
2026-07-20 13:45 ` [PATCH access-control 2/2] test: api: add tests for ACL modification endpoint Elias Huhsovitz
2026-07-21 15:20 ` Daniel Kral
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=DK4BSO7SXBBB.4HHN2P4WIH4B@proxmox.com \
--to=d.kral@proxmox.com \
--cc=e.huhsovitz@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