Skip to content

Commit

Permalink
Challenge for password when using cdr auth.
Browse files Browse the repository at this point in the history
  • Loading branch information
flihp committed Jan 1, 2025
1 parent 77b8a62 commit d38bd8e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/secret_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use zeroize::Zeroizing;
use crate::{
backup::{Share, Verifier},
cdrw::{CdReader, IsoReader},
util,
};

#[derive(ValueEnum, Copy, Clone, Debug, Default, PartialEq)]
Expand Down Expand Up @@ -131,10 +132,24 @@ impl CdrPasswordReader {

impl PasswordReader for CdrPasswordReader {
fn read(&mut self, _prompt: &str) -> Result<Zeroizing<String>> {
let password = self.cdr.read("password")?;
match self.cdr.eject() {
Ok(()) => (),
Err(e) => return Err(e),
}

print!(
"Place authentication CD in the drive, close the drive, then press \n\
any key to continue: "
);
match io::stdout().flush() {
Ok(()) => (),
Err(e) => return Err(e.into()),
}
util::wait_for_line()?;

// Passwords are utf8 and `String::from_utf8` explicitly does *not*
// copy the Vec<u8>.
let password = self.cdr.read("password")?;
let password = Zeroizing::new(String::from_utf8(password)?);
debug!("read password: {:?}", password.deref());

Expand Down

0 comments on commit d38bd8e

Please sign in to comment.