Drop privileges after server start

This commit is contained in:
Jan Eitzinger 2024-11-08 19:16:56 +01:00
parent ec1ead89ab
commit f0257a2784

View File

@ -204,13 +204,6 @@ func main() {
taskManager.Start()
serverInit()
// Because this program will want to bind to a privileged port (like 80), the listener must
// be established first, then the user can be changed, and after that,
// the actual http server can be started.
if err := runtimeEnv.DropPrivileges(config.Keys.Group, config.Keys.User); err != nil {
log.Fatalf("error while preparing server start: %s", err.Error())
}
var wg sync.WaitGroup
wg.Add(1)
@ -219,6 +212,13 @@ func main() {
serverStart()
}()
// Because this program will want to bind to a privileged port (like 80), the listener must
// be established first, then the user can be changed, and after that,
// the actual http server can be started.
if err := runtimeEnv.DropPrivileges(config.Keys.Group, config.Keys.User); err != nil {
log.Fatalf("error while preparing server start: %s", err.Error())
}
wg.Add(1)
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)