[pbs-devel] [PATCH proxmox-backup] api: delay datastore lookup after permission check

Dietmar Maurer dietmar at proxmox.com
Thu Apr 25 11:49:06 CEST 2024


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 src/api2/admin/datastore.rs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index 3ea17499..3948cc0d 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -678,8 +678,6 @@ pub async fn status(
     let user_info = CachedUserInfo::new()?;
     let store_privs = user_info.lookup_privs(&auth_id, &["datastore", &store]);
 
-    let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read));
-
     let store_stats = if store_privs & (PRIV_DATASTORE_AUDIT | PRIV_DATASTORE_BACKUP) != 0 {
         true
     } else if store_privs & PRIV_DATASTORE_READ != 0 {
@@ -691,7 +689,8 @@ pub async fn status(
             _ => false,
         }
     };
-    let datastore = datastore?; // only unwrap no to avoid leaking existence info
+
+    let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?;
 
     let (counts, gc_status) = if verbose {
         let filter_owner = if store_privs & PRIV_DATASTORE_AUDIT != 0 {
-- 
2.39.2




More information about the pbs-devel mailing list