2023-02-13 20:26:52 +01:00
|
|
|
// +build linux,!go1.16
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2023-02-19 14:40:54 +01:00
|
|
|
func enableSecurityRestrictions(config Config, ui userInfo, errorLog *log.Logger) error {
|
2023-02-13 20:26:52 +01:00
|
|
|
|
|
|
|
// Prior to Go 1.6, setuid did not work reliably on Linux
|
|
|
|
// So, absolutely refuse to run as root
|
|
|
|
uid := os.Getuid()
|
|
|
|
euid := os.Geteuid()
|
|
|
|
if uid == 0 || euid == 0 {
|
|
|
|
setuid_err := "Refusing to run with root privileges when setuid() will not work!"
|
|
|
|
errorLog.Println(setuid_err)
|
2023-02-19 14:40:54 +01:00
|
|
|
return error.New(setuid_err)
|
2023-02-13 20:26:52 +01:00
|
|
|
}
|
2023-02-19 14:40:54 +01:00
|
|
|
|
|
|
|
return nil
|
2023-02-13 20:26:52 +01:00
|
|
|
}
|