public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 storage 6/6] api: file restore: use check_volume_access to restrict content type
Date: Wed, 30 Mar 2022 12:24:33 +0200	[thread overview]
Message-ID: <20220330102437.46955-8-f.ebner@proxmox.com> (raw)
In-Reply-To: <20220330102437.46955-1-f.ebner@proxmox.com>

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

No changes from v1.

 PVE/API2/Storage/FileRestore.pm | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/PVE/API2/Storage/FileRestore.pm b/PVE/API2/Storage/FileRestore.pm
index a4bad44..ccc56e5 100644
--- a/PVE/API2/Storage/FileRestore.pm
+++ b/PVE/API2/Storage/FileRestore.pm
@@ -111,14 +111,12 @@ __PACKAGE__->register_method ({
 	my $cfg = PVE::Storage::config();
 	my $scfg = PVE::Storage::storage_config($cfg, $storeid);
 
-	PVE::Storage::check_volume_access($rpcenv, $user, $cfg, undef, $volid);
+	PVE::Storage::check_volume_access($rpcenv, $user, $cfg, undef, $volid, 'backup');
 
 	raise_param_exc({'storage' => "Only PBS storages supported for file-restore."})
 	    if $scfg->{type} ne 'pbs';
 
-	my ($vtype, $snap) = PVE::Storage::parse_volname($cfg, $volid);
-	raise_param_exc({'volume' => 'Not a backup archive.'})
-	    if $vtype ne 'backup';
+	my (undef, $snap) = PVE::Storage::parse_volname($cfg, $volid);
 
 	my $client = PVE::PBSClient->new($scfg, $storeid);
 	my $ret = $client->file_restore_list($snap, $path, $base64);
@@ -177,14 +175,12 @@ __PACKAGE__->register_method ({
 	my $cfg = PVE::Storage::config();
 	my $scfg = PVE::Storage::storage_config($cfg, $storeid);
 
-	PVE::Storage::check_volume_access($rpcenv, $user, $cfg, undef, $volid);
+	PVE::Storage::check_volume_access($rpcenv, $user, $cfg, undef, $volid, 'backup');
 
 	raise_param_exc({'storage' => "Only PBS storages supported for file-restore."})
 	    if $scfg->{type} ne 'pbs';
 
-	my ($vtype, $snap) = PVE::Storage::parse_volname($cfg, $volid);
-	raise_param_exc({'volume' => 'Not a backup archive.'})
-	    if $vtype ne 'backup';
+	my (undef, $snap) = PVE::Storage::parse_volname($cfg, $volid);
 
 	my $client = PVE::PBSClient->new($scfg, $storeid);
 	my $fifo = $client->file_restore_extract_prepare();
-- 
2.30.2





  parent reply	other threads:[~2022-03-30 10:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30 10:24 [pve-devel] [PATCH-SERIES v2 manager/storage/container/qemu-server] improve check_volume_access Fabian Ebner
2022-03-30 10:24 ` [pve-devel] [PATCH v2 manager 1/3] api: vzdump: extract config: check for VM.Backup privilege Fabian Ebner
2022-03-30 10:24 ` [pve-devel] [PATCH v2 storage 1/6] pvesm: " Fabian Ebner
2022-03-30 10:24 ` [pve-devel] [PATCH v2 storage 2/6] check volume access: always allow with Datastore.Allocate privilege Fabian Ebner
2022-03-30 10:24 ` [pve-devel] [PATCH v2 storage 3/6] check volume access: allow for images/rootdir if user has VM.Config.Disk Fabian Ebner
2022-03-30 10:24 ` [pve-devel] [PATCH v2 storage 4/6] check volume accesss: add content type parameter Fabian Ebner
2022-03-30 10:24 ` [pve-devel] [PATCH v2 storage 5/6] pvesm: extract config: add content type check Fabian Ebner
2022-03-30 10:24 ` Fabian Ebner [this message]
2022-03-30 10:24 ` [pve-devel] [PATCH v2 manager 2/3] pveam: remove: " Fabian Ebner
2022-03-30 10:24 ` [pve-devel] [PATCH v2 manager 3/3] api: vzdump: extract config: " Fabian Ebner
2022-03-30 10:24 ` [pve-devel] [PATCH v2 container 1/1] api: create/modify: add content type checks Fabian Ebner
2022-03-30 10:24 ` [pve-devel] [PATCH v2 qemu-server " Fabian Ebner
2022-04-01  8:04 ` [pve-devel] applied-series: [PATCH-SERIES v2 manager/storage/container/qemu-server] improve check_volume_access Fabian Grünbichler

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=20220330102437.46955-8-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