mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-02-03 13:47:18 +03:00
config: re-enable efficient mixed acl path/slice support
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
d8ec2a25ba
commit
2d7ec3578b
@ -336,30 +336,36 @@ impl AclTree {
|
|||||||
|
|
||||||
fn get_node(&self, path: &[&str]) -> Option<&AclTreeNode> {
|
fn get_node(&self, path: &[&str]) -> Option<&AclTreeNode> {
|
||||||
let mut node = &self.root;
|
let mut node = &self.root;
|
||||||
for comp in path {
|
for outer in path {
|
||||||
node = match node.children.get(*comp) {
|
for comp in outer.split("/") {
|
||||||
Some(n) => n,
|
node = match node.children.get(comp) {
|
||||||
None => return None,
|
Some(n) => n,
|
||||||
};
|
None => return None,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some(node)
|
Some(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_node_mut(&mut self, path: &[&str]) -> Option<&mut AclTreeNode> {
|
fn get_node_mut(&mut self, path: &[&str]) -> Option<&mut AclTreeNode> {
|
||||||
let mut node = &mut self.root;
|
let mut node = &mut self.root;
|
||||||
for comp in path {
|
for outer in path {
|
||||||
node = match node.children.get_mut(*comp) {
|
for comp in outer.split("/") {
|
||||||
Some(n) => n,
|
node = match node.children.get_mut(comp) {
|
||||||
None => return None,
|
Some(n) => n,
|
||||||
};
|
None => return None,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some(node)
|
Some(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_or_insert_node(&mut self, path: &[&str]) -> &mut AclTreeNode {
|
fn get_or_insert_node(&mut self, path: &[&str]) -> &mut AclTreeNode {
|
||||||
let mut node = &mut self.root;
|
let mut node = &mut self.root;
|
||||||
for comp in path {
|
for outer in path {
|
||||||
node = node.children.entry(String::from(*comp)).or_default();
|
for comp in outer.split("/") {
|
||||||
|
node = node.children.entry(String::from(comp)).or_default();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
node
|
node
|
||||||
}
|
}
|
||||||
@ -658,11 +664,10 @@ impl AclTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_child_paths(&self, auth_id: &Authid, path: &[&str]) -> Result<Vec<String>, Error> {
|
pub fn get_child_paths(&self, auth_id: &Authid, path: &[&str]) -> Result<Vec<String>, Error> {
|
||||||
let path = path.join("/");
|
|
||||||
|
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
|
|
||||||
if let Some(node) = self.get_node(&split_acl_path(&path)) {
|
if let Some(node) = self.get_node(&path) {
|
||||||
|
let path = path.join("/");
|
||||||
node.get_child_paths(path, auth_id, &mut res)?;
|
node.get_child_paths(path, auth_id, &mut res)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user