Merge pull request #86 from str4d/83-improve-missing-service-error

Inform users when `pcscd` is required
This commit is contained in:
str4d
2022-12-29 10:10:42 +00:00
committed by GitHub
3 changed files with 55 additions and 0 deletions
+9
View File
@@ -18,6 +18,15 @@ cargo install age-plugin-yubikey
Help from new packagers is very welcome. Help from new packagers is very welcome.
### Linux, BSD, etc.
On non-Windows, non-macOS systems, you need to ensure that the `pcscd` service
is installed and running. On Debian or Ubuntu, you can do this with:
```
$ sudo apt-get install pcscd
```
### Windows Subsystem for Linux (WSL) ### Windows Subsystem for Linux (WSL)
WSL does not currently provide native support for USB devices. However, Windows WSL does not currently provide native support for USB devices. However, Windows
+17
View File
@@ -12,6 +12,7 @@
-yubikey = YubiKey -yubikey = YubiKey
-yubikeys = YubiKeys -yubikeys = YubiKeys
-age-plugin-yubikey = age-plugin-yubikey -age-plugin-yubikey = age-plugin-yubikey
-pcscd = pcscd
## CLI commands and flags ## CLI commands and flags
@@ -185,6 +186,22 @@ err-slot-has-no-identity = Slot {$slot} does not contain an {-age} identity or c
err-slot-is-not-empty = Slot {$slot} is not empty. Use {-flag-force} to overwrite the slot. err-slot-is-not-empty = Slot {$slot} is not empty. Use {-flag-force} to overwrite the slot.
err-timed-out = Timed out while waiting for a {-yubikey} to be inserted. err-timed-out = Timed out while waiting for a {-yubikey} to be inserted.
err-use-list-for-single = Use {-cmd-list} to print the recipient for a single slot. err-use-list-for-single = Use {-cmd-list} to print the recipient for a single slot.
err-yk-no-service-macos = The Crypto Token Kit service is not running.
rec-yk-no-service-macos =
You may need to restart it. See this Stack Exchange answer for more help:
{" "}{$url}
err-yk-no-service-pcscd = {-pcscd} is not running.
rec-yk-no-service-pcscd =
If you are on Debian or Ubuntu, you can install it with:
{" "}{$apt}
err-yk-no-service-win = The Smart Cards for Windows service is not running.
rec-yk-no-service-win =
See this troubleshooting guide for more help:
{" "}{$url}
err-yk-not-found = Please insert the {-yubikey} you want to set up err-yk-not-found = Please insert the {-yubikey} you want to set up
err-yk-wrong-pin = Invalid PIN ({$tries} tries remaining before it is blocked) err-yk-wrong-pin = Invalid PIN ({$tries} tries remaining before it is blocked)
err-yk-general = Error while communicating with {-yubikey}: {$err} err-yk-general = Error while communicating with {-yubikey}: {$err}
+29
View File
@@ -141,6 +141,35 @@ impl fmt::Debug for Error {
Error::UseListForSingleSlot => wlnfl!(f, "err-use-list-for-single")?, Error::UseListForSingleSlot => wlnfl!(f, "err-use-list-for-single")?,
Error::YubiKey(e) => match e { Error::YubiKey(e) => match e {
yubikey::Error::NotFound => wlnfl!(f, "err-yk-not-found")?, yubikey::Error::NotFound => wlnfl!(f, "err-yk-not-found")?,
yubikey::Error::PcscError {
inner: Some(pcsc::Error::NoService),
} => {
if cfg!(windows) {
wlnfl!(f, "err-yk-no-service-win")?;
let url = "https://learn.microsoft.com/en-us/windows/security/identity-protection/smart-cards/smart-card-debugging-information#smart-card-service";
writeln!(
f,
"{}",
fl!(crate::LANGUAGE_LOADER, "rec-yk-no-service-win", url = url),
)?;
} else if cfg!(target_os = "macos") {
wlnfl!(f, "err-yk-no-service-macos")?;
let url = "https://apple.stackexchange.com/a/438198";
writeln!(
f,
"{}",
fl!(crate::LANGUAGE_LOADER, "rec-yk-no-service-macos", url = url),
)?;
} else {
wlnfl!(f, "err-yk-no-service-pcscd")?;
let apt = "sudo apt-get install pcscd";
writeln!(
f,
"{}",
fl!(crate::LANGUAGE_LOADER, "rec-yk-no-service-pcscd", apt = apt),
)?;
}
}
yubikey::Error::WrongPin { tries } => writeln!( yubikey::Error::WrongPin { tries } => writeln!(
f, f,
"{}", "{}",