Skip to content

Commit b621032

Browse files
committed
Move unlock_luks2_dev()
1 parent 35c2ff3 commit b621032

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

archinstall/lib/disk/device_handler.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from ..command import SysCommand, SysCommandWorker
1212
from ..exceptions import DiskError, SysCallError, UnknownFilesystemFormat
13-
from ..luks import Luks2
13+
from ..luks import Luks2, unlock_luks2_dev
1414
from ..models.device import (
1515
DEFAULT_ITER_TIME,
1616
BDevice,
@@ -658,7 +658,7 @@ def create_btrfs_volumes(
658658
if not part_mod.mapper_name:
659659
raise ValueError('No device path specified for modification')
660660

661-
luks_handler = self.unlock_luks2_dev(
661+
luks_handler = unlock_luks2_dev(
662662
part_mod.safe_dev_path,
663663
part_mod.mapper_name,
664664
enc_conf.encryption_password,
@@ -691,19 +691,6 @@ def create_btrfs_volumes(
691691
if luks_handler is not None and luks_handler.mapper_dev is not None:
692692
luks_handler.lock()
693693

694-
def unlock_luks2_dev(
695-
self,
696-
dev_path: Path,
697-
mapper_name: str,
698-
enc_password: Password | None,
699-
) -> Luks2:
700-
luks_handler = Luks2(dev_path, mapper_name=mapper_name, password=enc_password)
701-
702-
if not luks_handler.is_unlocked():
703-
luks_handler.unlock()
704-
705-
return luks_handler
706-
707694
def umount_all_existing(self, device_path: Path) -> None:
708695
debug(f'Unmounting all existing partitions: {device_path}')
709696

archinstall/lib/installer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from .exceptions import DiskError, HardwareIncompatibilityError, RequirementError, ServiceException, SysCallError
4242
from .hardware import SysInfo
4343
from .locale.utils import verify_keyboard_layout, verify_x11_keyboard_layout
44-
from .luks import Luks2
44+
from .luks import Luks2, unlock_luks2_dev
4545
from .mirrors import MirrorListHandler
4646
from .models.bootloader import Bootloader
4747
from .models.locale import LocaleConfiguration
@@ -317,7 +317,7 @@ def _prepare_luks_partitions(
317317
partitions: list[PartitionModification],
318318
) -> dict[PartitionModification, Luks2]:
319319
return {
320-
part_mod: device_handler.unlock_luks2_dev(
320+
part_mod: unlock_luks2_dev(
321321
part_mod.dev_path,
322322
part_mod.mapper_name,
323323
self._disk_encryption.encryption_password,
@@ -344,7 +344,7 @@ def _prepare_luks_lvm(
344344
lvm_volumes: list[LvmVolume],
345345
) -> dict[LvmVolume, Luks2]:
346346
return {
347-
vol: device_handler.unlock_luks2_dev(
347+
vol: unlock_luks2_dev(
348348
vol.dev_path,
349349
vol.mapper_name,
350350
self._disk_encryption.encryption_password,

archinstall/lib/luks.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,16 @@ def _crypttab(
237237
uuid = self._get_luks_uuid()
238238
row = f'{self.mapper_name} UUID={uuid} {key_file} {opt}\n'
239239
crypttab.write(row)
240+
241+
242+
def unlock_luks2_dev(
243+
dev_path: Path,
244+
mapper_name: str,
245+
enc_password: Password | None,
246+
) -> Luks2:
247+
luks_handler = Luks2(dev_path, mapper_name=mapper_name, password=enc_password)
248+
249+
if not luks_handler.is_unlocked():
250+
luks_handler.unlock()
251+
252+
return luks_handler

0 commit comments

Comments
 (0)