Ignore disk encryption config when no password found (#2779)

This commit is contained in:
Daniel Girtler 2024-11-07 23:08:42 +11:00 committed by GitHub
parent 0370e893ac
commit 83ece36ec3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View File

@ -255,11 +255,10 @@ def load_config() -> None:
arguments['audio_config'] = models.AudioConfiguration.parse_arg(arguments['audio_config']) arguments['audio_config'] = models.AudioConfiguration.parse_arg(arguments['audio_config'])
if arguments.get('disk_encryption', None) is not None and disk_config is not None: if arguments.get('disk_encryption', None) is not None and disk_config is not None:
password = arguments.get('encryption_password', '')
arguments['disk_encryption'] = disk.DiskEncryption.parse_arg( arguments['disk_encryption'] = disk.DiskEncryption.parse_arg(
arguments['disk_config'], arguments['disk_config'],
arguments['disk_encryption'], arguments['disk_encryption'],
password arguments.get('encryption_password', '')
) )

View File

@ -1232,32 +1232,35 @@ class DiskEncryption:
def parse_arg( def parse_arg(
cls, cls,
disk_config: DiskLayoutConfiguration, disk_config: DiskLayoutConfiguration,
arg: Dict[str, Any], disk_encryption: Dict[str, Any],
password: str = '' password: str = ''
) -> Optional['DiskEncryption']: ) -> Optional['DiskEncryption']:
if not cls.validate_enc(disk_config): if not cls.validate_enc(disk_config):
return None return None
if len(password) < 1:
return None
enc_partitions = [] enc_partitions = []
for mod in disk_config.device_modifications: for mod in disk_config.device_modifications:
for part in mod.partitions: for part in mod.partitions:
if part.obj_id in arg.get('partitions', []): if part.obj_id in disk_encryption.get('partitions', []):
enc_partitions.append(part) enc_partitions.append(part)
volumes = [] volumes = []
if disk_config.lvm_config: if disk_config.lvm_config:
for vol in disk_config.lvm_config.get_all_volumes(): for vol in disk_config.lvm_config.get_all_volumes():
if vol.obj_id in arg.get('lvm_volumes', []): if vol.obj_id in disk_encryption.get('lvm_volumes', []):
volumes.append(vol) volumes.append(vol)
enc = DiskEncryption( enc = DiskEncryption(
EncryptionType(arg['encryption_type']), EncryptionType(disk_encryption['encryption_type']),
password, password,
enc_partitions, enc_partitions,
volumes volumes
) )
if hsm := arg.get('hsm_device', None): if hsm := disk_encryption.get('hsm_device', None):
enc.hsm_device = Fido2Device.parse_arg(hsm) enc.hsm_device = Fido2Device.parse_arg(hsm)
return enc return enc