Skip to content

feat: add nacm_user_groups() and nacm_group_users() lookup helpers - #697

Open
khromenokroman wants to merge 1 commit into
clicon:masterfrom
khromenokroman:feature/nacm-group-user-lookup
Open

khromenokroman wants to merge 1 commit into
clicon:masterfrom
khromenokroman:feature/nacm-group-user-lookup

Conversation

@khromenokroman

Copy link
Copy Markdown
Contributor

@olofhagsand
Add two read-only NACM query functions to lib/src/clixon_nacm.c so callers (CLI/backend plugins) can look up static group membership without parsing the NACM XML tree themselves:

  • nacm_user_groups(h, username, &groups, &ngroups): all groups a user is statically assigned to (groups/group[user-name=username]).
  • nacm_group_users(h, groupname, &users, &nusers): all users statically assigned to a group (the user-name leaf-list of groups/group[name=...]).

Both resolve the currently active NACM configuration themselves via a new nacm_config_get() helper, which mirrors the tree-resolution logic at the start of nacm_access_pre() (respecting CLICON_NACM_MODE: disabled/external/internal) but is factored out so these lookups don't need to run inside an NACM RPC/data enforcement pass. Neither function resolves dynamic enable-external-groups (OS groups of a connected peer), since that needs live transport-layer peer state this standalone API does not have.

Declarations added to lib/clixon/clixon_nacm.h. Verified with a standalone test against an in-memory NACM tree (CLICON_NACM_MODE=external).

Add two read-only NACM query functions to lib/src/clixon_nacm.c so
callers (CLI/backend plugins) can look up static group membership
without parsing the NACM XML tree themselves:

- nacm_user_groups(h, username, &groups, &ngroups): all groups a user
  is statically assigned to (groups/group[user-name=username]).
- nacm_group_users(h, groupname, &users, &nusers): all users statically
  assigned to a group (the user-name leaf-list of groups/group[name=...]).

Both resolve the currently active NACM configuration themselves via a
new nacm_config_get() helper, which mirrors the tree-resolution logic
at the start of nacm_access_pre() (respecting CLICON_NACM_MODE:
disabled/external/internal) but is factored out so these lookups don't
need to run inside an NACM RPC/data enforcement pass. Neither function
resolves dynamic enable-external-groups (OS groups of a connected
peer), since that needs live transport-layer peer state this
standalone API does not have.

Declarations added to lib/clixon/clixon_nacm.h. Verified with a
standalone test against an in-memory NACM tree (CLICON_NACM_MODE=external).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant