mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
accounts/scwallet: send the path to go-pcsclite
This commit is contained in:
parent
c65f617a0d
commit
b038a6a727
6 changed files with 22 additions and 11 deletions
|
|
@ -152,8 +152,8 @@ func (hub *Hub) setPairing(wallet *Wallet, pairing *smartcardPairing) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHub creates a new hardware wallet manager for smartcards.
|
// NewHub creates a new hardware wallet manager for smartcards.
|
||||||
func NewHub(scheme string, datadir string) (*Hub, error) {
|
func NewHub(daemonPath string, scheme string, datadir string) (*Hub, error) {
|
||||||
context, err := pcsc.EstablishContext(pcsc.ScopeSystem)
|
context, err := pcsc.EstablishContext(daemonPath, pcsc.ScopeSystem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1159,6 +1159,10 @@ func setSmartCard(ctx *cli.Context, cfg *node.Config) {
|
||||||
// caught at the daemon initialization level, though.
|
// caught at the daemon initialization level, though.
|
||||||
if fi, err := os.Stat(ctx.GlobalString(SmartCardFlag.Name)); err == nil {
|
if fi, err := os.Stat(ctx.GlobalString(SmartCardFlag.Name)); err == nil {
|
||||||
cfg.SmartCard = fi.Mode()&os.ModeType == os.ModeSocket
|
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 {
|
} else {
|
||||||
log.Info("Smartcard support disabled on this platform")
|
log.Info("Smartcard support disabled on this platform")
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,9 @@ type Config struct {
|
||||||
// SmartCard activates smartcard wallet monitoring and connectivity.
|
// SmartCard activates smartcard wallet monitoring and connectivity.
|
||||||
SmartCard bool `toml:",omitempty"`
|
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
|
// 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
|
// 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
|
// 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 {
|
if conf.SmartCard {
|
||||||
// Start a smart card hub
|
// 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))
|
log.Warn(fmt.Sprintf("Failed to start smart card hub, disabling: %v", err))
|
||||||
} else {
|
} else {
|
||||||
backends = append(backends, schub)
|
backends = append(backends, schub)
|
||||||
|
|
|
||||||
10
vendor/github.com/gballet/go-libpcsclite/msg.go
generated
vendored
10
vendor/github.com/gballet/go-libpcsclite/msg.go
generated
vendored
|
|
@ -62,7 +62,7 @@ func messageSendWithHeader(command uint32, conn net.Conn, data []byte) error {
|
||||||
return err
|
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
|
// 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.
|
// 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 The socket can not open a connection.
|
||||||
* @retval -1 Can not set the socket to non-blocking.
|
* @retval -1 Can not set the socket to non-blocking.
|
||||||
*/
|
*/
|
||||||
func clientSetupSession() (net.Conn, error) {
|
func clientSetupSession(daemonPath string) (net.Conn, error) {
|
||||||
return net.Dial("unix", PCSCDSockName)
|
path := PCSCDSockName
|
||||||
|
if len(daemonPath) > 0 {
|
||||||
|
path = daemonPath
|
||||||
|
}
|
||||||
|
return net.Dial("unix", path)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
vendor/github.com/gballet/go-libpcsclite/winscard.go
generated
vendored
4
vendor/github.com/gballet/go-libpcsclite/winscard.go
generated
vendored
|
|
@ -56,10 +56,10 @@ type Client struct {
|
||||||
// EstablishContext asks the PCSC daemon to create a context
|
// EstablishContext asks the PCSC daemon to create a context
|
||||||
// handle for further communication with connected cards and
|
// handle for further communication with connected cards and
|
||||||
// readers.
|
// readers.
|
||||||
func EstablishContext(scope uint32) (*Client, error) {
|
func EstablishContext(path string, scope uint32) (*Client, error) {
|
||||||
client := &Client{}
|
client := &Client{}
|
||||||
|
|
||||||
conn, err := clientSetupSession()
|
conn, err := clientSetupSession(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
|
|
@ -135,10 +135,10 @@
|
||||||
"revisionTime": "2018-04-18T12:24:29Z"
|
"revisionTime": "2018-04-18T12:24:29Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "GXqHzd0XkPLX/iulpOncaxbxzZo=",
|
"checksumSHA1": "aG2cEBkWshLrW0snEymuR6vNZYs=",
|
||||||
"path": "github.com/gballet/go-libpcsclite",
|
"path": "github.com/gballet/go-libpcsclite",
|
||||||
"revision": "312b5175032f98274685a4dd81935a92ad2412a5",
|
"revision": "c11b1ec2c86bc1d38a95f14ae6662f23bf17bc37",
|
||||||
"revisionTime": "2019-04-03T18:15:18Z"
|
"revisionTime": "2019-05-17T11:38:18Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "gxV/cPPLkByTdY8y172t7v4qcZA=",
|
"checksumSHA1": "gxV/cPPLkByTdY8y172t7v4qcZA=",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue