public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH storage v2 2/2] api: prune backups: allow Datastore.Allocate even without VM.Backup
Date: Thu,  5 Nov 2026 11:35:44 +0100	[thread overview]
Message-ID: <20261105103736.52417-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20261105103736.52417-1-f.ebner@proxmox.com>

A user with 'Datastore.Allocate' permissions for the storage can prune
all backups on the storage. If the same user specifies an explicit
guest ID, additionally the 'VM.Backup' permission for the VM was
required. Remove this restriction, since removing a subset should not
require more permissions and is also at odds with the logic in
check_volume_access().

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/API2/Storage/PruneBackups.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/Storage/PruneBackups.pm b/src/PVE/API2/Storage/PruneBackups.pm
index 7863c36e..5f62e2b7 100644
--- a/src/PVE/API2/Storage/PruneBackups.pm
+++ b/src/PVE/API2/Storage/PruneBackups.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 
 use PVE::Cluster;
+use PVE::Exception qw(raise_perm_exc);
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::RESTHandler;
 use PVE::RPCEnvironment;
@@ -15,11 +16,13 @@ use base qw(PVE::RESTHandler);
 my sub assert_prune_permission {
     my ($rpcenv, $authuser, $storeid, $vmid) = @_;
 
+    return if $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.Allocate'], 1);
+
     if (defined($vmid)) {
         $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']);
         $rpcenv->check($authuser, "/vms/$vmid", ['VM.Backup']);
     } else {
-        $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.Allocate']);
+        raise_perm_exc("/storage/$storeid, Datastore.Allocate");
     }
 
     return;
-- 
2.47.3





      parent reply	other threads:[~2026-11-05 10:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 10:35 [PATCH-SERIES storage v2 0/2] api: prune backups: improve permission checks Fiona Ebner
2026-11-05 10:35 ` [PATCH storage v2 1/2] api: prune backups: align permission check for dry run and active run Fiona Ebner
2026-11-05 10:35 ` Fiona Ebner [this message]

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=20261105103736.52417-3-f.ebner@proxmox.com \
    --to=f.ebner@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal