File 0176-Parse-rootflags-correctly.patch of Package dracut.376

From d15ca6119125b015bddb2919b898b4d0e2aeccbf Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Thu, 12 Feb 2015 09:43:01 +0100
Subject: Parse rootflags correctly

The patch removes systemd-fstab-generator for the system-generators
directory so that it won't get started automatically.
It will be called by dracut-rootfs-generator if root= and rootflags=
are given at the command line.
Otherwise, dracut-rootfs-generator will create the sysroot.mount unit.
and sets the mount of /sysroot to readonly.

References: bnc#912734

Signed-off-by: Thomas Blume <thomas.blume@suse.com>
---
 modules.d/98systemd/module-setup.sh     |  2 +-
 modules.d/98systemd/rootfs-generator.sh | 13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/modules.d/98systemd/module-setup.sh b/modules.d/98systemd/module-setup.sh
index 4516b9a..bf1e8e6 100755
--- a/modules.d/98systemd/module-setup.sh
+++ b/modules.d/98systemd/module-setup.sh
@@ -43,7 +43,6 @@ install() {
         $systemdutildir/systemd-sysctl \
         $systemdutildir/systemd-modules-load \
         $systemdutildir/systemd-vconsole-setup \
-        $systemdutildir/system-generators/systemd-fstab-generator \
         $systemdutildir/system-generators/systemd-gpt-auto-generator \
         \
         $systemdsystemunitdir/cryptsetup.target \
@@ -193,6 +192,7 @@ install() {
     inst_script "$moddir/dracut-pre-pivot.sh" /bin/dracut-pre-pivot
 
     inst_script "$moddir/rootfs-generator.sh" $systemdutildir/system-generators/dracut-rootfs-generator
+    inst_simple "$systemdutildir/system-generators/systemd-fstab-generator" $systemdutildir/system-generator-helper/systemd-fstab-generator
 
     inst_binary true
     ln_r $(type -P true) "/usr/bin/loginctl"
diff --git a/modules.d/98systemd/rootfs-generator.sh b/modules.d/98systemd/rootfs-generator.sh
index d9b7be2..f221dc7 100755
--- a/modules.d/98systemd/rootfs-generator.sh
+++ b/modules.d/98systemd/rootfs-generator.sh
@@ -47,7 +47,16 @@ generator_mount_rootfs()
 
     _name=$(dev_unit_name "$1")
     [ -d /run/systemd/generator ] || mkdir -p /run/systemd/generator
-    if ! [ -f /run/systemd/generator/sysroot.mount ]; then
+
+    #only run systemd-fstab-generator if root= and rootflags= are present
+    if [ $(sed -n  '/root=/!{q1}') ] && [ $(getarg rootflags=) ]; then
+        /usr/lib/systemd/system-generator-helper/systemd-fstab-generator /run/systemd/generator NULL NULL
+    else
+        #make sure that the initial mount is ro
+        for i in $(echo $_flags | sed 's/,/ /g'); do
+           [[ $i == rw ]] || [[ $i == ro ]] || rootflags="$rootflags,$i"
+        done
+        _flags=" ${rootflags#,},ro"
         {
             echo "[Unit]"
             echo "Before=initrd-root-fs.target"
@@ -113,7 +122,7 @@ if [ "${root%%:*}" = "block" ]; then
    generator_wait_for_dev "${root#block:}" "$RDRETRY"
    generator_fsck_after_pre_mount "${root#block:}"
    cmdline=$(</proc/cmdline)
-   test "$cmdline" = "${cmdline#*root=}" && generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
+   generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
 fi
 
 exit 0
-- 
1.8.4.5

openSUSE Build Service is sponsored by