Skip to content

refactor: use geteuid() to detect root on Unix#192

Merged
domcyrus merged 1 commit into
domcyrus:mainfrom
DeepChirp:refactor/detect-root
Mar 18, 2026
Merged

refactor: use geteuid() to detect root on Unix#192
domcyrus merged 1 commit into
domcyrus:mainfrom
DeepChirp:refactor/detect-root

Conversation

@DeepChirp

Copy link
Copy Markdown
Contributor

Since the project already depends on libc, I believe we can simply use libc::geteuid() == 0 to check for root privileges across all Unix systems. The previous approaches—whether parsing /proc/self/status or shelling out to id -u—seem to introduce unnecessary performance overhead. Please let me know if I've missed any edge cases or historical context here.

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.
@domcyrus

Copy link
Copy Markdown
Owner

Thanks for your contribution @DeepChirp. This looks good to me!

@domcyrus domcyrus merged commit ccd2942 into domcyrus:main Mar 18, 2026
15 of 16 checks passed
@DeepChirp DeepChirp deleted the refactor/detect-root branch March 18, 2026 23:02
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
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.

2 participants