aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-10-13 20:06:47 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-10-13 20:06:47 +0900
commit315c9b8849ae7ad764035dc6ceddc0bc35cb0c95 (patch)
tree17eff1dbfd1c2dac598afe5c7d0aa6e7b6e2a75a
parent3739b56504c7a268241c80b50461a19c4abe699c (diff)
fortify: refuse to run as root
There is no good reason to run fortify as root and desktop environments typically do not like that either. This check prevents confusion for new users who might mistakenly run it as root or set the setuid bit. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
-rw-r--r--main.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/main.go b/main.go
index b0558c15..9ccdf0bc 100644
--- a/main.go
+++ b/main.go
@@ -38,6 +38,12 @@ func main() {
// shim early exit
shim.Try()
+ // root check
+ if os.Getuid() == 0 {
+ fmt.Println("fortify: this program must not run as root")
+ os.Exit(1)
+ }
+
// version/license/template command early exit
tryVersion()
tryLicense()