MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / check_inheritance_cycle

Method check_inheritance_cycle

nodedb/src/control/security/role.rs:306–311  ·  view source on GitHub ↗

Check that adopting `parent` as `role_name`'s inheritance parent would not create a cycle or exceed [`MAX_ROLE_INHERITANCE_DEPTH`]. Used by `ALTER ROLE ... SET INHERIT` and the role-to-role form of `GRANT` so that re-parenting an existing role enforces the same chain invariant `create_role` enforces at creation. The parent's existence is the caller's responsibility.

(&self, role_name: &str, parent: &str)

Source from the content-addressed store, hash-verified

304 /// chain invariant `create_role` enforces at creation. The parent's
305 /// existence is the caller's responsibility.
306 pub fn check_inheritance_cycle(&self, role_name: &str, parent: &str) -> crate::Result<()> {
307 let roles = self.roles.read().map_err(|e| crate::Error::Internal {
308 detail: format!("role store lock poisoned: {e}"),
309 })?;
310 check_inheritance_chain(role_name, parent, &roles)
311 }
312
313 /// Look up a custom role by name. Returns None if not found.
314 pub fn get_role(&self, name: &str) -> Option<CustomRole> {

Callers 1

set_role_parentFunction · 0.80

Calls 2

check_inheritance_chainFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected