From c60b403e00acb8ecefdaeef7fbc0ad42ecee4977 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Tue, 29 Mar 2022 18:12:37 +0400 Subject: [PATCH] Removed user substituting and chrooting. It must be made within systemd unit file. --- cmd/dwelling-upload-clean/main.go | 33 ------------------------------- 1 file changed, 33 deletions(-) diff --git a/cmd/dwelling-upload-clean/main.go b/cmd/dwelling-upload-clean/main.go index 47114a3..ce54abd 100644 --- a/cmd/dwelling-upload-clean/main.go +++ b/cmd/dwelling-upload-clean/main.go @@ -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 }