honour disable-token

This commit is contained in:
shimun 2020-10-13 21:25:42 +02:00
parent e5c6ca9237
commit 4b09fcb6cb
Signed by: shimun
GPG Key ID: E81D8382DC2F971B
2 changed files with 6 additions and 3 deletions

0
CHANGELOG.md Normal file
View File

View File

@ -33,7 +33,7 @@ fn derive_secret(
timeout: u64,
pin: Option<&str>,
) -> Fido2LuksResult<([u8; 32], FidoCredential)> {
if credentials.len() == 0 {
if credentials.is_empty() {
return Err(Fido2LuksError::InsufficientCredentials);
}
let timeout = Duration::from_secs(timeout);
@ -419,7 +419,7 @@ pub fn run_cli() -> Fido2LuksResult<()> {
let slot = if let Some(ref credentials) = credentials.ids {
secret(Cow::Borrowed(&credentials.0))
.and_then(|(secret, _cred)| luks_dev.activate(&name, &secret, luks.slot))
} else if luks_dev.is_luks2()? {
} else if luks_dev.is_luks2()? && !luks.disable_token {
luks_dev.activate_token(
&name,
Box::new(|credentials: Vec<String>| {
@ -432,8 +432,11 @@ pub fn run_cli() -> Fido2LuksResult<()> {
}),
luks.slot,
)
} else if luks_dev.is_luks2()? && luks.disable_token {
// disable-token is mostly cosmetic in this instance
return Err(Fido2LuksError::InsufficientCredentials);
} else {
return Err(Fido2LuksError::WrongSecret); // creds or luks2
return Err(Fido2LuksError::WrongSecret);
};
match slot {
Err(e) => {