Skip to content

fix: check effective uid instead of username for root - #13

Merged
dobbi84 merged 1 commit into
mainfrom
fix/root-check-euid
Jun 4, 2026
Merged

fix: check effective uid instead of username for root#13
dobbi84 merged 1 commit into
mainfrom
fix/root-check-euid

Conversation

@dobbi84

@dobbi84 dobbi84 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The root-privilege check compared currentUser.Username against the literal string "root", which misses uid-0 accounts that are not named root. Switched to an effective-uid check.

Changes

  • Replace utils.CheckCurrentUser(wantedUser string) with utils.CheckRoot(), which returns an error unless os.Geteuid() == 0.
  • Update the caller in cmd/main.go.
  • Drop the now-unused os/user import.

Testing

  • go build ./...
  • go vet ./...

Comparing currentUser.Username against "root" misses uid-0 accounts
that are not literally named root. Replace CheckCurrentUser with
CheckRoot, which uses os.Geteuid() == 0.
@dobbi84
dobbi84 requested a review from LemonySnippet as a code owner June 4, 2026 08:28
@dobbi84 dobbi84 self-assigned this Jun 4, 2026
@dobbi84 dobbi84 added bug Something isn't working go Pull requests that update go code labels Jun 4, 2026
@dobbi84
dobbi84 merged commit 23d12f0 into main Jun 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant