From b0d66c994c75122bc1582cecd5d8e513266b2004 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Wed, 5 Jun 2019 11:09:49 +0200 Subject: [PATCH] clef: don't error is pcsc is not installed --- signer/core/api.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/signer/core/api.go b/signer/core/api.go index 3c2b80f0d9..d728789fe8 100644 --- a/signer/core/api.go +++ b/signer/core/api.go @@ -22,6 +22,7 @@ import ( "errors" "fmt" "math/big" + "os" "reflect" "strings" @@ -156,10 +157,20 @@ func StartClefAccountManager(ksLocation string, nousb, lightKDF bool, scpath str // Start a smart card hub if len(scpath) > 0 { - if schub, err := scwallet.NewHub(scpath, scwallet.Scheme, ksLocation); err != nil { - log.Warn(fmt.Sprintf("Failed to start smart card hub, disabling: %v", err)) + // Sanity check that the smartcard path is valid + fi, err := os.Stat(scpath) + if err != nil { + log.Info("Smartcard socket file missing, disabling", "err", err) } else { - backends = append(backends, schub) + if fi.Mode()&os.ModeType != os.ModeSocket { + log.Error("Invalid smartcard socket file type", "path", scpath, "type", fi.Mode().String()) + } else { + if schub, err := scwallet.NewHub(scpath, scwallet.Scheme, ksLocation); err != nil { + log.Warn(fmt.Sprintf("Failed to start smart card hub, disabling: %v", err)) + } else { + backends = append(backends, schub) + } + } } }