From eb6bb49d5a61de3c1263bb7d4d08bf3472e5714f Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Thu, 13 Oct 2016 19:01:13 +0200 Subject: [PATCH] [fstab] Write configurable options to crypttab (default: luks). fstab.conf: Add a new "crypttabOptions" option that defaults to "luks". Document that for Debian and Debian-based distributions, the setting should be changed to "luks,keyscript=/bin/cat". main.py: Append the options from the above setting to the end of every line in crypttab. At least the "luks" option should always be there, because there may be different encryption types. The Debian initramfs-tools also require the Debian-specific keyscript option and will otherwise ignore the keyfile entirely (see pull request #254). --- src/modules/fstab/fstab.conf | 3 +++ src/modules/fstab/main.py | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/modules/fstab/fstab.conf b/src/modules/fstab/fstab.conf index 7dbf52975..c3dbfc309 100644 --- a/src/modules/fstab/fstab.conf +++ b/src/modules/fstab/fstab.conf @@ -8,3 +8,6 @@ ssdExtraMountOptions: xfs: discard swap: discard btrfs: discard,compress=lzo +crypttabOptions: luks +# For Debian and Debian-based distributions, change the above line to: +# crypttabOptions: luks,keyscript=/bin/cat diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index 528a8487f..05b094fdc 100644 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -102,11 +102,13 @@ class FstabGenerator(object): :param mount_options: :param ssd_extra_mount_options: """ - def __init__(self, partitions, root_mount_point, mount_options, ssd_extra_mount_options): + def __init__(self, partitions, root_mount_point, mount_options, + ssd_extra_mount_options, crypttab_options): self.partitions = partitions self.root_mount_point = root_mount_point self.mount_options = mount_options self.ssd_extra_mount_options = ssd_extra_mount_options + self.crypttab_options = crypttab_options self.ssd_disks = set() self.root_is_ssd = False @@ -156,14 +158,16 @@ class FstabGenerator(object): name=mapper_name, device="UUID=" + luks_uuid, password="/crypto_keyfile.bin", + options=self.crypttab_options, ) def print_crypttab_line(self, dct, file=None): """ Prints line to '/etc/crypttab' file. """ - line = "{:21} {:<45} {}".format(dct["name"], - dct["device"], - dct["password"], - ) + line = "{:21} {:<45} {} {}".format(dct["name"], + dct["device"], + dct["password"], + dct["options"], + ) print(line, file=file) @@ -255,9 +259,11 @@ def run(): root_mount_point = global_storage.value("rootMountPoint") mount_options = conf["mountOptions"] ssd_extra_mount_options = conf.get("ssdExtraMountOptions", {}) + crypttab_options = conf.get("crypttabOptions", "luks") generator = FstabGenerator(partitions, root_mount_point, mount_options, - ssd_extra_mount_options) + ssd_extra_mount_options, + crypttab_options) return generator.run()