From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH storage] api: prune backups: dry run: filter volumes based on permissions
Date: Tue, 3 Nov 2026 16:14:25 +0100 [thread overview]
Message-ID: <20261103151432.197799-1-f.ebner@proxmox.com> (raw)
In the API endpoint for the prune backups dry run, filter volumes in
the result based on permissions using check_volume_access(), similar
to what the API endpoint for listing storage contents is already
doing.
The permission check is based on permissions for the storage and the
'VM.Backup' permission for guest IDs, so each backup group is either
fully absent or fully present in the result.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/API2/Storage/PruneBackups.pm | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/PVE/API2/Storage/PruneBackups.pm b/src/PVE/API2/Storage/PruneBackups.pm
index 2920c89..60a8182 100644
--- a/src/PVE/API2/Storage/PruneBackups.pm
+++ b/src/PVE/API2/Storage/PruneBackups.pm
@@ -100,6 +100,9 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
my $cfg = PVE::Storage::config();
my $vmid = extract_param($param, 'vmid');
@@ -110,7 +113,19 @@ __PACKAGE__->register_method({
$prune_backups = PVE::JSONSchema::parse_property_string('prune-backups', $prune_backups)
if defined($prune_backups);
- return PVE::Storage::prune_backups($cfg, $storeid, $prune_backups, $vmid, $type, 1);
+ my $result = [];
+ my $prune_list =
+ PVE::Storage::prune_backups($cfg, $storeid, $prune_backups, $vmid, $type, 1);
+ for my $prune_entry ($prune_list->@*) {
+ eval {
+ PVE::Storage::check_volume_access(
+ $rpcenv, $authuser, $cfg, undef, $prune_entry->{volid}, 'backup',
+ );
+ };
+ next if $@;
+ push $result->@*, $prune_entry;
+ }
+ return $result;
},
});
--
2.47.3
next reply other threads:[~2026-11-03 15:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 15:14 Fiona Ebner [this message]
2026-11-04 10:05 ` [PATCH storage] api: prune backups: dry run: filter volumes based on permissions Fabian Grünbichler
2026-11-05 10:39 ` superseded: " Fiona Ebner
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=20261103151432.197799-1-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