Removed user substituting and chrooting. It must be made within systemd unit file.
This commit is contained in:
parent
f7d2618c8c
commit
c60b403e00
@ -8,36 +8,13 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
var configPath *string = flag.String("conf", "config.yaml", "path to configuration file")
|
||||
var logToStdout *bool = flag.Bool("log-stdout", false, "write logs to stdout")
|
||||
|
||||
func substituteUser(username string) error {
|
||||
u, err := user.Lookup(username)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
uid, err := strconv.Atoi(u.Uid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if os.Getuid() != uid {
|
||||
if err := syscall.Setuid(uid); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
@ -46,16 +23,6 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if config.Chroot != "" {
|
||||
if err := syscall.Chroot(config.Chroot); err != nil {
|
||||
log.Fatalln("failed to chroot:", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := substituteUser(config.User); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if *logToStdout {
|
||||
config.Log.ToStdout = true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user