Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion archinstall/lib/disk/disk_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def _prev_disk_encryption(self, item: MenuItem) -> str | None:
if enc_config.encryption_password:
output += tr('Password') + f': {enc_config.encryption_password.hidden()}\n'

if enc_type != EncryptionType.NoEncryption:
if enc_type != EncryptionType.NO_ENCRYPTION:
output += tr('Iteration time') + f': {enc_config.iter_time or DEFAULT_ITER_TIME}ms\n'

if enc_config.partitions:
Expand Down
18 changes: 9 additions & 9 deletions archinstall/lib/disk/encryption_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ async def _select_lvm_vols(self, preset: list[LvmVolume]) -> list[LvmVolume]:

def _check_dep_enc_type(self) -> bool:
enc_type: EncryptionType | None = self._item_group.find_by_key('encryption_type').value
if enc_type and enc_type != EncryptionType.NoEncryption:
if enc_type and enc_type != EncryptionType.NO_ENCRYPTION:
return True
return False

def _check_dep_partitions(self) -> bool:
enc_type: EncryptionType | None = self._item_group.find_by_key('encryption_type').value
if enc_type and enc_type in [EncryptionType.Luks, EncryptionType.LvmOnLuks]:
if enc_type and enc_type in [EncryptionType.LUKS, EncryptionType.LVM_ON_LUKS]:
return True
return False

def _check_dep_lvm_vols(self) -> bool:
enc_type: EncryptionType | None = self._item_group.find_by_key('encryption_type').value
if enc_type and enc_type == EncryptionType.LuksOnLvm:
if enc_type and enc_type == EncryptionType.LUKS_ON_LVM:
return True
return False

Expand All @@ -137,13 +137,13 @@ async def show(self) -> DiskEncryption | None:
assert enc_partitions is not None
assert enc_lvm_vols is not None

if enc_type in [EncryptionType.Luks, EncryptionType.LvmOnLuks] and enc_partitions:
if enc_type in [EncryptionType.LUKS, EncryptionType.LVM_ON_LUKS] and enc_partitions:
enc_lvm_vols = []

if enc_type == EncryptionType.LuksOnLvm:
if enc_type == EncryptionType.LUKS_ON_LVM:
enc_partitions = []

