Blame 0057-base-init.sh-don-t-mount-run-with-noexec-if-the-init.patch

Harald Hoyer b38677
From db7d61cff7f5a5be3a56cff39dc278f004b9c461 Mon Sep 17 00:00:00 2001
Harald Hoyer b38677
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer b38677
Date: Thu, 14 Apr 2016 14:56:37 +0200
Harald Hoyer b38677
Subject: [PATCH] base/init.sh: don't mount /run with noexec, if the initramfs
Harald Hoyer b38677
 lives there
Harald Hoyer b38677
Harald Hoyer b38677
If the initramfs was built with prefix=/run/... /run can't be mounted
Harald Hoyer b38677
with noexec, otherwise no binary can be run.
Harald Hoyer b38677
Harald Hoyer b38677
Guard against it by looking where /bin/sh is really located.
Harald Hoyer b38677
---
Harald Hoyer b38677
 modules.d/99base/init.sh | 7 ++++++-
Harald Hoyer b38677
 1 file changed, 6 insertions(+), 1 deletion(-)
Harald Hoyer b38677
Harald Hoyer b38677
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
Harald Hoyer b38677
index bd7ef70..a563393 100755
Harald Hoyer b38677
--- a/modules.d/99base/init.sh
Harald Hoyer b38677
+++ b/modules.d/99base/init.sh
Harald Hoyer b38677
@@ -64,7 +64,12 @@ fi
Harald Hoyer b38677
 
Harald Hoyer b38677
 if ! ismounted /run; then
Harald Hoyer b38677
     mkdir -m 0755 /newrun
Harald Hoyer b38677
-    mount -t tmpfs -o mode=0755,noexec,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
Harald Hoyer b38677
+    if ! str_starts "$(readlink -f /bin/sh)" "/run/"; then
Harald Hoyer b38677
+        mount -t tmpfs -o mode=0755,noexec,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
Harald Hoyer b38677
+    else
Harald Hoyer b38677
+        # the initramfs binaries are located in /run, so don't mount it with noexec
Harald Hoyer b38677
+        mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
Harald Hoyer b38677
+    fi
Harald Hoyer b38677
     cp -a /run/* /newrun >/dev/null 2>&1
Harald Hoyer b38677
     mount --move /newrun /run
Harald Hoyer b38677
     rm -fr -- /newrun