11__author__ = 'desultory'
2- __version__ = '2.1 .0'
2+ __version__ = '2.2 .0'
33
44from zenlib .util import check_dict
55
@@ -187,23 +187,6 @@ def _validate_crypysetup_key(self, key_paramters: dict) -> None:
187187 key_copy = parent
188188
189189
190- def open_crypt_key (self , name : str , parameters : dict ) -> tuple [list [str ], str ]:
191- """
192- Returns a tuple of bash lines and the path to the key file
193- Returns bash lines to open a luks key and output it to specified key file
194- """
195- if parameters .get ('key_file' ):
196- _validate_crypysetup_key (self , parameters )
197- else :
198- raise ValueError ("Key file must be specified for cryptsetup mount: %s" % name )
199- key_path = f"/run/vars/key_{ name } "
200-
201- out = [f" einfo 'Attempting to open luks key for { name } '" ]
202- out += [f' { parameters ["key_command" ]} "{ key_path } "' ]
203-
204- return out , key_path
205-
206-
207190def open_crypt_device (self , name : str , parameters : dict ) -> list [str ]:
208191 """ Returns a bash script to open a cryptsetup device. """
209192 self .logger .debug ("[%s] Processing cryptsetup volume: %s" % (name , parameters ))
@@ -215,9 +198,9 @@ def open_crypt_device(self, name: str, parameters: dict) -> list[str]:
215198 # When there is a key command, read from the named pipe and use that as the key
216199 if 'key_command' in parameters :
217200 self .logger .debug ("[%s] Using key command: %s" % (name , parameters ['key_command' ]))
218- out_line , key_name = open_crypt_key ( self , name , parameters )
219- out += out_line
220- cryptsetup_command = f'cryptsetup open --key-file { key_name } '
201+ out += [ f" einfo 'Attempting to open LUKS key: { parameters [ 'key_file' ] } '" ,
202+ f" edebug 'Using key command: { parameters [ 'key_command' ] } '" ]
203+ cryptsetup_command = f'{ parameters [ "key_command" ] } | cryptsetup open --key-file - '
221204 elif 'key_file' in parameters :
222205 self .logger .debug ("[%s] Using key file: %s" % (name , parameters ['key_file' ]))
223206 _validate_crypysetup_key (self , parameters )
0 commit comments