-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #369: Do not allow to run fabio as root
Fabio 1.6 will add recurring warning if fabio is run as root (UID == 0) on UNIX operating systems. It will also add an '-insecure' flag as an override. As of version 1.7 fabio will refuse to start as root without the '-insecure' flag. Fixes #369
- Loading branch information
1 parent
ce979fe
commit abefccc
Showing
6 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// +build !windows | ||
|
||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"time" | ||
) | ||
|
||
const interval = time.Hour | ||
|
||
const warnInsecure = ` | ||
************************************************************ | ||
You are running fabio as root with the '-insecure' flag | ||
Please check the fabio wiki for alternatives | ||
************************************************************ | ||
` | ||
|
||
const warn17behavior = ` | ||
************************************************************ | ||
You are running fabio as root without the '-insecure' flag | ||
This will stop working with fabio 1.7! | ||
************************************************************ | ||
` | ||
|
||
func WarnIfRunAsRoot(allowRoot bool) { | ||
|
||
isRoot := os.Getuid() == 0 | ||
if !isRoot { | ||
return | ||
} | ||
|
||
warn := warnInsecure | ||
if !allowRoot { | ||
warn = warn17behavior | ||
} | ||
|
||
go func() { | ||
for { | ||
log.Printf("[INFO] Running fabio as UID=%d EUID=%d GID=%d", os.Getuid(), os.Geteuid(), os.Getgid()) | ||
log.Print("[WARN] ", warn) | ||
time.Sleep(interval) | ||
} | ||
}() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// +build windows | ||
|
||
package main | ||
|
||
func CheckInsecure(allowRoot bool) { | ||
// windows not supported | ||
} |