[pbs-devel] [PATCH v7 proxmox-backup 06/31] config: acl: refactor acl path component check for datastore

Christian Ebner c.ebner at proxmox.com
Mon Nov 11 16:43:28 CET 2024


Combine the two if statements checking the datastores ACL path
components, which can be represented more concisely as one.

Further, extend the pre-existing comment to clarify that `datastore`
ACL paths are not limited to the datastore name, but might have
further sub-components specifying the namespace.

Suggested-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 6:
- no changes

 pbs-config/src/acl.rs | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs
index 4ce4c13c0..29ad3e8c9 100644
--- a/pbs-config/src/acl.rs
+++ b/pbs-config/src/acl.rs
@@ -80,11 +80,8 @@ pub fn check_acl_path(path: &str) -> Result<(), Error> {
             }
         }
         "datastore" => {
-            // /datastore/{store}
-            if components_len <= 2 {
-                return Ok(());
-            }
-            if components_len > 2 && components_len <= 2 + pbs_api_types::MAX_NAMESPACE_DEPTH {
+            // /datastore/{store}/{namespace}
+            if components_len <= 2 + pbs_api_types::MAX_NAMESPACE_DEPTH {
                 return Ok(());
             }
         }
-- 
2.39.5





More information about the pbs-devel mailing list