File tree Expand file tree Collapse file tree
src/engine/strat_engine/backstore/crypt Expand file tree Collapse file tree Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff line change @@ -402,8 +402,15 @@ pub fn load_crypt_metadata(
402402 } ;
403403 let clevis_info = clevis_info_from_metadata ( device) ?;
404404
405- let encryption_info = EncryptionInfo :: from_options ( ( key_description, clevis_info) )
406- . expect ( "Must have at least one unlock method" ) ;
405+ let encryption_info =
406+ if let Some ( info) = EncryptionInfo :: from_options ( ( key_description, clevis_info) ) {
407+ info
408+ } else {
409+ return Err ( StratisError :: Msg ( format ! (
410+ "No valid encryption method that can be used to unlock device {} found" ,
411+ physical_path. display( )
412+ ) ) ) ;
413+ } ;
407414
408415 let path = vec ! [ DEVICEMAPPER_PATH , & activation_name. to_string( ) ]
409416 . into_iter ( )
You can’t perform that action at this time.
0 commit comments