Skip to content

Commit

Permalink
change way to check for root
Browse files Browse the repository at this point in the history
  • Loading branch information
seriousm4x committed Jan 29, 2023
1 parent 752e61c commit a182f7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/pb/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ func HandlerScan(c echo.Context) error {
}
} else {
// check for root on anything else
sudoUID := os.Getenv("SUDO_UID")
if sudoUID == "" {
uid, err := exec.Command("id", "-u").Output()
if err != nil {
return err
}
if string(uid) != "0" {
err := errors.New("network scan requires upsnap to be run as root")
return apis.NewBadRequestError(err.Error(), nil)
}
Expand Down

0 comments on commit a182f7b

Please sign in to comment.