[pbs-devel] [PATCH v5 proxmox-backup 06/31] api types: implement remote acl path method for sync job
Christian Ebner
c.ebner at proxmox.com
Fri Oct 18 10:42:17 CEST 2024
Add `remote_acl_path` method which generates the acl path from the sync
job configuration. This helper allows to easily generate the acl path
from a given sync job config for privilege checks.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 4:
- no changes
changes since version 3:
- not present in previous version
pbs-api-types/src/jobs.rs | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs
index 868702bc0..3971dd49f 100644
--- a/pbs-api-types/src/jobs.rs
+++ b/pbs-api-types/src/jobs.rs
@@ -594,6 +594,19 @@ impl SyncJobConfig {
None => vec!["datastore", &self.store],
}
}
+
+ pub fn remote_acl_path(&self) -> Option<Vec<&str>> {
+ let remote = self.remote.as_ref()?;
+ let mut remote_acl_path = vec!["remote", remote, &self.remote_store];
+
+ if let Some(namespace) = self.remote_ns.as_ref() {
+ if !namespace.is_root() {
+ let comp: Vec<&str> = namespace.components().collect();
+ remote_acl_path.extend(comp);
+ }
+ }
+ Some(remote_acl_path)
+ }
}
#[api(
--
2.39.5
More information about the pbs-devel
mailing list