From 48809ab0db15ba0940bc050391bbf15047f3ce01 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Mon, 11 Nov 2024 16:43:30 +0100 Subject: [PATCH] api types: add remote acl path method for `BackupNamespace` 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 --- 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 a5704c93..c9aa6b74 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -722,9 +722,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 { @@ -733,6 +731,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.