[pbs-devel] [PATCH v6 proxmox-backup 06/29] api types: add remote acl path method for `BackupNamespace`

Christian Ebner c.ebner at proxmox.com
Thu Oct 31 13:14:56 CET 2024


Add a `remote_acl_path` helper method for creating acl paths for
remote namespaces, to be used by the priv checks on remote datastore
namespaces for e.g. the sync job in push direction.

Factor out the common path extension into a dedicated method.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 5:
- not present in previous version

 pbs-api-types/src/datastore.rs | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
index 31767417a..b037b6fec 100644
--- a/pbs-api-types/src/datastore.rs
+++ b/pbs-api-types/src/datastore.rs
@@ -717,9 +717,7 @@ impl BackupNamespace {
         Ok(())
     }
 
-    pub fn acl_path<'a>(&'a self, store: &'a str) -> Vec<&'a str> {
-        let mut path: Vec<&str> = vec!["datastore", store];
-
+    fn acl_path_extend<'a>(&'a self, mut path: Vec<&'a str>) -> Vec<&'a str> {
         if self.is_root() {
             path
         } else {
@@ -728,6 +726,14 @@ impl BackupNamespace {
         }
     }
 
+    pub fn acl_path<'a>(&'a self, store: &'a str) -> Vec<&'a str> {
+        self.acl_path_extend(vec!["datastore", store])
+    }
+
+    pub fn remote_acl_path<'a>(&'a self, remote: &'a str, store: &'a str) -> Vec<&'a str> {
+        self.acl_path_extend(vec!["remote", remote, store])
+    }
+
     /// Check whether this namespace contains another namespace.
     ///
     /// If so, the depth is returned.
-- 
2.39.5





More information about the pbs-devel mailing list