From ee6f1e0795fbbdfe8655c44cd40ca94e29f55f74 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Thu, 13 Mar 2014 10:06:14 +0000 Subject: [PATCH] remove the socket before creating it --- cmd/localauditd/localauditd.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/localauditd/localauditd.go b/cmd/localauditd/localauditd.go index bb09608..07bb6b3 100644 --- a/cmd/localauditd/localauditd.go +++ b/cmd/localauditd/localauditd.go @@ -66,6 +66,10 @@ func newLocalServer(spoolPath string, serverUrl string, tlsConf *tls.Config) *lo } func (l *localServer) Serve(path string) error { + // Remove the UNIX socket, or we won't be able to bind successfully. + os.Remove(path) + + // Bind to the specified UNIX socket. uaddr, err := net.ResolveUnixAddr("unix", path) if err != nil { return err @@ -76,6 +80,7 @@ func (l *localServer) Serve(path string) error { } defer s.Close() + // Accept connections and handle them. for { conn, err := s.Accept() if err != nil { -- GitLab