From e2b6851736722dcb80aa4d9c54efac1d11afaa6d Mon Sep 17 00:00:00 2001 From: Jiri Konecny Date: Tue, 16 Jul 2024 11:59:37 +0200 Subject: [PATCH] Fix whitespace chars broke Dracut config parsing With commit 0785531e40c20404d24f1511b37a797b4fca3d7f the `get_config` function in anaconda-lib.sh was broken because missing quotes removed leading and trailing whitespace characters automatically but after the fix in commit mentioned above this side effect was fixed which lead in broken code. In other words the key were never matched because of trailing whitespace. Issue raised by this is not being able to read .treeinfo and .buildstamp files in Dracut. Example of such situation is broken boot when stage2 image is stored under special path mentioned in .treeinfo file. --- dracut/anaconda-lib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dracut/anaconda-lib.sh b/dracut/anaconda-lib.sh index e91e7f65137..f7c46eb2420 100755 --- a/dracut/anaconda-lib.sh +++ b/dracut/anaconda-lib.sh @@ -26,6 +26,10 @@ config_get() { \[*\]*) cursec="${line#[}"; cursec="${cursec%%]*}" ;; *=*) k="${line%%=*}"; v="${line#*=}" ;; esac + # trim leading and trailing whitespace characters + k=$(echo "$k" | sed 's/^ *//;s/ *$//') + v=$(echo "$v" | sed 's/^ *//;s/ *$//') + if [ "$cursec" = "$section" ] && [ "$k" == "$key" ]; then echo "$v" break