public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] api: move DataStoreConfig parsing and mount check after allowed check
@ 2024-12-16 11:50 Shannon Sterz
  2024-12-16 12:42 ` [pbs-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Shannon Sterz @ 2024-12-16 11:50 UTC (permalink / raw)
  To: pbs-devel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-16 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-16 11:50 [pbs-devel] [PATCH proxmox-backup] api: move DataStoreConfig parsing and mount check after allowed check Shannon Sterz
2024-12-16 12:42 ` [pbs-devel] applied: " Thomas Lamprecht

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