use await-dev per default
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7ed948d53b
commit
a437106fcb
31
src/cli.rs
31
src/cli.rs
@ -13,7 +13,6 @@ use failure::_core::str::FromStr;
|
|||||||
use failure::_core::time::Duration;
|
use failure::_core::time::Duration;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use std::io::stdout;
|
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ pub struct SecretGeneration {
|
|||||||
/// Salt for secret generation, defaults to 'ask'
|
/// Salt for secret generation, defaults to 'ask'
|
||||||
///
|
///
|
||||||
/// Options:{n}
|
/// Options:{n}
|
||||||
/// - ask : Promt user using password helper{n}
|
/// - ask : Prompt user using password helper{n}
|
||||||
/// - file:<PATH> : Will read <FILE>{n}
|
/// - file:<PATH> : Will read <FILE>{n}
|
||||||
/// - string:<STRING> : Will use <STRING>, which will be handled like a password provided to the 'ask' option{n}
|
/// - string:<STRING> : Will use <STRING>, which will be handled like a password provided to the 'ask' option{n}
|
||||||
#[structopt(
|
#[structopt(
|
||||||
@ -130,8 +129,13 @@ pub struct SecretGeneration {
|
|||||||
pub password_helper: PasswordHelper,
|
pub password_helper: PasswordHelper,
|
||||||
|
|
||||||
/// Await for an authenticator to be connected, timeout after n seconds
|
/// Await for an authenticator to be connected, timeout after n seconds
|
||||||
#[structopt(long = "await-dev", name = "await-dev", env = "FIDO2LUKS_DEVICE_AWAIT")]
|
#[structopt(
|
||||||
pub await_authenticator: Option<u64>,
|
long = "await-dev",
|
||||||
|
name = "await-dev",
|
||||||
|
env = "FIDO2LUKS_DEVICE_AWAIT",
|
||||||
|
default_value = "15"
|
||||||
|
)]
|
||||||
|
pub await_authenticator: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SecretGeneration {
|
impl SecretGeneration {
|
||||||
@ -145,17 +149,20 @@ impl SecretGeneration {
|
|||||||
|
|
||||||
pub fn obtain_secret(&self) -> Fido2LuksResult<[u8; 32]> {
|
pub fn obtain_secret(&self) -> Fido2LuksResult<[u8; 32]> {
|
||||||
let salt = self.salt.obtain(&self.password_helper)?;
|
let salt = self.salt.obtain(&self.password_helper)?;
|
||||||
if let Some(timeout) = self.await_authenticator.map(Duration::from_secs) {
|
let timeout = Duration::from_secs(self.await_authenticator);
|
||||||
let start = SystemTime::now();
|
let start = SystemTime::now();
|
||||||
while start
|
|
||||||
.elapsed()
|
while let Ok(el) = start.elapsed() {
|
||||||
.map(|el| el < timeout)
|
if el > timeout {
|
||||||
.ok()
|
Err(error::Fido2LuksError::NoAuthenticatorError)?;
|
||||||
.and_then(|el| get_devices().map(|devs| el && devs.is_empty()).ok())
|
}
|
||||||
|
if get_devices()
|
||||||
|
.map(|devices| !devices.is_empty())
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
thread::sleep(Duration::from_millis(500));
|
break;
|
||||||
}
|
}
|
||||||
|
thread::sleep(Duration::from_millis(500));
|
||||||
}
|
}
|
||||||
Ok(assemble_secret(
|
Ok(assemble_secret(
|
||||||
&perform_challenge(&self.credential_id.0, &salt)?,
|
&perform_challenge(&self.credential_id.0, &salt)?,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user