From e186e54434af6058e0f8d841a8ddca8aa75ba684 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 24 May 2021 22:16:54 +0200 Subject: [PATCH] [fstab] Don't fail with a KeyError in misconfigured installations Use get() instead of [] to avoid KeyError when the host system confuguration is entirely missing a setting for *mountOptions*. FIXES #1702 --- src/modules/fstab/main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index b6d7a4b2a..61f6b0e9f 100644 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -372,15 +372,23 @@ def run(): root_btrfs = (root_partitions[0] == "btrfs") if root_partitions else False if root_btrfs: partitions.append( dict(fs="swap", mountPoint=None, claimed=True, device="/swap/swapfile", uuid=None) ) - else: + else: partitions.append( dict(fs="swap", mountPoint=None, claimed=True, device="/swapfile", uuid=None) ) else: swap_choice = None libcalamares.job.setprogress(0.1) - mount_options = conf["mountOptions"] + mount_options = conf.get("mountOptions", {}) ssd_extra_mount_options = conf.get("ssdExtraMountOptions", {}) crypttab_options = conf.get("crypttabOptions", "luks") + + # We rely on mount_options having a default; if there wasn't one, + # bail out with a meaningful error. + if not mount_options: + return (_("Configuration Error"), + _("No
{!s}
configuration is given for
{!s}
to use.") + .format("mountOptions", "fstab")) + generator = FstabGenerator(partitions, root_mount_point, mount_options,