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.
()
| 458 | // |
| 459 | // On BSD, root users should always have UID 0. |
| 460 | func (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 | } |