public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup v4 02/14] api: config: early perform user access checks for datastore creation
Date: Mon,  3 Aug 2026 11:07:35 +0200	[thread overview]
Message-ID: <20260803090747.265683-3-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260803090747.265683-1-c.ebner@proxmox.com>

If the user is lacking permissions to perform the requested actions,
locking the datastore config must be avoided altogether.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 src/api2/config/datastore.rs | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
index e7028480c..76e784e5a 100644
--- a/src/api2/config/datastore.rs
+++ b/src/api2/config/datastore.rs
@@ -276,6 +276,14 @@ pub fn create_datastore(
     overwrite_in_use: bool,
     rpcenv: &mut dyn RpcEnvironment,
 ) -> Result<String, Error> {
+    let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
+    let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
+
+    if config.backing_device.is_some() {
+        let user_info = CachedUserInfo::new()?;
+        user_info.check_privs(&auth_id, &["system", "disks"], PRIV_SYS_MODIFY, false)?;
+    }
+
     let lock = pbs_config::datastore::lock_config()?;
 
     let (section_config, _digest) = pbs_config::datastore::config()?;
@@ -302,14 +310,6 @@ pub fn create_datastore(
         param_bail!("gc-on-unmount", "only supported on removable datastores",);
     }
 
-    let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
-    let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
-
-    if config.backing_device.is_some() {
-        let user_info = CachedUserInfo::new()?;
-        user_info.check_privs(&auth_id, &["system", "disks"], PRIV_SYS_MODIFY, false)?;
-    }
-
     let mut prune_job_config = None;
     if config.keep.keeps_something() || !has_prune_job(&config.name)? {
         prune_job_config = config.prune_schedule.as_ref().map(|schedule| {
-- 
2.47.3





  parent reply	other threads:[~2026-08-03  9:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03  9:07 [PATCH proxmox{,-backup} v4 00/14] keep datastore config unlocked during long running operations Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox v4 01/14] pbs-api-types: add datastore create maintenance-mode type Christian Ebner
2026-08-03  9:07 ` Christian Ebner [this message]
2026-08-03  9:07 ` [PATCH proxmox-backup v4 03/14] api: config: unlocked s3 bucket access check for datastore creation Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 04/14] api: config: rearrange independent code block " Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 05/14] api/datastore: refactor datastore creation helper logic Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 06/14] datastore: restrict chunk store scope to pbs-datastore crate Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 07/14] datastore: move lock files base path constant to central location Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 08/14] datastore: move file lock helper to centralized place Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 09/14] datastore: add additional check for device number on lock helper Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 10/14] datastore: create lockdir with correct mode for backup user access Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 11/14] api/datastore: use maintenance-mode lock to protect against changes Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 12/14] pbs-config: add helper to check new datastore config sections Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 13/14] api: datastore: move prune job and s3 backend logic to create helper Christian Ebner
2026-08-03  9:07 ` [PATCH proxmox-backup v4 14/14] datastore: protect datastore creation by maintenance-mode Christian 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=20260803090747.265683-3-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-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