From ed1673beeddf477a29392e2a976fa1210813f785 Mon Sep 17 00:00:00 2001 From: Koro Date: Sun, 3 Jul 2022 15:27:36 -0400 Subject: [PATCH] Set socket mode after creation. --- server/server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index 7026dfb..1ffb85c 100644 --- a/server/server.go +++ b/server/server.go @@ -174,7 +174,7 @@ func (s *Server) Run() error { listenStr += fmt.Sprintf(" %s[https]", s.config.ListenHTTPS) } if s.config.ListenUnix != "" { - listenStr += fmt.Sprintf(" %s[unix]", s.config.ListenUnix) + listenStr += fmt.Sprintf(" %s[unix/%04o]", s.config.ListenUnix, s.config.ListenUnixMode) } if s.config.SMTPServerListen != "" { listenStr += fmt.Sprintf(" %s[smtp]", s.config.SMTPServerListen) @@ -207,6 +207,11 @@ func (s *Server) Run() error { errChan <- err return } + if err := os.Chmod(s.config.ListenUnix, s.config.ListenUnixMode); err != nil { + s.unixListener.Close() + errChan <- err + return + } s.mu.Unlock() httpServer := &http.Server{Handler: mux} errChan <- httpServer.Serve(s.unixListener)