Blame 0167-Revert-Let-user-specify-the-action-after-fail.patch

Harald Hoyer bb31e7
From 687000767464401261f336d118de9bba7f50e88d Mon Sep 17 00:00:00 2001
Harald Hoyer bb31e7
From: "dyoung@redhat.com" <dyoung@redhat.com>
Harald Hoyer bb31e7
Date: Mon, 31 Aug 2015 10:43:20 +0800
Harald Hoyer bb31e7
Subject: [PATCH] Revert "Let user specify the action after fail"
Harald Hoyer bb31e7
Harald Hoyer bb31e7
This reverts commit 9d787df19674937e8c07bd295b5d282a63829209
Harald Hoyer bb31e7
Harald Hoyer bb31e7
action_on_fail is useless thus remove the commits for it one by one.
Harald Hoyer bb31e7
Harald Hoyer bb31e7
Signed-off-by: Dave Young <dyoung@redhat.com>
Harald Hoyer bb31e7
---
Harald Hoyer bb31e7
 dracut.cmdline.7.asc                           |  4 ----
Harald Hoyer bb31e7
 modules.d/95rootfs-block/mount-root.sh         |  2 +-
Harald Hoyer bb31e7
 modules.d/98dracut-systemd/dracut-initqueue.sh |  2 +-
Harald Hoyer bb31e7
 modules.d/98dracut-systemd/dracut-mount.sh     |  2 +-
Harald Hoyer bb31e7
 modules.d/98selinux/selinux-loadpolicy.sh      |  6 ++++--
Harald Hoyer bb31e7
 modules.d/98usrmount/mount-usr.sh              |  4 ++--
Harald Hoyer bb31e7
 modules.d/99base/dracut-lib.sh                 | 22 ----------------------
Harald Hoyer bb31e7
 modules.d/99base/init.sh                       | 12 ++++++------
Harald Hoyer bb31e7
 8 files changed, 15 insertions(+), 39 deletions(-)
Harald Hoyer bb31e7
Harald Hoyer bb31e7
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
Harald Hoyer bb31e7
index cd8cc66..d790afd 100644
Harald Hoyer bb31e7
--- a/dracut.cmdline.7.asc
Harald Hoyer bb31e7
+++ b/dracut.cmdline.7.asc
Harald Hoyer bb31e7
@@ -159,10 +159,6 @@ Misc
Harald Hoyer bb31e7
    specify the controlling terminal for the console.
Harald Hoyer bb31e7
    This is useful, if you have multiple "console=" arguments.
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
-**action_on_fail=**_{shell|continue}_::
Harald Hoyer bb31e7
-   Specify the action after failure. By default it's emergency_shell.
Harald Hoyer bb31e7
-   'continue' means: ignore the current failure and go ahead.
Harald Hoyer bb31e7
-
Harald Hoyer bb31e7
 [[dracutkerneldebug]]
Harald Hoyer bb31e7
 Debug
Harald Hoyer bb31e7
 ~~~~~
Harald Hoyer bb31e7
diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh
Harald Hoyer bb31e7
index 7e9c5bb..924393b 100755
Harald Hoyer bb31e7
--- a/modules.d/95rootfs-block/mount-root.sh
Harald Hoyer bb31e7
+++ b/modules.d/95rootfs-block/mount-root.sh
Harald Hoyer bb31e7
@@ -66,7 +66,7 @@ mount_root() {
Harald Hoyer bb31e7
                 warn "*** Warning -- the system did not shut down cleanly. "
Harald Hoyer bb31e7
                 warn "*** Dropping you to a shell; the system will continue"
Harald Hoyer bb31e7
                 warn "*** when you leave the shell."
Harald Hoyer bb31e7
-                action_on_fail
Harald Hoyer bb31e7
+                emergency_shell
Harald Hoyer bb31e7
             fi
Harald Hoyer bb31e7
             fsckoptions="$AUTOFSCK_OPT $fsckoptions"
Harald Hoyer bb31e7
         fi
Harald Hoyer bb31e7
diff --git a/modules.d/98dracut-systemd/dracut-initqueue.sh b/modules.d/98dracut-systemd/dracut-initqueue.sh
Harald Hoyer bb31e7
index 881f639..3ddc236 100755
Harald Hoyer bb31e7
--- a/modules.d/98dracut-systemd/dracut-initqueue.sh
Harald Hoyer bb31e7
+++ b/modules.d/98dracut-systemd/dracut-initqueue.sh
Harald Hoyer bb31e7
@@ -68,7 +68,7 @@ while :; do
Harald Hoyer bb31e7
     main_loop=$(($main_loop+1))
Harald Hoyer bb31e7
     if [ $main_loop -gt $RDRETRY ]; then
Harald Hoyer bb31e7
         if ! [ -f /sysroot/etc/fstab ] || ! [ -e /sysroot/sbin/init ] ; then
Harald Hoyer bb31e7
-            action_on_fail "Could not boot." && break
Harald Hoyer bb31e7
+            emergency_shell "Could not boot."
Harald Hoyer bb31e7
         fi
Harald Hoyer bb31e7
         warn "Not all disks have been found."
Harald Hoyer bb31e7
         warn "You might want to regenerate your initramfs."
Harald Hoyer bb31e7
diff --git a/modules.d/98dracut-systemd/dracut-mount.sh b/modules.d/98dracut-systemd/dracut-mount.sh
Harald Hoyer bb31e7
index 11ba7bc..c4febfe 100755
Harald Hoyer bb31e7
--- a/modules.d/98dracut-systemd/dracut-mount.sh
Harald Hoyer bb31e7
+++ b/modules.d/98dracut-systemd/dracut-mount.sh
Harald Hoyer bb31e7
@@ -29,7 +29,7 @@ while :; do
Harald Hoyer bb31e7
     done
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
     i=$(($i+1))
Harald Hoyer bb31e7
-    [ $i -gt 20 ] && action_on_fail "Can't mount root filesystem" && break
Harald Hoyer bb31e7
+    [ $i -gt 20 ] && emergency_shell "Can't mount root filesystem"
Harald Hoyer bb31e7
 done
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
 export -p > /dracut-state.sh
Harald Hoyer bb31e7
diff --git a/modules.d/98selinux/selinux-loadpolicy.sh b/modules.d/98selinux/selinux-loadpolicy.sh
Harald Hoyer bb31e7
index d0ac834..ca81a38 100755
Harald Hoyer bb31e7
--- a/modules.d/98selinux/selinux-loadpolicy.sh
Harald Hoyer bb31e7
+++ b/modules.d/98selinux/selinux-loadpolicy.sh
Harald Hoyer bb31e7
@@ -54,14 +54,16 @@ rd_load_policy()
Harald Hoyer bb31e7
         if [ $ret -eq 3 -o $permissive -eq 0 ]; then
Harald Hoyer bb31e7
             warn "Machine in enforcing mode."
Harald Hoyer bb31e7
             warn "Not continuing"
Harald Hoyer bb31e7
-            action_on_fail -n selinux || exit 1
Harald Hoyer bb31e7
+            emergency_shell -n selinux
Harald Hoyer bb31e7
+            exit 1
Harald Hoyer bb31e7
         fi
Harald Hoyer bb31e7
         return 0
Harald Hoyer bb31e7
     elif [ $permissive -eq 0 -a "$SELINUX" != "disabled" ]; then
Harald Hoyer bb31e7
         warn "Machine in enforcing mode and cannot execute load_policy."
Harald Hoyer bb31e7
         warn "To disable selinux, add selinux=0 to the kernel command line."
Harald Hoyer bb31e7
         warn "Not continuing"
Harald Hoyer bb31e7
-        action_on_fail -n selinux || exit 1
Harald Hoyer bb31e7
+        emergency_shell -n selinux
Harald Hoyer bb31e7
+        exit 1
Harald Hoyer bb31e7
     fi
Harald Hoyer bb31e7
 }
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
diff --git a/modules.d/98usrmount/mount-usr.sh b/modules.d/98usrmount/mount-usr.sh
Harald Hoyer bb31e7
index d1a629c..1699604 100755
Harald Hoyer bb31e7
--- a/modules.d/98usrmount/mount-usr.sh
Harald Hoyer bb31e7
+++ b/modules.d/98usrmount/mount-usr.sh
Harald Hoyer bb31e7
@@ -40,7 +40,7 @@ fsck_usr()
Harald Hoyer bb31e7
             warn "*** Warning -- the system did not shut down cleanly. "
Harald Hoyer bb31e7
             warn "*** Dropping you to a shell; the system will continue"
Harald Hoyer bb31e7
             warn "*** when you leave the shell."
Harald Hoyer bb31e7
-            action_on_fail
Harald Hoyer bb31e7
+            emergency_shell
Harald Hoyer bb31e7
         fi
Harald Hoyer bb31e7
         _fsckoptions="$AUTOFSCK_OPT $_fsckoptions"
Harald Hoyer bb31e7
     fi
Harald Hoyer bb31e7
@@ -103,7 +103,7 @@ mount_usr()
Harald Hoyer bb31e7
             warn "Mounting /usr to $NEWROOT/usr failed"
Harald Hoyer bb31e7
             warn "*** Dropping you to a shell; the system will continue"
Harald Hoyer bb31e7
             warn "*** when you leave the shell."
Harald Hoyer bb31e7
-            action_on_fail
Harald Hoyer bb31e7
+            emergency_shell
Harald Hoyer bb31e7
         fi
Harald Hoyer bb31e7
     fi
Harald Hoyer bb31e7
 }
Harald Hoyer bb31e7
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer bb31e7
index 1ac9b3c..d3a7b59 100755
Harald Hoyer bb31e7
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer bb31e7
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer bb31e7
@@ -1141,28 +1141,6 @@ emergency_shell()
Harald Hoyer bb31e7
     fi
