From 06c6dfc67f3c5aa90356e3ccf2ca326f7d8cfa62 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 10 Dec 2018 00:19:21 +0000 Subject: [PATCH] Complain if socket file already exists --- src/yggdrasil/admin.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 50fdcf90..720c30f8 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -343,11 +343,14 @@ func (a *admin) listen() { if err == nil { switch strings.ToLower(u.Scheme) { case "unix": + if _, err := os.Stat(a.listenaddr[7:]); err == nil { + a.core.log.Println("WARNING:", a.listenaddr[7:], "already exists and may be in use by another process") + } a.listener, err = net.Listen("unix", a.listenaddr[7:]) if err == nil { if err := os.Chmod(a.listenaddr[7:], 0660); err != nil { - a.core.log.Printf("WARNING:", a.listenaddr[:7], "may have unsafe permissions!") - } + a.core.log.Println("WARNING:", a.listenaddr[:7], "may have unsafe permissions!") + } } case "tcp": a.listener, err = net.Listen("tcp", u.Host)