Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accounts/scwallet: Add a switch to specify path to sc daemon #19439

Merged
merged 10 commits into from
May 31, 2019

Conversation

gballet
Copy link
Member

@gballet gballet commented Apr 10, 2019

This adds a command line switch to geth to activate the smartcard management code. This is to remove a warning that will otherwise occur at geth startup and confuse the user:

WARN [04-10|12:04:39.488] Failed to open wallet                    url=pcsc://xxxxxxxx                          err="smartcard: pin needed"

The same switch has voluntarily not been added to clef as clef doesn't support smartcard yet. This will be covered in the PR to add the smartcard feature to clef.

@karalabe
Copy link
Member

Hmmm, doesn't this only appear for Status smart cards? I think if we have an Ethereum smart card in, this is a valid warning. If we don't, this should not appear.

I'm generally against adding flags to enable features, because Geth should be smart enough to correctly handle all scenarios. Requiring user manual flags is just effectively disabling a feature.

node/config.go Outdated
log.Warn(fmt.Sprintf("Failed to start smart card hub, disabling: %v", err))
} else {
backends = append(backends, schub)
if conf.SmartCard {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 fixes the warning when running geth account list.

@gballet
Copy link
Member Author

gballet commented Apr 18, 2019

Hmmm, doesn't this only appear for Status smart cards? I think if we have an Ethereum smart card in, this is a valid warning. If we don't, this should not appear.

This warning appears each time, even if you don't have a smart card reader plugged in. That's why I only want it to be available to the user who knows that they have a smartcard reader. So yes, it's effectively disabling. I'm going to see if it's easier to detect that there is no smartcard reader before activating (basically, making the switch invisible to the user based on what pcscd reports)

@karalabe
Copy link
Member

Yes, that would be ideal. Btw, do the smart cards work on multiple OSes, or only linux? If only Linux, we could make the whole thing disabled for others. That's a good start.

@gballet
Copy link
Member Author

gballet commented Apr 18, 2019

Oh right, there are other OSes besides Linux 😅 pcscd is meant to mimic a windows driver, so I expect support to work on windows and MacOS X is supported according to the PCSC docs. I will try FreeBSD as well, and disable it until it's been tested on each platform.

* disable card support in windows until tested
* only activate account if pcscd socket file is present
* the switch is now the path to the socket file
@gballet
Copy link
Member Author

gballet commented Apr 18, 2019

@karalabe I'm proposing an intermediate step:

  • deactivate it in the case of windows, until I can find a machine to test it
  • look for the PCSC daemon socket file.
    • if not present, it means that the user doesn't have pcscd installed, so we don't activate the scwallet
    • if present, then whatever error happens should be reported to the user by the PCSC code, so scwallet is activated
  • The flag is still here to let the user specify the path to the socket. We can also just set it into the node config if you don't like flags. Just let me know.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor nits, generally looks good to me

p2p/simulations/adapters/exec.go Outdated Show resolved Hide resolved
p2p/simulations/adapters/inproc.go Outdated Show resolved Hide resolved
if fi, err := os.Stat(ctx.GlobalString(SmartCardFlag.Name)); err == nil {
cfg.SmartCard = fi.Mode()&os.ModeType == os.ModeSocket
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth mentioning to windows-users that smart card support is disabled? I don't know, think about it, I'll leave it for you to decide.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@holiman I have updated the command line info. Like you said this morning, let's not display a message every time we start geth. I'm also going to test it on Windows, FreeBSD and macos so it might not be limited to Linux so long anyway. I expect the PCSC daemon to behave the same on these platforms.

cmd/utils/flags.go Show resolved Hide resolved
cmd/swarm/run_test.go Outdated Show resolved Hide resolved
@gballet gballet changed the title accounts/scwallet: Add a switch to enable smartcard support accounts/scwallet: Add a switch to specify path to sc daemon May 5, 2019
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@gballet gballet force-pushed the scwallet-activation-switch branch from 8beae9b to e498e2d Compare May 21, 2019 15:03
@@ -127,6 +128,11 @@ var (
Name: "nousb",
Usage: "Disables monitoring for and managing USB hardware wallets",
}
SmartCardFlag = cli.StringFlag{
Name: "pcscd-sock",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pcscdpath

@karalabe karalabe merged commit 7a22da9 into ethereum:master May 31, 2019
@karalabe karalabe added this to the 1.9.0 milestone May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants