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>
This commit is contained in:
Ophestra Umiker 2024-10-13 20:06:47 +09:00
parent 3739b56504
commit 315c9b8849
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
1 changed files with 6 additions and 0 deletions

View File

@ -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()