Skip to content

Commit

Permalink
check if root
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Jul 29, 2018
1 parent 28ed403 commit 15ce690
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"os/user"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -48,7 +49,7 @@ func main() {
app.Version = fmt.Sprintf("%s (%s %s)", version, commit, date)
app.Usage = "this command line scanner works with FIND3\n\t\tto capture bluetooth and WiFi signals from devices"
app.Authors = []cli.Author{
cli.Author{
{
Name: "Zack Scholl",
Email: "[email protected]",
},
Expand Down Expand Up @@ -148,7 +149,6 @@ func main() {
runForever = c.GlobalBool("forever")
scanSeconds = c.GlobalInt("scantime")
minimumThreshold = c.GlobalInt("min-rssi")

if doDebug {
setLogLevel("debug")
} else {
Expand All @@ -157,8 +157,12 @@ func main() {

// make sure is sudo
if os.Getenv("SUDO_USER") == "" {
err = errors.New("need to run with sudo")
return
user, usererr := user.Current()
if usererr == nil && user.Name != "root" {
err = errors.New("need to run with sudo")
return

}
}

// ensure backwards compatibility
Expand Down

0 comments on commit 15ce690

Please sign in to comment.