Skip to content

test(sandbox): split drop_privileges test to unblock non-root CI#623

Open
elezar wants to merge 1 commit intomainfrom
622-fix-drop-privileges-test-non-root/elezar
Open

test(sandbox): split drop_privileges test to unblock non-root CI#623
elezar wants to merge 1 commit intomainfrom
622-fix-drop-privileges-test-non-root/elezar

Conversation

@elezar
Copy link
Member

@elezar elezar commented Mar 26, 2026

Summary

drop_privileges_succeeds_for_current_user failed on non-root systems because initgroups(3) requires CAP_SETGID even when switching to the current user. This splits the test into a non-root-safe variant that still exercises the setgid() + GID verification path, and marks the full path as #[ignore] for explicit root-only runs.

Related Issue

Closes #622

Changes

  • Added drop_privileges_succeeds_for_current_group: sets only run_as_group (no run_as_user), bypassing initgroups. Exercises setgid() and the GID post-condition verification without root. Runs on every cargo test.
  • Marked drop_privileges_succeeds_for_current_user with #[ignore = "initgroups(3) requires CAP_SETGID; run as root: sudo cargo test -- --ignored"]. Full path (including initgroups, setuid, root-reacquisition check) still reachable explicitly.

Testing

  • mise run pre-commit passes
  • Unit tests added/updated

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

The drop_privileges_succeeds_for_current_user test failed on non-root
systems because initgroups(3) requires CAP_SETGID even when switching
to the current user. Add a new drop_privileges_succeeds_for_current_group
test that omits run_as_user, bypassing initgroups while still exercising
setgid() and the GID post-condition verification. Mark the original
full-path test with #[ignore] so it can be run explicitly as root.

Fixes #622
@elezar elezar requested a review from a team as a code owner March 26, 2026 09:29
@elezar elezar self-assigned this Mar 26, 2026
@elezar elezar changed the title fix(sandbox): split drop_privileges test to unblock non-root CI test(sandbox): split drop_privileges test to unblock non-root CI Mar 26, 2026
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.

bug: drop_privileges_succeeds_for_current_user test fails as non-root due to initgroups requiring CAP_SETGID

1 participant