Harald Hoyer bb31e7
 }
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
-action_on_fail()
Harald Hoyer bb31e7
-{
Harald Hoyer bb31e7
-    local _action=$(getarg action_on_fail=)
Harald Hoyer bb31e7
-    case "$_action" in
Harald Hoyer bb31e7
-        continue)
Harald Hoyer bb31e7
-            [ "$1" = "-n" ] && shift 2
Harald Hoyer bb31e7
-            [ "$1" = "--shutdown" ] && shift 2
Harald Hoyer bb31e7
-            warn "$*"
Harald Hoyer bb31e7
-            warn "Not dropping to emergency shell, because 'action_on_fail=continue' was set on the kernel command line."
Harald Hoyer bb31e7
-            return 0
Harald Hoyer bb31e7
-            ;;
Harald Hoyer bb31e7
-        shell)
Harald Hoyer bb31e7
-            emergency_shell $@
Harald Hoyer bb31e7
-            return 1
Harald Hoyer bb31e7
-            ;;
Harald Hoyer bb31e7
-        *)
Harald Hoyer bb31e7
-            emergency_shell $@
Harald Hoyer bb31e7
-            return 1
Harald Hoyer bb31e7
-            ;;
Harald Hoyer bb31e7
-    esac
Harald Hoyer bb31e7
-}
Harald Hoyer bb31e7
-
Harald Hoyer bb31e7
 # Retain the values of these variables but ensure that they are unexported
Harald Hoyer bb31e7
 # This is a POSIX-compliant equivalent of bash's "export -n"
Harald Hoyer bb31e7
 export_n()
Harald Hoyer bb31e7
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
Harald Hoyer bb31e7
index a59e8ea..e2e4029 100755
Harald Hoyer bb31e7
--- a/modules.d/99base/init.sh
Harald Hoyer bb31e7
+++ b/modules.d/99base/init.sh
Harald Hoyer bb31e7
@@ -85,7 +85,7 @@ if command -v kmod >/dev/null 2>/dev/null; then
Harald Hoyer bb31e7
         done
Harald Hoyer bb31e7
 fi
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
-trap "action_on_fail Signal caught!" 0
Harald Hoyer bb31e7
+trap "emergency_shell Signal caught!" 0
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
 export UDEVVERSION=$(udevadm --version)
Harald Hoyer bb31e7
 if [ $UDEVVERSION -gt 166 ]; then
Harald Hoyer bb31e7
@@ -214,7 +214,7 @@ while :; do
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
     main_loop=$(($main_loop+1))
Harald Hoyer bb31e7
     [ $main_loop -gt $RDRETRY ] \
Harald Hoyer bb31e7
-        && { flock -s 9 ; action_on_fail "Could not boot." && break; } 9>/.console_lock
Harald Hoyer bb31e7
+        && { flock -s 9 ; emergency_shell "Could not boot."; } 9>/.console_lock
Harald Hoyer bb31e7
 done
Harald Hoyer bb31e7
 unset job
Harald Hoyer bb31e7
 unset queuetriggered
Harald Hoyer bb31e7
@@ -249,7 +249,7 @@ while :; do
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
     _i_mount=$(($_i_mount+1))
Harald Hoyer bb31e7
     [ $_i_mount -gt 20 ] \
Harald Hoyer bb31e7
-        && { flock -s 9 ; action_on_fail "Can't mount root filesystem" && break; } 9>/.console_lock
Harald Hoyer bb31e7
+        && { flock -s 9 ; emergency_shell "Can't mount root filesystem"; } 9>/.console_lock
Harald Hoyer bb31e7
 done
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
 {
Harald Hoyer bb31e7
@@ -283,7 +283,7 @@ done
Harald Hoyer bb31e7
 [ "$INIT" ] || {
Harald Hoyer bb31e7
     echo "Cannot find init!"
Harald Hoyer bb31e7
     echo "Please check to make sure you passed a valid root filesystem!"
Harald Hoyer bb31e7
-    action_on_fail
Harald Hoyer bb31e7
+    emergency_shell
Harald Hoyer bb31e7
 }
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
 if [ $UDEVVERSION -lt 168 ]; then
Harald Hoyer bb31e7
@@ -387,13 +387,13 @@ if [ -f /etc/capsdrop ]; then
Harald Hoyer bb31e7
 	warn "Command:"
Harald Hoyer bb31e7
 	warn capsh --drop=$CAPS_INIT_DROP -- -c exec switch_root "$NEWROOT" "$INIT" $initargs
Harald Hoyer bb31e7
 	warn "failed."
Harald Hoyer bb31e7
-	action_on_fail
Harald Hoyer bb31e7
+	emergency_shell
Harald Hoyer bb31e7
     }
Harald Hoyer bb31e7
 else
Harald Hoyer bb31e7
     unset RD_DEBUG
Harald Hoyer bb31e7
     exec $SWITCH_ROOT "$NEWROOT" "$INIT" $initargs || {
Harald Hoyer bb31e7
 	warn "Something went very badly wrong in the initramfs.  Please "
Harald Hoyer bb31e7
 	warn "file a bug against dracut."
Harald Hoyer bb31e7
-	action_on_fail
Harald Hoyer bb31e7
+	emergency_shell
Harald Hoyer bb31e7
     }
Harald Hoyer bb31e7
 fi