Skip to content

Commit e30e767

Browse files
committed
Return an error if no unlock method after initialization
Signed-off-by: mulhern <[email protected]>
1 parent 379337c commit e30e767

File tree

1 file changed

+9
-2
lines changed
  • src/engine/strat_engine/backstore/crypt

1 file changed

+9
-2
lines changed

src/engine/strat_engine/backstore/crypt/handle.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,15 @@ impl CryptHandle {
205205
.and_then(|path| clevis_info_from_metadata(&mut device).map(|ci| (path, ci)))
206206
.and_then(|(_, clevis_info)| {
207207
let encryption_info =
208-
EncryptionInfo::from_options((encryption_info.key_description().cloned(), clevis_info))
209-
.expect("Encrypted device must be provided encryption parameters");
208+
if let Some(info) = EncryptionInfo::from_options((encryption_info.key_description().cloned(), clevis_info)) {
209+
info
210+
} else {
211+
return Err(StratisError::Msg(format!(
212+
"No valid encryption method that can be used to unlock device {} found after initialization",
213+
physical_path.display()
214+
)));
215+
};
216+
210217
let device_path = DevicePath::new(physical_path)?;
211218
let devno = get_devno_from_path(physical_path)?;
212219
Ok(CryptHandle::new(

0 commit comments

Comments
 (0)