Permissions of unix socket

This commit is contained in:
Philipp Heckel 2022-07-03 19:33:01 -04:00
parent 8532b5b7ea
commit bf8077626e
4 changed files with 13 additions and 9 deletions

View file

@ -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/%04o]", s.config.ListenUnix, s.config.ListenUnixMode)
listenStr += fmt.Sprintf(" %s[unix]", s.config.ListenUnix)
}
if s.config.SMTPServerListen != "" {
listenStr += fmt.Sprintf(" %s[smtp]", s.config.SMTPServerListen)
@ -204,13 +204,17 @@ func (s *Server) Run() error {
os.Remove(s.config.ListenUnix)
s.unixListener, err = net.Listen("unix", s.config.ListenUnix)
if err != nil {
s.mu.Unlock()
errChan <- err
return
}
if err := os.Chmod(s.config.ListenUnix, s.config.ListenUnixMode); err != nil {
s.unixListener.Close()
errChan <- err
return
defer s.unixListener.Close()
if s.config.ListenUnixMode > 0 {
if err := os.Chmod(s.config.ListenUnix, s.config.ListenUnixMode); err != nil {
s.mu.Unlock()
errChan <- err
return
}
}
s.mu.Unlock()
httpServer := &http.Server{Handler: mux}