refactor: use geteuid() to detect root on Unix#192
Merged
Conversation
Replace platform-specific root checks with a single Unix implementation based on libc::geteuid(). This removes the need to parse /proc/self/status on Linux or spawn `id -u` on macOS and FreeBSD, making the check simpler and more reliable.
Owner
|
Thanks for your contribution @DeepChirp. This looks good to me! |
domcyrus
added a commit
that referenced
this pull request
Apr 9, 2026
- Windows restricted token sandbox (#206) - macOS Seatbelt sandboxing, later tightened (#196, #203) - Linux sandbox hardening: drop capabilities and clear ambient set (#208) - UI: process privilege shown in security section (#197) - Filter: exact port matching and regex support (#195) - VLAN support in PKTAP/SLL parsers and L3 extraction (#202, #199) - IGMP protocol parsing (#209) - Process name for wildcard /proc/net entries (#218) - CPU efficiency improvements in sort/snapshot/rate/timeout paths (#213, #220, #212, #222) — thanks @deepakpjose - FreeBSD platform cleanup (#205) - Fix default interface selection (#194), root detection on Unix (#192) - Dependency updates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the project already depends on
libc, I believe we can simply uselibc::geteuid() == 0to check for root privileges across all Unix systems. The previous approaches—whether parsing/proc/self/statusor shelling out toid -u—seem to introduce unnecessary performance overhead. Please let me know if I've missed any edge cases or historical context here.