Skip to content

feat(fix-perms): add OnRootMismatch change policy - #6

Merged
amannocci merged 1 commit into
mainfrom
feat/on-root-mismatch
Oct 24, 2026
Merged

amannocci merged 1 commit into
mainfrom
feat/on-root-mismatch

Conversation

@amannocci

Copy link
Copy Markdown
Member

Summary

  • Add a FIX_PERMS_POLICY env var that works like Kubernetes' fsGroupChangePolicy. Values are Always (default) and OnRootMismatch, case-insensitive.
  • With OnRootMismatch, a spec path is skipped entirely when its root already has the expected uid:gid and mode, so large trees are not walked on every start. The skip is logged on stderr.
  • Entries below a matching root that have drifted are not fixed. Kubernetes has the same limitation.
  • An invalid value prints a warning and falls back to Always, so no fix is ever skipped by mistake.
  • The owner/mode comparison is moved into a check_entry helper, used by both the root check and the per-entry walk.
  • The README gets a Configuration section listing USERMAP_UID, USERMAP_GID and FIX_PERMS_POLICY.

Test plan

  • cargo fmt, cargo clippy -D warnings, cargo test -p fix-perms pass locally (19 tests, 5 new).
  • Manual run on a temp tree: a matching root is skipped, a mismatching root is fully fixed, and an invalid value warns and exits 0.

Add the FIX_PERMS_POLICY environment variable, mirroring Kubernetes'
fsGroupChangePolicy. With OnRootMismatch, a spec path is skipped entirely
when its root already has the expected owner and mode, avoiding a full
traversal of large trees. Always (default) keeps the current behaviour.
Invalid values warn and fall back to Always.
@amannocci
amannocci force-pushed the feat/on-root-mismatch branch from 8bc2314 to 3593504 Compare October 24, 2026 13:27
@amannocci amannocci self-assigned this Oct 24, 2026
@amannocci
amannocci merged commit 9d16745 into main Oct 24, 2026
7 checks passed
@amannocci
amannocci deleted the feat/on-root-mismatch branch October 24, 2026 13:30
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