Fix clippy lints
This commit is contained in:
+2
-6
@@ -78,13 +78,9 @@ impl IdentityBuilder {
|
|||||||
let keys = Key::list(yubikey)?;
|
let keys = Key::list(yubikey)?;
|
||||||
USABLE_SLOTS
|
USABLE_SLOTS
|
||||||
.iter()
|
.iter()
|
||||||
.find(|&&slot| {
|
.find(|&&slot| !keys.iter().any(|key| key.slot() == SlotId::Retired(slot)))
|
||||||
keys.iter()
|
|
||||||
.find(|key| key.slot() == SlotId::Retired(slot))
|
|
||||||
.is_none()
|
|
||||||
})
|
|
||||||
.cloned()
|
.cloned()
|
||||||
.ok_or(Error::NoEmptySlots(yubikey.serial()))?
|
.ok_or_else(|| Error::NoEmptySlots(yubikey.serial()))?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -265,8 +265,8 @@ fn main() -> Result<(), Error> {
|
|||||||
if let Some(state_machine) = opts.age_plugin {
|
if let Some(state_machine) = opts.age_plugin {
|
||||||
run_state_machine(
|
run_state_machine(
|
||||||
&state_machine,
|
&state_machine,
|
||||||
|| plugin::RecipientPlugin::default(),
|
plugin::RecipientPlugin::default,
|
||||||
|| plugin::IdentityPlugin::default(),
|
plugin::IdentityPlugin::default,
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else if opts.generate {
|
} else if opts.generate {
|
||||||
@@ -279,17 +279,17 @@ fn main() -> Result<(), Error> {
|
|||||||
list(true)
|
list(true)
|
||||||
} else {
|
} else {
|
||||||
eprintln!("✨ Let's get your YubiKey set up for age! ✨");
|
eprintln!("✨ Let's get your YubiKey set up for age! ✨");
|
||||||
eprintln!("");
|
eprintln!();
|
||||||
eprintln!("This tool can create a new age identity in a free slot of your YubiKey.");
|
eprintln!("This tool can create a new age identity in a free slot of your YubiKey.");
|
||||||
eprintln!("It will generate an identity file that you can use with an age client,");
|
eprintln!("It will generate an identity file that you can use with an age client,");
|
||||||
eprintln!("along with the corresponding recipient.");
|
eprintln!("along with the corresponding recipient.");
|
||||||
eprintln!("");
|
eprintln!();
|
||||||
eprintln!("If you are already using a YubiKey with age, you can select an existing");
|
eprintln!("If you are already using a YubiKey with age, you can select an existing");
|
||||||
eprintln!("slot to recreate its corresponding identity file and recipient.");
|
eprintln!("slot to recreate its corresponding identity file and recipient.");
|
||||||
eprintln!("");
|
eprintln!();
|
||||||
eprintln!("When asked below to select an option, use the up/down arrow keys to");
|
eprintln!("When asked below to select an option, use the up/down arrow keys to");
|
||||||
eprintln!("make your choice, or press [Esc] or [q] to quit.");
|
eprintln!("make your choice, or press [Esc] or [q] to quit.");
|
||||||
eprintln!("");
|
eprintln!();
|
||||||
|
|
||||||
if Readers::open()?.iter()?.len() == 0 {
|
if Readers::open()?.iter()?.len() == 0 {
|
||||||
eprintln!("⏳ Please insert the YubiKey you want to set up.");
|
eprintln!("⏳ Please insert the YubiKey you want to set up.");
|
||||||
@@ -299,8 +299,8 @@ fn main() -> Result<(), Error> {
|
|||||||
// Filter out readers we can't connect to.
|
// Filter out readers we can't connect to.
|
||||||
let readers_list: Vec<_> = readers
|
let readers_list: Vec<_> = readers
|
||||||
.iter()?
|
.iter()?
|
||||||
.filter_map(|reader| match reader.open() {
|
.filter(|reader| match reader.open() {
|
||||||
Ok(_) => Some(reader),
|
Ok(_) => true,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
let reason = if let Some(inner) = e.source() {
|
let reason = if let Some(inner) = e.source() {
|
||||||
@@ -309,7 +309,7 @@ fn main() -> Result<(), Error> {
|
|||||||
e.to_string()
|
e.to_string()
|
||||||
};
|
};
|
||||||
warn!("Ignoring {}: {}", reader.name(), reason);
|
warn!("Ignoring {}: {}", reader.name(), reason);
|
||||||
None
|
false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|||||||
+4
-4
@@ -71,7 +71,7 @@ pub(crate) fn open(serial: Option<Serial>) -> Result<YubiKey, Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn manage(yubikey: &mut YubiKey) -> Result<(), Error> {
|
pub(crate) fn manage(yubikey: &mut YubiKey) -> Result<(), Error> {
|
||||||
eprintln!("");
|
eprintln!();
|
||||||
let pin = Password::new()
|
let pin = Password::new()
|
||||||
.with_prompt(&format!(
|
.with_prompt(&format!(
|
||||||
"Enter PIN for YubiKey with serial {} (default is 123456)",
|
"Enter PIN for YubiKey with serial {} (default is 123456)",
|
||||||
@@ -82,15 +82,15 @@ pub(crate) fn manage(yubikey: &mut YubiKey) -> Result<(), Error> {
|
|||||||
|
|
||||||
// If the user is using the default PIN, help them to change it.
|
// If the user is using the default PIN, help them to change it.
|
||||||
if pin == "123456" {
|
if pin == "123456" {
|
||||||
eprintln!("");
|
eprintln!();
|
||||||
eprintln!("✨ Your key is using the default PIN. Let's change it!");
|
eprintln!("✨ Your key is using the default PIN. Let's change it!");
|
||||||
eprintln!("✨ We'll also set the PUK equal to the PIN.");
|
eprintln!("✨ We'll also set the PUK equal to the PIN.");
|
||||||
eprintln!("");
|
eprintln!();
|
||||||
eprintln!("🔐 The PIN is up to 8 numbers, letters, or symbols. Not just numbers!");
|
eprintln!("🔐 The PIN is up to 8 numbers, letters, or symbols. Not just numbers!");
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"❌ Your keys will be lost if the PIN and PUK are locked after 3 incorrect tries."
|
"❌ Your keys will be lost if the PIN and PUK are locked after 3 incorrect tries."
|
||||||
);
|
);
|
||||||
eprintln!("");
|
eprintln!();
|
||||||
let current_puk = Password::new()
|
let current_puk = Password::new()
|
||||||
.with_prompt("Enter current PUK (default is 12345678)")
|
.with_prompt("Enter current PUK (default is 12345678)")
|
||||||
.interact()?;
|
.interact()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user