Skip to content

Commit 5c9b9fe

Browse files
committed
Merge remote-tracking branch 'origin/main' into tests
2 parents 9fda116 + 6aba724 commit 5c9b9fe

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

examples/example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This config will decrypt the LUKS volume with uuid "fdf442da-0574-4531-98c7-55227a041f1d", mapping it to "/dev/mapper/root"
2-
# It will attempt to mount the btrfs volume with label "rootfs" to /mnt/root
2+
# It will attempt to mount the btrfs volume with label "rootfs" to /target_rootfs
33
# It will pull all current kernel modules from lspci -k results
44
# It will try to process the cmdline and mount the rootfs based on the root= parameter
55

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ Similarly `ugrd.kmod.novideo` `nonetwork`, and `nosound` exist to ignore video,
354354

355355
`mounts`: A dictionary containing entries for mounts, with their associated config.
356356

357-
`mounts.root` is predefined to have a destination of `/mnt/root` and defines the root filesystem mount, used by `switch_root`.
357+
`mounts.root` is predefined to have a destination of `/target_rootfs` and defines the root filesystem mount, used by `switch_root`.
358358

359359
Each mount has the following available parameters:
360360

@@ -413,7 +413,7 @@ Importing this module will run `btrfs device scan` and pull btrfs modules.
413413
* `subvol_selector` (false) The root subvolume will be selected at runtime based on existing subvolumes. Overridden by `root_subvol`.
414414
* `autodetect_root_subvol` (true) Autodetect the root subvolume, unless `root_subvol` or `subvol_selector` is set. Depends on `hostonly`.
415415
* `root_subvol` - Set the desired root subvolume.
416-
* `_base_mount_path` (/mnt/root_base) Sets where the subvolume selector mounts the base filesytem to scan for subvolumes.
416+
* `_base_mount_path` (/root_base) Sets where the subvolume selector mounts the base filesytem to scan for subvolumes.
417417

418418
### Cryptographic modules
419419

@@ -488,6 +488,7 @@ Cryptsetup global config:
488488
* `cryptsetup_prompt` (false) Whether or not to prompt the user to press enter before attempting to unlock a device.
489489
* `cryptsetup_autoretry` (false) Whether or not to automatically retry mount attempts.
490490
* `cryptsetup_trim` (false) Whether or not to pass `--allow-discards` to cryptsetup (reduces security).
491+
* `cryptsetup_keyfile_validation` (true) Whether or not to validate that keyfiles should exist at runtime.
491492

492493
##### Key type definitions
493494

src/ugrd/crypto/cryptsetup.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '2.4.2'
2+
__version__ = '2.5.0'
33

44
from zenlib.util import check_dict
55

@@ -49,12 +49,18 @@ def _validate_crypysetup_key(self, key_paramters: dict) -> None:
4949
key_path = Path(key_paramters['key_file'])
5050

5151
if not key_path.is_file():
52-
raise FileNotFoundError("Key file not found: %s" % key_path)
52+
if self['cryptsetup_keyfile_validation']:
53+
raise FileNotFoundError("Key file not found: %s" % key_path)
54+
else:
55+
return self.logger.error("Key file not found: %s" % key_path)
5356

5457
key_copy = key_path
5558
while parent := key_copy.parent:
5659
if parent == Path('/'):
57-
raise ValueError("No mount is defined for external key file: %s" % key_path)
60+
if self['cryptsetup_keyfile_validation']:
61+
raise ValueError("No mount is defined for external key file: %s" % key_path)
62+
else:
63+
return self.logger.critical("No mount is defined for external key file: %s" % key_path)
5864
if str(parent).lstrip('/') in self['mounts']:
5965
self.logger.debug("Found mount for key file: %s" % parent)
6066
break

src/ugrd/crypto/cryptsetup.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ cryptsetup_retries = 5
1010
cryptsetup_autoretry = true
1111
cryptsetup_prompt = true
1212

13+
cryptsetup_keyfile_validation = true
14+
1315
[imports.config_processing]
1416
"ugrd.crypto.cryptsetup" = [ "_process_cryptsetup_multi", "_process_cryptsetup_key_types_multi" ]
1517

@@ -27,6 +29,7 @@ key_command = "cat {key_file} |"
2729

2830
[custom_parameters]
2931
cryptsetup_key_type = "str" # The default key type to use for unlocking devices
32+
cryptsetup_keyfile_validation = "bool" # Whether to validate the key file
3033
cryptsetup_key_types = "dict" # Dict containing key types and their associated mount commands
3134
cryptsetup_retries = "int" # Number of times to retry unlocking a device
3235
cryptsetup_prompt = "bool" # Whether to prompt the user to press enter before unlocking devices

src/ugrd/fs/btrfs.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
binaries = [ "btrfs" ]
22
kmod_init = "btrfs"
33

4-
_base_mount_path = "/mnt/root_base"
4+
_base_mount_path = "/root_base"
55
subvol_selector = false
66
autodetect_root_subvol = true
77

src/ugrd/fs/mounts.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ _blkid_info = "dict" # The blkid information
6161
# Define the base of the root mount
6262
[mounts.root]
6363
options = ['ro']
64-
destination = "/mnt/root"
64+
destination = "/target_rootfs"
6565

6666
# Define the default mounts
6767
# The format is mounts.mount where the mount is the name of the mount

0 commit comments

Comments
 (0)