From 2a2817e87c38fdde711811bfd08678e6678a79ce Mon Sep 17 00:00:00 2001 From: Jiri Konecny Date: Tue, 16 Jul 2024 11:59:37 +0200 Subject: [PATCH 1/2] 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. Resolves: RHEL- --- 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 From 89fd44c02e9fd7fcb72c5c2abc34a476e43caeca Mon Sep 17 00:00:00 2001 From: Jiri Konecny Date: Tue, 16 Jul 2024 13:26:14 +0200 Subject: [PATCH 2/2] Fix trailing `/` when downloading stage2 image In Dracut the URL concatenation from .treeinfo could also point you to directory above by `..`. However, if the `inst.repo=` argument was set with trailing `/` it will create URL which is not supported by curl. Supported: `os/../BaseOS/` Unsupported by curl: `os//../BaseOS/` Remove the trailing `/` to avoid this issue. Resolves: RHEL-48821 --- dracut/anaconda-lib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dracut/anaconda-lib.sh b/dracut/anaconda-lib.sh index f7c46eb2420..a03f2356a73 100755 --- a/dracut/anaconda-lib.sh +++ b/dracut/anaconda-lib.sh @@ -112,6 +112,10 @@ anaconda_net_root() { local repo="$1" info "anaconda: fetching stage2 from $repo" + # Remove last `/` from repo to enable cunstructs like ...os/../BaseOS/image/install.img + # Otherwise curl will fail to work with `...os//../BaseOS...` + repo=${repo%/} + # Try to get the local path to stage2 from treeinfo. treeinfo=$(fetch_url "$repo/.treeinfo" 2> /tmp/treeinfo_err) && \ stage2=$(config_get stage2 mainimage < "$treeinfo")