Skip to content

Commit 7bc3274

Browse files
committed
Don't write encryption keyfiles to an unencrypted root partition
1 parent 0175949 commit 7bc3274

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

archinstall/lib/installer.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ def generate_key_files(self) -> None:
444444
pass
445445

446446
def _generate_key_files_partitions(self) -> None:
447+
root_is_encrypted = any(p.is_root() for p in self._disk_encryption.partitions)
448+
447449
for part_mod in self._disk_encryption.partitions:
448450
gen_enc_file = self._disk_encryption.should_generate_encryption_file(part_mod)
449451

@@ -454,8 +456,11 @@ def _generate_key_files_partitions(self) -> None:
454456
)
455457

456458
if gen_enc_file and not part_mod.is_root():
457-
debug(f'Creating key-file: {part_mod.dev_path}')
458-
luks_handler.create_keyfile(self.target)
459+
if root_is_encrypted:
460+
debug(f'Creating key-file: {part_mod.dev_path}')
461+
luks_handler.create_keyfile(self.target)
462+
else:
463+
debug(f'Skipping key-file for {part_mod.dev_path}: root is not encrypted')
459464

460465
if part_mod.is_root() and not gen_enc_file:
461466
if self._disk_encryption.hsm_device:
@@ -467,6 +472,8 @@ def _generate_key_files_partitions(self) -> None:
467472
)
468473

469474
def _generate_key_file_lvm_volumes(self) -> None:
475+
root_is_encrypted = any(v.is_root() for v in self._disk_encryption.lvm_volumes)
476+
470477
for vol in self._disk_encryption.lvm_volumes:
471478
gen_enc_file = self._disk_encryption.should_generate_encryption_file(vol)
472479

@@ -477,8 +484,11 @@ def _generate_key_file_lvm_volumes(self) -> None:
477484
)
478485

479486
if gen_enc_file and not vol.is_root():
480-
info(f'Creating key-file: {vol.dev_path}')
481-
luks_handler.create_keyfile(self.target)
487+
if root_is_encrypted:
488+
info(f'Creating key-file: {vol.dev_path}')
489+
luks_handler.create_keyfile(self.target)
490+
else:
491+
info(f'Skipping key-file for {vol.dev_path}: root is not encrypted')
482492

483493
if vol.is_root() and not gen_enc_file:
484494
if self._disk_encryption.hsm_device:

0 commit comments

Comments
 (0)