public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Shannon Sterz <s.sterz@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] api: move DataStoreConfig parsing and mount check after allowed check
Date: Mon, 16 Dec 2024 12:50:44 +0100	[thread overview]
Message-ID: <20241216115044.208595-1-s.sterz@proxmox.com> (raw)

this moves the parsing of the concrete DataStoreConfig as well as the
check whether a store is mounted after the authorization checks.
otherwise we always check for all datastore whether they are mounted,
even if the requesting user has no privileges to list the specified
datastore anyway.

this may improve performance for large setups, as we won't need to stat
mounted datastores regardless of the useres privileges. this was
suggested on the mailing list [1].

[1]: https://lore.proxmox.com/pbs-devel/embeb48874-d400-4e69-ae0f-2cc56a39d592@93f95f61.com/

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
 src/api2/admin/datastore.rs | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index 11d2641b..c611f593 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -1336,15 +1336,15 @@ pub fn get_datastore_list(
             }
         }
 
-        let store_config: DataStoreConfig = serde_json::from_value(data)?;
+        if allowed || allow_id {
+            let store_config: DataStoreConfig = serde_json::from_value(data)?;
 
-        let mount_status = match pbs_datastore::get_datastore_mount_status(&store_config) {
-            Some(true) => DataStoreMountStatus::Mounted,
-            Some(false) => DataStoreMountStatus::NotMounted,
-            None => DataStoreMountStatus::NonRemovable,
-        };
+            let mount_status = match pbs_datastore::get_datastore_mount_status(&store_config) {
+                Some(true) => DataStoreMountStatus::Mounted,
+                Some(false) => DataStoreMountStatus::NotMounted,
+                None => DataStoreMountStatus::NonRemovable,
+            };
 
-        if allowed || allow_id {
             list.push(DataStoreListItem {
                 store: store.clone(),
                 comment: store_config.comment.filter(|_| allowed),
-- 
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


             reply	other threads:[~2024-12-16 11:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-16 11:50 Shannon Sterz [this message]
2024-12-16 12:42 ` [pbs-devel] applied: " Thomas Lamprecht

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=20241216115044.208595-1-s.sterz@proxmox.com \
    --to=s.sterz@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