[pbs-devel] [PATCH proxmox-backup v5 44/44] api: notification: also list datastores if user has only Backup privs

Lukas Wagner l.wagner at proxmox.com
Tue Apr 23 13:52:30 CEST 2024


Use the /admin/datatore API instead of /config/datastore to get a list
of all available datastores - this ensures that users can see
datastores even if they only have Datastore.Backup privs.

Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
 src/api2/config/notifications/mod.rs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/api2/config/notifications/mod.rs b/src/api2/config/notifications/mod.rs
index 48fa60b4..dfe82ed0 100644
--- a/src/api2/config/notifications/mod.rs
+++ b/src/api2/config/notifications/mod.rs
@@ -3,17 +3,17 @@ use serde::Serialize;
 use serde_json::Value;
 use std::cmp::Ordering;
 
-use proxmox_router::{list_subdirs_api_method, Permission, RpcEnvironment};
+use proxmox_router::{list_subdirs_api_method, ApiMethod, Permission, RpcEnvironment};
 use proxmox_router::{Router, SubdirMap};
 use proxmox_schema::api;
 use proxmox_sortable_macro::sortable;
 
+use crate::api2::admin::datastore::get_datastore_list;
 use pbs_api_types::PRIV_SYS_AUDIT;
 
 use crate::api2::admin::prune::list_prune_jobs;
 use crate::api2::admin::sync::list_sync_jobs;
 use crate::api2::admin::verify::list_verification_jobs;
-use crate::api2::config::datastore::list_datastores;
 use crate::api2::config::media_pool::list_pools;
 use crate::api2::tape::backup::list_tape_backup_jobs;
 
@@ -112,16 +112,17 @@ pub fn get_fields() -> Result<Vec<MatchableField>, Error> {
 /// List all known, matchable metadata field values.
 pub fn get_values(
     param: Value,
+    info: &ApiMethod,
     rpcenv: &mut dyn RpcEnvironment,
 ) -> Result<Vec<MatchableValue>, Error> {
     let mut values = Vec::new();
 
-    let datastores = list_datastores(param.clone(), rpcenv)?;
+    let datastores = get_datastore_list(param.clone(), info, rpcenv)?;
 
     for datastore in datastores {
         values.push(MatchableValue {
             field: "datastore".into(),
-            value: datastore.name.clone(),
+            value: datastore.store.clone(),
             comment: datastore.comment.clone(),
         });
     }
-- 
2.39.2





More information about the pbs-devel mailing list