From 18e270caaee926321c3e72461da685134a0aabd8 Mon Sep 17 00:00:00 2001 From: Artem Date: Thu, 30 Apr 2020 11:26:28 +0300 Subject: [PATCH] Adding error message when sock file exists --- main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 73abdea..a676e5c 100644 --- a/main.go +++ b/main.go @@ -239,14 +239,16 @@ func main() { }() if *unixSocket != "" { - if *force { - // If the socket file already exists then unlink it - _, err := os.Stat(*unixSocket) - if err == nil || !os.IsNotExist(err) { + _, err := os.Stat(*unixSocket) + if err == nil || !os.IsNotExist(err) { + if *force { + // If the socket file already exists then unlink it err = syscall.Unlink(*unixSocket) if err != nil { log.Fatalf("Failed to unlink socket %s, error '%s'\n", *unixSocket, err) } + } else { + log.Fatalf("Error: the SSH_AUTH_SOCK file already exists. Please delete it manually or use --force option.") } }