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 3F1171FF0AA for ; Tue, 03 Nov 2026 16:14:41 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5BF8B218D7; Tue, 03 Nov 2026 16:14:39 +0100 (CET) From: Fiona Ebner 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 Message-ID: <20261103151432.197799-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793718875138 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.300 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_MED -2.3 Sender listed at https://www.dnswl.org/, medium 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: 52W63CN7C7XNLIOWGMGRJQ5SVAHL7A6N X-Message-ID-Hash: 52W63CN7C7XNLIOWGMGRJQ5SVAHL7A6N X-MailFrom: f.ebner@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: 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 --- 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