[pbs-devel] [PATCH proxmox-backup] api: move DataStoreConfig parsing and mount check after allowed check
Shannon Sterz
s.sterz at proxmox.com
Mon Dec 16 12:50:44 CET 2024
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 at 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
More information about the pbs-devel
mailing list