MCPcopy Create free account
hub / github.com/tailscale/tailscale / assertNotRoot

Method assertNotRoot

drive/driveimpl/remote_impl.go:460–469  ·  view source on GitHub ↗

assertNotRoot returns an error if the current user has UID 0 or if we cannot determine the current user. On Linux, root users will always have UID 0. On BSD, root users should always have UID 0.

()

Source from the content-addressed store, hash-verified

458//
459// On BSD, root users should always have UID 0.
460func (s *userServer) assertNotRoot() error {
461 u, err := user.Current()
462 if err != nil {
463 return fmt.Errorf("assertNotRoot failed to find current user: %s", err)
464 }
465 if u.Uid == "0" {
466 return fmt.Errorf("%q is root", u.Name)
467 }
468 return nil
469}

Callers 1

runMethod · 0.95

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected