From f727362a90ca5e5e0f5eeed2481c3b4abffe3e83 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Nov 2019 16:36:57 +0100 Subject: [PATCH] [grubcfg] Guard against stupid configurations - Scenario: *keepDistribution* is true, and the existing file contains a GRUB_DISTRIBUTION line **followed** by a commented-out GRUB_DISTRIBUTION line. - In that case, the commented-out line would change the flag back to False, and we'd end up writing a second GRUB_DISTRIBUTION line at the end. Prevent that: the flag can only go to "True" and then stays there. Editorial: If your grub configuration would have tripped this up, then you're doing something wrong. Clean up the configuration file first. --- src/modules/grubcfg/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index 79679790c..1f2574965 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -184,7 +184,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): else: # We're not updating because of *keepDistributor*, but if # this was a comment line, then it's still not been set. - have_distributor_line = not lines[i].startsdwith("#") + have_distributor_line = have_distributor_line or not lines[i].startsdwith("#") else: lines = []