]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Prevent environment leaking into initrd-release
authorAlexander Tsoy <alexander@tsoy.me>
Sat, 8 Sep 2018 14:02:03 +0000 (17:02 +0300)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 10 Sep 2018 07:42:36 +0000 (09:42 +0200)
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.

modules.d/01systemd-initrd/module-setup.sh
modules.d/99base/module-setup.sh

index c1ccd2afae77c16712326da08dfd7c464c20c16e..cb8a8fa6c23aec36cd8a944d358f14650f686a8a 100755 (executable)
@@ -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
index 731c6dccc53c06c26ae84e289a6926886c84949c..21523fc9dcc146b361820b78f80fdb518aa0e34a 100755 (executable)
@@ -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