if enc_type != EncryptionType.NoEncryption and enc_password and (enc_partitions or enc_lvm_vols):
if enc_type != EncryptionType.NO_ENCRYPTION and enc_password and (enc_partitions or enc_lvm_vols):
return DiskEncryption(
encryption_password=enc_password,
encryption_type=enc_type,
Expand Down Expand Up @@ -227,7 +227,7 @@ def _prev_iter_time(self, item: MenuItem) -> str | None:
iter_time = item.value
enc_type = self._item_group.find_by_key('encryption_type').value

if iter_time and enc_type != EncryptionType.NoEncryption:
if iter_time and enc_type != EncryptionType.NO_ENCRYPTION:
return f'{tr("Iteration time")}: {iter_time}ms'

return None
Expand All @@ -240,9 +240,9 @@ async def select_encryption_type(
options: list[EncryptionType] = []

if lvm_config:
options = [EncryptionType.LvmOnLuks, EncryptionType.LuksOnLvm]
options = [EncryptionType.LVM_ON_LUKS, EncryptionType.LUKS_ON_LVM]
else:
options = [EncryptionType.Luks]
options = [EncryptionType.LUKS]

if not preset:
preset = options[0]
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/disk/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def perform_lvm_operations(self) -> None:
self._format_lvm_vols(self._disk_config.lvm_config)

def _setup_lvm_encrypted(self, lvm_config: LvmConfiguration, enc_config: DiskEncryption) -> None:
if enc_config.encryption_type == EncryptionType.LvmOnLuks:
if enc_config.encryption_type == EncryptionType.LVM_ON_LUKS:
enc_mods = self._encrypt_partitions(enc_config, lock_after_create=False)

self._setup_lvm(lvm_config, enc_mods)
Expand All @@ -148,7 +148,7 @@ def _setup_lvm_encrypted(self, lvm_config: LvmConfiguration, enc_config: DiskEnc
# Don't close LVM or LUKS during setup - keep everything active
# The installation phase will handle unlocking and mounting
# Closing causes "parent leaked" and lvchange errors
elif enc_config.encryption_type == EncryptionType.LuksOnLvm:
elif enc_config.encryption_type == EncryptionType.LUKS_ON_LVM:
self._setup_lvm(lvm_config)
enc_vols = self._encrypt_lvm_vols(lvm_config, enc_config, False)
self._format_lvm_vols(lvm_config, enc_vols)
Expand Down
24 changes: 12 additions & 12 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(
self.kernels = kernels or ['linux']
self._disk_config = disk_config

self._disk_encryption = disk_config.disk_encryption or DiskEncryption(EncryptionType.NoEncryption)
self._disk_encryption = disk_config.disk_encryption or DiskEncryption(EncryptionType.NO_ENCRYPTION)
self.target: Path = target

self.init_time = time.strftime('%Y-%m-%d_%H-%M-%S')
Expand Down Expand Up @@ -254,16 +254,16 @@ def mount_ordered_layout(self) -> None:
luks_handlers: dict[Any, Luks2] = {}

match self._disk_encryption.encryption_type:
case EncryptionType.NoEncryption:
case EncryptionType.NO_ENCRYPTION:
self._import_lvm()
self._mount_lvm_layout()
case EncryptionType.Luks:
case EncryptionType.LUKS:
luks_handlers = self._prepare_luks_partitions(self._disk_encryption.partitions)
case EncryptionType.LvmOnLuks:
case EncryptionType.LVM_ON_LUKS:
luks_handlers = self._prepare_luks_partitions(self._disk_encryption.partitions)
self._import_lvm()
self._mount_lvm_layout(luks_handlers)
case EncryptionType.LuksOnLvm:
case EncryptionType.LUKS_ON_LVM:
self._import_lvm()
luks_handlers = self._prepare_luks_lvm(self._disk_encryption.lvm_volumes)
self._mount_lvm_layout(luks_handlers)
Expand Down Expand Up @@ -433,11 +433,11 @@ def _mount_btrfs_subvol(

def generate_key_files(self) -> None:
match self._disk_encryption.encryption_type:
case EncryptionType.Luks:
case EncryptionType.LUKS:
self._generate_key_files_partitions()
case EncryptionType.LuksOnLvm:
case EncryptionType.LUKS_ON_LVM:
self._generate_key_file_lvm_volumes()
case EncryptionType.LvmOnLuks:
case EncryptionType.LVM_ON_LUKS:
# currently LvmOnLuks only supports a single
# partitioning layout (boot + partition)
# so we won't need any keyfile generation atm
Expand Down Expand Up @@ -899,7 +899,7 @@ def minimal_installation(
if vol.fs_type is not None:
self._prepare_fs_type(vol.fs_type, vol.mountpoint)

types = (EncryptionType.LvmOnLuks, EncryptionType.LuksOnLvm)
types = (EncryptionType.LVM_ON_LUKS, EncryptionType.LUKS_ON_LVM)
if self._disk_encryption.encryption_type in types:
self._prepare_encrypt(lvm)
else:
Expand Down Expand Up @@ -1137,7 +1137,7 @@ def _get_kernel_params_lvm(
kernel_parameters = []

match self._disk_encryption.encryption_type:
case EncryptionType.LvmOnLuks:
case EncryptionType.LVM_ON_LUKS:
if not lvm.vg_name:
raise ValueError(f'Unable to determine VG name for {lvm.name}')

Expand All @@ -1154,7 +1154,7 @@ def _get_kernel_params_lvm(
else:
debug(f'LvmOnLuks, encrypted root partition, identifying by UUID: {uuid}')
kernel_parameters.append(f'cryptdevice=UUID={uuid}:cryptlvm root={lvm.safe_dev_path}')
case EncryptionType.LuksOnLvm:
case EncryptionType.LUKS_ON_LVM:
uuid = self._get_luks_uuid_from_mapper_dev(lvm.mapper_path)

if self._disk_encryption.hsm_device:
Expand All @@ -1163,7 +1163,7 @@ def _get_kernel_params_lvm(
else:
debug(f'LuksOnLvm, encrypted root partition, identifying by UUID: {uuid}')
kernel_parameters.append(f'cryptdevice=UUID={uuid}:root root=/dev/mapper/root')
case EncryptionType.NoEncryption:
case EncryptionType.NO_ENCRYPTION:
debug(f'Identifying root lvm by mapper device: {lvm.dev_path}')
kernel_parameters.append(f'root={lvm.safe_dev_path}')

Expand Down
24 changes: 12 additions & 12 deletions archinstall/lib/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,19 +1400,19 @@ def json(self) -> _DeviceModificationSerialization:
}


class EncryptionType(Enum):
NoEncryption = 'no_encryption'
Luks = 'luks'
LvmOnLuks = 'lvm_on_luks'
LuksOnLvm = 'luks_on_lvm'
class EncryptionType(StrEnum):
NO_ENCRYPTION = auto()
LUKS = auto()
LVM_ON_LUKS = auto()
LUKS_ON_LVM = auto()

@classmethod
def _encryption_type_mapper(cls) -> dict[str, Self]:
return {
tr('No Encryption'): cls.NoEncryption,
tr('LUKS'): cls.Luks,
tr('LVM on LUKS'): cls.LvmOnLuks,
tr('LUKS on LVM'): cls.LuksOnLvm,
tr('No Encryption'): cls.NO_ENCRYPTION,
tr('LUKS'): cls.LUKS,
tr('LVM on LUKS'): cls.LVM_ON_LUKS,
tr('LUKS on LVM'): cls.LUKS_ON_LVM,
}

@classmethod
Expand All @@ -1436,18 +1436,18 @@ class _DiskEncryptionSerialization(TypedDict):

@dataclass
class DiskEncryption:
encryption_type: EncryptionType = EncryptionType.NoEncryption
encryption_type: EncryptionType = EncryptionType.NO_ENCRYPTION
encryption_password: Password | None = None
partitions: list[PartitionModification] = field(default_factory=list)
lvm_volumes: list[LvmVolume] = field(default_factory=list)
hsm_device: Fido2Device | None = None
iter_time: int = DEFAULT_ITER_TIME

def __post_init__(self) -> None:
if self.encryption_type in [EncryptionType.Luks, EncryptionType.LvmOnLuks] and not self.partitions:
if self.encryption_type in [EncryptionType.LUKS, EncryptionType.LVM_ON_LUKS] and not self.partitions:
raise ValueError('Luks or LvmOnLuks encryption require partitions to be defined')

if self.encryption_type == EncryptionType.LuksOnLvm and not self.lvm_volumes:
if self.encryption_type == EncryptionType.LUKS_ON_LVM and not self.lvm_volumes:
raise ValueError('LuksOnLvm encryption require LMV volumes to be defined')

def should_generate_encryption_file(self, dev: PartitionModification | LvmVolume) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion archinstall/scripts/guided.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def perform_installation(
)

if disk_config.config_type != DiskLayoutType.Pre_mount:
if disk_config.disk_encryption and disk_config.disk_encryption.encryption_type != EncryptionType.NoEncryption:
if disk_config.disk_encryption and disk_config.disk_encryption.encryption_type != EncryptionType.NO_ENCRYPTION:
# generate encryption key files for the mounted luks devices
installation.generate_key_files()

Expand Down
2 changes: 1 addition & 1 deletion examples/full_automated_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
# disk encryption configuration (Optional)
disk_encryption = DiskEncryption(
encryption_password=Password(plaintext='enc_password'),
encryption_type=EncryptionType.Luks,
encryption_type=EncryptionType.LUKS,
partitions=[home_partition],
hsm_device=None,
)
Expand Down