1
1
Fork 0
mirror of https://tildegit.org/solderpunk/molly-brown synced 2024-05-11 03:06:03 +02:00
molly-brown/security_oldgolinux.go
Solderpunk eb85a6e94c Another big refactor, splitting the Config struct in two.
The split reflects that between variables which can and cannot be
overridden by .molly files, and this greatly simplifies the
processing of said files, getting rid of the need for lots of
ugly temporary variable thrashing.
2023-02-25 11:29:13 +01:00

24 lines
465 B
Go

// +build linux,!go1.16
package main
import (
"log"
"os"
)
func enableSecurityRestrictions(config SysConfig, ui userInfo) error {
// 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!"
log.Println(setuid_err)
return error.New(setuid_err)
}
return nil
}