From: Alexander Tsoy Date: Sat, 8 Sep 2018 14:02:03 +0000 (+0300) Subject: Prevent environment leaking into initrd-release X-Git-Tag: 049~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b3480d31b01e66e21a70b7dab55eac95449126c7;p=thirdparty%2Fdracut.git Prevent environment leaking into initrd-release On my system the following initrd-release is generated: ... VERSION="4 dracut-048 dracut-048" ... VERSION is not defined in /etc/os-release, so the variable is concatenated with its previous value: * "4" comes from the kernel build system since dracut is called from the kernel install hook ("4" is a major kernel version); * first "dracut-048" comes from the "systemd-initrd" module; * second "dracut-048" comes from the "base" module. --- diff --git a/modules.d/01systemd-initrd/module-setup.sh b/modules.d/01systemd-initrd/module-setup.sh index c1ccd2afa..cb8a8fa6c 100755 --- a/modules.d/01systemd-initrd/module-setup.sh +++ b/modules.d/01systemd-initrd/module-setup.sh @@ -38,13 +38,12 @@ install() { ln_r "${systemdsystemunitdir}/initrd.target" "${systemdsystemunitdir}/default.target" + local VERSION="" + local PRETTY_NAME="" if [ -e /etc/os-release ]; then . /etc/os-release - VERSION+=" " - PRETTY_NAME+=" " - else - VERSION="" - PRETTY_NAME="" + [[ -n ${VERSION} ]] && VERSION+=" " + [[ -n ${PRETTY_NAME} ]] && PRETTY_NAME+=" " fi NAME=dracut ID=dracut diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh index 731c6dccc..21523fc9d 100755 --- a/modules.d/99base/module-setup.sh +++ b/modules.d/99base/module-setup.sh @@ -63,13 +63,12 @@ install() { echo ro >> "${initdir}/etc/cmdline.d/base.conf" fi + local VERSION="" + local PRETTY_NAME="" if [ -e /etc/os-release ]; then . /etc/os-release - VERSION+=" " - PRETTY_NAME+=" " - else - VERSION="" - PRETTY_NAME="" + [[ -n ${VERSION} ]] && VERSION+=" " + [[ -n ${PRETTY_NAME} ]] && PRETTY_NAME+=" " fi NAME=dracut ID=dracut