Skip to content

Commit

Permalink
Check if sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
antsankov committed Jan 10, 2021
1 parent c8b4676 commit d5a42bd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func main() {
go lib.Printer(_dir, ":80")
err = lib.StartServer(_dir, ":80", _cache)
} else {
if _quiet == false {
// If user is sudo we don't launch the browser.
if _quiet == false && isSudo() == false {
browser.OpenURL(fmt.Sprintf("http://localhost%s", _port))
}
go lib.Printer(_dir, _port)
Expand All @@ -67,3 +68,8 @@ func main() {
os.Exit(1)
}
}

// IsSudo checks if user is sudo
func isSudo() bool {
return (os.Geteuid() == 0)
}

0 comments on commit d5a42bd

Please sign in to comment.