diff --git a/accounts/scwallet/hub.go b/accounts/scwallet/hub.go index c259f711f0..fac60b44a7 100644 --- a/accounts/scwallet/hub.go +++ b/accounts/scwallet/hub.go @@ -152,8 +152,8 @@ func (hub *Hub) setPairing(wallet *Wallet, pairing *smartcardPairing) error { } // NewHub creates a new hardware wallet manager for smartcards. -func NewHub(scheme string, datadir string) (*Hub, error) { - context, err := pcsc.EstablishContext(pcsc.ScopeSystem) +func NewHub(daemonPath string, scheme string, datadir string) (*Hub, error) { + context, err := pcsc.EstablishContext(daemonPath, pcsc.ScopeSystem) if err != nil { return nil, err } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 1caec41b20..5bbae6d608 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1159,6 +1159,10 @@ func setSmartCard(ctx *cli.Context, cfg *node.Config) { // caught at the daemon initialization level, though. if fi, err := os.Stat(ctx.GlobalString(SmartCardFlag.Name)); err == nil { cfg.SmartCard = fi.Mode()&os.ModeType == os.ModeSocket + cfg.SmartCardDaemonPath = ctx.GlobalString(SmartCardFlag.Name) + fmt.Println(ctx.GlobalString(SmartCardFlag.Name)) + } else { + log.Error(ctx.GlobalString(SmartCardFlag.Name), "doesn't seem to be a socket file") } } else { log.Info("Smartcard support disabled on this platform") diff --git a/node/config.go b/node/config.go index 55a8a05da0..cb3b07c2e0 100644 --- a/node/config.go +++ b/node/config.go @@ -98,6 +98,9 @@ type Config struct { // SmartCard activates smartcard wallet monitoring and connectivity. SmartCard bool `toml:",omitempty"` + // SmartCardDaemonPath is the path to the smartcard daemon's socket + SmartCardDaemonPath string `toml:",omitempty"` + // IPCPath is the requested location to place the IPC endpoint. If the path is // a simple file name, it is placed inside the data directory (or on the root // pipe path on Windows), whereas if it's a resolvable path name (absolute or @@ -510,7 +513,7 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) { } if conf.SmartCard { // Start a smart card hub - if schub, err := scwallet.NewHub(scwallet.Scheme, keydir); err != nil { + if schub, err := scwallet.NewHub(conf.SmartCardDaemonPath, scwallet.Scheme, keydir); err != nil { log.Warn(fmt.Sprintf("Failed to start smart card hub, disabling: %v", err)) } else { backends = append(backends, schub) diff --git a/vendor/github.com/gballet/go-libpcsclite/msg.go b/vendor/github.com/gballet/go-libpcsclite/msg.go index 53f5435308..1377082b14 100644 --- a/vendor/github.com/gballet/go-libpcsclite/msg.go +++ b/vendor/github.com/gballet/go-libpcsclite/msg.go @@ -62,7 +62,7 @@ func messageSendWithHeader(command uint32, conn net.Conn, data []byte) error { return err } -// ClientSetupSession prepares a communication channel for the client to talk to the server. +// clientSetupSession prepares a communication channel for the client to talk to the server. // This is called by the application to create a socket for local IPC with the // server. The socket is associated to the file \c PCSCLITE_CSOCK_NAME. /* @@ -73,6 +73,10 @@ func messageSendWithHeader(command uint32, conn net.Conn, data []byte) error { * @retval -1 The socket can not open a connection. * @retval -1 Can not set the socket to non-blocking. */ -func clientSetupSession() (net.Conn, error) { - return net.Dial("unix", PCSCDSockName) +func clientSetupSession(daemonPath string) (net.Conn, error) { + path := PCSCDSockName + if len(daemonPath) > 0 { + path = daemonPath + } + return net.Dial("unix", path) } diff --git a/vendor/github.com/gballet/go-libpcsclite/winscard.go b/vendor/github.com/gballet/go-libpcsclite/winscard.go index e4692ed165..b916db1621 100644 --- a/vendor/github.com/gballet/go-libpcsclite/winscard.go +++ b/vendor/github.com/gballet/go-libpcsclite/winscard.go @@ -56,10 +56,10 @@ type Client struct { // EstablishContext asks the PCSC daemon to create a context // handle for further communication with connected cards and // readers. -func EstablishContext(scope uint32) (*Client, error) { +func EstablishContext(path string, scope uint32) (*Client, error) { client := &Client{} - conn, err := clientSetupSession() + conn, err := clientSetupSession(path) if err != nil { return nil, err } diff --git a/vendor/vendor.json b/vendor/vendor.json index 89a78363c7..957a4d32ce 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -135,10 +135,10 @@ "revisionTime": "2018-04-18T12:24:29Z" }, { - "checksumSHA1": "GXqHzd0XkPLX/iulpOncaxbxzZo=", + "checksumSHA1": "aG2cEBkWshLrW0snEymuR6vNZYs=", "path": "github.com/gballet/go-libpcsclite", - "revision": "312b5175032f98274685a4dd81935a92ad2412a5", - "revisionTime": "2019-04-03T18:15:18Z" + "revision": "c11b1ec2c86bc1d38a95f14ae6662f23bf17bc37", + "revisionTime": "2019-05-17T11:38:18Z" }, { "checksumSHA1": "gxV/cPPLkByTdY8y172t7v4qcZA=",