]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
cope with "rd.shell=0" in the testsuite
authorHarald Hoyer <harald@redhat.com>
Wed, 8 Jun 2016 07:33:48 +0000 (09:33 +0200)
committerHarald Hoyer <harald@redhat.com>
Wed, 8 Jun 2016 14:48:07 +0000 (16:48 +0200)
If emergency and shutdown-emergency hooks are called, the systemd should
poweroff the testsuite, therefore "rd.shell=0" is given on the test
suite kernel command lines.

"rd.shell=0" has to be parsed correctly by the test suite real root init
also.

45 files changed:
test/TEST-01-BASIC/hard-off.sh
test/TEST-01-BASIC/test-init.sh
test/TEST-01-BASIC/test.sh
test/TEST-02-SYSTEMD/hard-off.sh
test/TEST-02-SYSTEMD/test-init.sh
test/TEST-02-SYSTEMD/test.sh
test/TEST-03-USR-MOUNT/hard-off.sh
test/TEST-03-USR-MOUNT/test-init.sh
test/TEST-03-USR-MOUNT/test.sh
test/TEST-04-FULL-SYSTEMD/hard-off.sh
test/TEST-04-FULL-SYSTEMD/test-init.sh
test/TEST-04-FULL-SYSTEMD/test.sh
test/TEST-10-RAID/hard-off.sh
test/TEST-10-RAID/test-init.sh
test/TEST-10-RAID/test.sh
test/TEST-11-LVM/hard-off.sh
test/TEST-11-LVM/test-init.sh
test/TEST-11-LVM/test.sh
test/TEST-12-RAID-DEG/hard-off.sh
test/TEST-12-RAID-DEG/test-init.sh
test/TEST-12-RAID-DEG/test.sh
test/TEST-13-ENC-RAID-LVM/hard-off.sh
test/TEST-13-ENC-RAID-LVM/test.sh
test/TEST-14-IMSM/hard-off.sh
test/TEST-14-IMSM/test-init.sh
test/TEST-14-IMSM/test.sh
test/TEST-15-BTRFSRAID/hard-off.sh
test/TEST-15-BTRFSRAID/test.sh
test/TEST-16-DMSQUASH/hard-off.sh
test/TEST-16-DMSQUASH/test-init.sh
test/TEST-16-DMSQUASH/test.sh
test/TEST-17-LVM-THIN/hard-off.sh
test/TEST-17-LVM-THIN/test-init.sh
test/TEST-17-LVM-THIN/test.sh
test/TEST-20-NFS/client-init.sh
test/TEST-20-NFS/hard-off.sh
test/TEST-20-NFS/test.sh
test/TEST-30-ISCSI/client-init.sh
test/TEST-30-ISCSI/hard-off.sh
test/TEST-30-ISCSI/test.sh
test/TEST-40-NBD/hard-off.sh
test/TEST-40-NBD/test.sh
test/TEST-50-MULTINIC/client-init.sh
test/TEST-50-MULTINIC/hard-off.sh
test/TEST-50-MULTINIC/test.sh

index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index ef196ecbc38a103bf3c46daf7b9c0a41b4646b96..a8b6e393ace145a0ae5509170bd97810bf57cae1 100755 (executable)
@@ -1,5 +1,100 @@
 #!/bin/sh
 >/dev/watchdog
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
@@ -12,7 +107,7 @@ export PS1='initramfs-test:\w\$ '
 [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-if strstr "$CMDLINE" "rd.shell"; then
+if getargbool 0 rd.shell; then
        strstr "$(setsid --help)" "control" && CTTY="-c"
        setsid $CTTY sh -i
 fi
index 959ac05dddd8156d4828753d204e7b84451351ac..ab840744b96878a36c5ebb5216e7aa11ce09a845 100755 (executable)
@@ -14,7 +14,7 @@ test_run() {
        -m 256M -smp 2 -nographic \
        -net none \
        -watchdog i6300esb -watchdog-action poweroff \
-       -append "root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 $DEBUGFAIL" \
+       -append "root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing || return 1
     grep -F -m 1 -q dracut-root-block-success $TESTDIR/result || return 1
 }
@@ -90,6 +90,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index b7e01921903c33e16e290a0911e00c041f65c546..0999bc0260c65e3b5a62cf2df37be67555380966 100755 (executable)
@@ -1,4 +1,102 @@
 #!/bin/sh
+
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
+
+
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
@@ -11,7 +109,7 @@ export PS1='initramfs-test:\w\$ '
 [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-if strstr "$CMDLINE" "rd.shell"; then
+if getargbool 0 rd.shell; then
        strstr "$(setsid --help)" "control" && CTTY="-c"
        setsid $CTTY sh -i
 fi
index 6dc6f42ef2ff74364b157db04c6bb42b13563fcc..350cff8c19af4c7a44bcd8d7b2df25feacb1b013 100755 (executable)
@@ -10,7 +10,7 @@ test_run() {
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
        -m 256M -smp 2 -nographic \
        -net none \
-       -append "root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug init=/sbin/init $DEBUGFAIL" \
+       -append "root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug init=/sbin/init rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing
     grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1
 }
@@ -87,6 +87,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index 48fbfeaf60d9da5bb66c85e37e0e255ef60305ba..68eaff05647bbeedfd68b1adac4af15e8107392b 100755 (executable)
@@ -1,5 +1,100 @@
 #!/bin/sh
 >/dev/watchdog
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
@@ -22,7 +117,7 @@ export PS1='initramfs-test:\w\$ '
 [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-if strstr "$CMDLINE" "rd.shell"; then
+if getargbool 0 rd.shell; then
        strstr "$(setsid --help)" "control" && CTTY="-c"
        setsid $CTTY sh -i
 fi
index 0aca8cf1013db1f9fe64d9c0be31007f97a50811..ed76d3540b78603ba93ac34f407145c4fe62cc3d 100755 (executable)
@@ -21,7 +21,7 @@ client_run() {
        -m 256M -smp 2 -nographic \
        -net none \
        -watchdog i6300esb -watchdog-action poweroff \
-       -append "root=LABEL=dracut $client_opts quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
+       -append "root=LABEL=dracut $client_opts quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing
 
     if (($? != 0)); then
@@ -125,6 +125,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index ad516f1f5cc18ae33b17f99bfe0c340b6d6498e5..e388afca605d88d8b1e9eb0ff1ec177bbd1bd2a1 100755 (executable)
@@ -1,5 +1,100 @@
 #!/bin/sh
 >/dev/watchdog
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
@@ -35,7 +130,7 @@ export PS1='initramfs-test:\w\$ '
 [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-if strstr "$CMDLINE" "rd.shell"; then
+if getargbool 0 rd.shell; then
 #      while sleep 1; do sleep 1;done
        strstr "$(setsid --help)" "control" && CTTY="-c"
        setsid $CTTY sh -i
index 884f4412f83440fa54f91b0007b6967b5ad3f183..88711eff2b7153ad14a127b00b8505809a922e96 100755 (executable)
@@ -22,7 +22,7 @@ client_run() {
        -drive format=raw,index=2,media=disk,file=$TESTDIR/result \
        -m 256M -smp 2 -nographic \
        -net none \
-       -append "root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT $DEBUGFAIL" \
+       -append "root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing
 
     if (($? != 0)); then
@@ -262,6 +262,7 @@ EOF
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
 
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index c7c114e745346f80d008eaeeb48c00da7fb631f8..7eb932a04468e780fa6f11b60fbba0cd21e5d97c 100755 (executable)
@@ -1,5 +1,100 @@
 #!/bin/sh
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
 command -v plymouth >/dev/null && plymouth --quit
@@ -11,7 +106,7 @@ export PS1='initramfs-test:\w\$ '
 [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-strstr "$CMDLINE" "rd.shell" && sh -i
+getargbool 0 rd.shell && sh -i
 echo "Powering down."
 mount -n -o remount,ro /
 #echo " rd.break=shutdown " >> /run/initramfs/etc/cmdline
index 6ec77a68d3e5a8c7b883d668da2c0d4f69b954b4..2d09314ccfc13e1ce5b852aa7fd07f0a2daaee5a 100755 (executable)
@@ -12,7 +12,7 @@ test_run() {
        -drive format=raw,index=0,media=disk,file=$DISKIMAGE \
        -m 256M -smp 2 -nographic \
        -net none \
-       -append "root=/dev/dracut/root rd.auto rw rd.retry=10 console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
+       -append "root=/dev/dracut/root rd.auto rw rd.retry=10 console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing
     grep -F -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
 }
@@ -87,6 +87,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst ./cryptroot-ask.sh /sbin/cryptroot-ask
         mkdir -p $initdir/etc
         echo "testluks UUID=$ID_FS_UUID /etc/key" > $initdir/etc/crypttab
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index 61a95435b5667bbb46cc7783c852fa69510bf244..18fd2b35a607275d8cb8fec245c5d4fe638dc68b 100755 (executable)
@@ -1,5 +1,100 @@
 #!/bin/sh
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
 plymouth --quit
@@ -11,7 +106,7 @@ export PS1='initramfs-test:\w\$ '
 [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-strstr "$CMDLINE" "rd.shell" && sh -i
+getargbool 0 rd.shell && sh -i
 echo "Powering down."
 mount -n -o remount,ro /
 poweroff -f
index 412a0658fcc7c147d1938bcc997904a0071edf0f..97c2f97621c0ad61b88130f046762ce7e976b00c 100755 (executable)
@@ -11,7 +11,7 @@ test_run() {
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
        -m 256M -smp 2 -nographic \
        -net none \
-       -append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $DEBUGFAIL" \
+       -append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing
     grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1
 }
@@ -80,6 +80,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
index 07a8f1fef7f240f7383f551bb6d5eb445db28a9f..cf44fb0bbd33117adc6b2387100283b3a4f61403 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-! getarg rd.break && getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+! getargbool 0 rd.break && getargbool 0 failme && poweroff -f
index c7c114e745346f80d008eaeeb48c00da7fb631f8..7eb932a04468e780fa6f11b60fbba0cd21e5d97c 100755 (executable)
@@ -1,5 +1,100 @@
 #!/bin/sh
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
 command -v plymouth >/dev/null && plymouth --quit
@@ -11,7 +106,7 @@ export PS1='initramfs-test:\w\$ '
 [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-strstr "$CMDLINE" "rd.shell" && sh -i
+getargbool 0 rd.shell && sh -i
 echo "Powering down."
 mount -n -o remount,ro /
 #echo " rd.break=shutdown " >> /run/initramfs/etc/cmdline
index 444dca6d2541d42fec1c0b5bc7757fa26a75af3f..09d78dda4807fd419dbeb233c9d68eb1acd00b14 100755 (executable)
@@ -19,7 +19,7 @@ client_run() {
        -drive format=raw,index=2,media=disk,file=$TESTDIR/disk2.img.new \
        -drive format=raw,index=3,media=disk,file=$TESTDIR/disk3.img.new \
        -net none \
-       -append "$* root=LABEL=root rw rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL " \
+       -append "$* root=LABEL=root rw rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL " \
        -initrd $TESTDIR/initramfs.testing
     if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then
        echo "CLIENT TEST END: $@ [FAIL]"
@@ -130,6 +130,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
        inst ./cryptroot-ask.sh /sbin/cryptroot-ask
         mkdir -p $initdir/etc
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index 2a814f89d4e6d68c7d6000d0244320f6cc72cc28..3e8c3e282cdf71280ef8a36a85a9076ea358e375 100755 (executable)
@@ -19,7 +19,7 @@ test_run() {
        -drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
        -m 256M -smp 2 -nographic \
        -net none \
-       -append "root=/dev/dracut/root rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 rd.debug rootwait $LUKSARGS $DEBUGFAIL" \
+       -append "root=/dev/dracut/root rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 rd.debug rootwait $LUKSARGS rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing
     grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
     echo "CLIENT TEST END: [OK]"
@@ -124,6 +124,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
        inst ./cryptroot-ask.sh /sbin/cryptroot-ask
         mkdir -p $initdir/etc
index f340d2d4b7786894b96790cfdd7f5a1a440e66b4..780a0b2d55534a2e7356a683a2b5de763ff71845 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f 
-getarg failme && poweroff -f 
+getargbool 0 rd.shell || poweroff -f 
+getargbool 0 failme && poweroff -f 
index ba63245ba2ac59f15fd44e19aaf3bf456c000509..127185a23b1fd75bfd905b446885b2241a5f7433 100755 (executable)
@@ -1,4 +1,99 @@
 #!/bin/sh
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
@@ -11,7 +106,7 @@ cat /proc/mdstat
 [ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-strstr "$CMDLINE" "rd.shell" && sh -i
+getargbool 0 rd.shell && sh -i
 echo "Powering down."
 mount -n -o remount,ro /
 poweroff -f
index 315bc5aa9ab3806800161c88e31be180f97c9777..9083fd50fa104503ad132e0d5bf9e2f305e4c36f 100755 (executable)
@@ -15,7 +15,7 @@ client_run() {
        -drive format=raw,index=2,media=disk,file=$TESTDIR/disk2 \
        -m 256M -nographic \
        -net none \
-       -append "$* root=LABEL=root rw debug rd.retry=5 rd.debug console=ttyS0,115200n81 selinux=0 rd.info $DEBUGFAIL" \
+       -append "$* root=LABEL=root rw debug rd.retry=5 rd.debug console=ttyS0,115200n81 selinux=0 rd.info rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing
     if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then
        echo "CLIENT TEST END: $@ [FAIL]"
@@ -114,6 +114,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index 8e2ea49ef987890005cbc90e79b26fe31c614d9c..281f856bfcb194cbb25b5b5a7dd05828d4bab1e2 100755 (executable)
@@ -11,7 +11,7 @@ test_run() {
        -drive format=raw,index=0,media=disk,file=$DISKIMAGE \
        -m 256M  -smp 2 -nographic \
        -net none \
-       -append "root=LABEL=root rw rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
+       -append "root=LABEL=root rw rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing
     dd if=$DISKIMAGE bs=512 count=4 skip=2048 | grep -F -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
 }
@@ -88,6 +88,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index 206298da7f431eae2cf18d72485bd7bc223037f1..5fe523c17700bdf5f60c257786c0f806e46ca750 100755 (executable)
@@ -1,4 +1,99 @@
 #!/bin/sh
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
@@ -11,7 +106,7 @@ export PS1='initramfs-test:\w\$ '
 [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-strstr "$CMDLINE" "rd.shell" && sh -i
+getargbool 0 rd.shell && sh -i
 echo "Powering down."
 mount -n -o remount,ro /
 poweroff -f
index b255492eb38ab5bf91a222f3cabea5cd72bd38bb..4d724706c6bbb52d25a7ff80ea7a90136234a325 100755 (executable)
@@ -22,7 +22,7 @@ test_run() {
         -m 256M -smp 2 \
         -nographic \
         -net none \
-        -append "root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
+        -append "root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
         -initrd "$TESTDIR"/initramfs.testing
 
     # mediacheck test with qemu GUI
@@ -44,6 +44,7 @@ test_setup() {
        . "$basedir"/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
 
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..f4d19dcbfc1232b008537922067b262bdfdb9b48 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
+getargbool 0 rd.shell || poweroff -f
 getarg failme && poweroff -f
index 61a95435b5667bbb46cc7783c852fa69510bf244..77fb346d698048a9cfaeb0f81d4dceb0b738b39f 100755 (executable)
@@ -1,4 +1,99 @@
 #!/bin/sh
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
@@ -11,7 +106,7 @@ export PS1='initramfs-test:\w\$ '
 [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
 stty sane
 echo "made it to the rootfs!"
-strstr "$CMDLINE" "rd.shell" && sh -i
+getargbool 0 rd.shell && sh -i
 echo "Powering down."
 mount -n -o remount,ro /
 poweroff -f
index e3375918c689f411ba9e819a38212ce84d19a671..1485f72195a19be3eacb9731b3c19e5a0ab8ba5e 100755 (executable)
@@ -11,7 +11,7 @@ test_run() {
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
        -m 256M -smp 2 -nographic \
        -net none \
-       -append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $DEBUGFAIL" \
+       -append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
        -initrd $TESTDIR/initramfs.testing
     grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1
 }
@@ -80,6 +80,7 @@ test_setup() {
        . $basedir/dracut-init.sh
        inst_multiple poweroff shutdown
        inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
index a443289e3133ee27217b06a6d4392fff76c13e22..eea162cbcce2f0e7920a4b9e884f93de55686292 100755 (executable)
@@ -1,4 +1,99 @@
 #!/bin/sh
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 exec >/dev/console 2>&1
 export TERM=linux
@@ -7,7 +102,7 @@ CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
 
 stty sane
-if strstr "$CMDLINE" "rd.shell"; then
+if getargbool 0 rd.shell; then
     [ -c /dev/watchdog ] && printf 'V' > /dev/watchdog
        strstr "$(setsid --help)" "control" && CTTY="-c"
        setsid $CTTY sh -i
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index 1dfdfc4ecbfd3778aca1887390f3fb232d9789dc..d7df71e949edb9f5d7300df41e440e1aa5441d4c 100755 (executable)
@@ -54,7 +54,7 @@ client_test() {
         -net nic,macaddr=$mac,model=e1000 \
         -net socket,connect=127.0.0.1:12320 \
         -watchdog i6300esb -watchdog-action poweroff \
-        -append "$cmdline $DEBUGFAIL rd.debug rd.retry=10 rd.info quiet  ro console=ttyS0,115200n81 selinux=0" \
+        -append "rd.shell=0 $cmdline $DEBUGFAIL rd.debug rd.retry=10 rd.info quiet  ro console=ttyS0,115200n81 selinux=0" \
         -initrd $TESTDIR/initramfs.testing
 
     if [[ $? -ne 0 ]] || ! grep -F -m 1 -q nfs-OK $TESTDIR/client.img; then
@@ -335,6 +335,7 @@ test_setup() {
         mkdir $TESTDIR/overlay
         inst_multiple poweroff shutdown
         inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
         inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
 
index 2e422cd5a2eec7a9952a8c424f3b01de755667c8..7279987ca5d56ecd048b1ee1abd7f9af6397f02c 100755 (executable)
@@ -1,4 +1,99 @@
 #!/bin/sh
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 exec >/dev/console 2>&1
 strstr() { [ "${1##*"$2"*}" != "$1" ]; }
@@ -13,7 +108,7 @@ while read dev fs fstype opts rest || [ -n "$dev" ]; do
     break
 done < /proc/mounts
 #sh -i
-if strstr "$CMDLINE" "rd.shell"; then
+if getargbool 0 rd.shell; then
        strstr "$(setsid --help)" "control" && CTTY="-c"
        setsid $CTTY sh -i
 fi
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index 1c06b06d27e112f668dc5f76d1edae05916d2f83..83fd623ac639ecc74b98c34eba0ab45534d52cff 100755 (executable)
@@ -49,7 +49,7 @@ run_client() {
         -net nic,macaddr=52:54:00:12:34:00,model=e1000 \
         -net nic,macaddr=52:54:00:12:34:01,model=e1000 \
         -net socket,connect=127.0.0.1:12330 \
-        -append "rw rd.auto rd.retry=50 console=ttyS0,115200n81 selinux=0 rd.debug=0 $DEBUGFAIL $*" \
+        -append "rw rd.auto rd.retry=50 console=ttyS0,115200n81 selinux=0 rd.debug=0 rd.shell=0 $DEBUGFAIL $*" \
         -initrd $TESTDIR/initramfs.testing
     if ! grep -F -m 1 -q iscsi-OK $TESTDIR/client.img; then
        echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
@@ -214,6 +214,7 @@ test_setup() {
         . $basedir/dracut-init.sh
         inst_multiple poweroff shutdown
         inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
         inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index 2061392ab91271d2166a65d43b9d56c8790bdfff..40e09b7dbde9319f8d810cd91d5ab8512dd2afce 100755 (executable)
@@ -58,7 +58,7 @@ client_test() {
         -nographic \
         -net nic,macaddr=$mac,model=e1000 \
         -net socket,connect=127.0.0.1:12340 \
-        -append "$cmdline $DEBUGFAIL rd.auto rd.info rd.retry=10 ro console=ttyS0,115200n81  selinux=0  " \
+        -append "rd.shell=0 $cmdline $DEBUGFAIL rd.auto rd.info rd.retry=10 ro console=ttyS0,115200n81  selinux=0  " \
         -initrd $TESTDIR/initramfs.testing
 
     if [[ $? -ne 0 ]] || ! grep -F -m 1 -q nbd-OK $TESTDIR/flag.img; then
@@ -227,6 +227,7 @@ make_encrypted_root() {
         )
         inst_multiple mke2fs poweroff cp umount tune2fs
         inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
         inst_hook initqueue 01 ./create-root.sh
         inst_hook initqueue/finished 01 ./finished-false.sh
         inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
index e6157af2eeb1564ea67d95ffde78a035945ac635..d9ba45ec81a7bf6282d31b9452d75e83b8e8c193 100755 (executable)
@@ -1,4 +1,100 @@
 #!/bin/sh
+getcmdline() {
+    while read -r _line || [ -n "$_line" ]; do
+        printf "%s" "$line"
+    done </proc/cmdline;
+}
+
+_dogetarg() {
+    local _o _val _doecho
+    unset _val
+    unset _o
+    unset _doecho
+    CMDLINE=$(getcmdline)
+
+    for _o in $CMDLINE; do
+        if [ "${_o%%=*}" = "${1%%=*}" ]; then
+            if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
+                # if $1 has a "=<value>", we want the exact match
+                if [ "$_o" = "$1" ]; then
+                    _val="1";
+                    unset _doecho
+                fi
+                continue
+            fi
+
+            if [ "${_o#*=}" = "$_o" ]; then
+                # if cmdline argument has no "=<value>", we assume "=1"
+                _val="1";
+                unset _doecho
+                continue
+            fi
+
+            _val="${_o#*=}"
+            _doecho=1
+        fi
+    done
+    if [ -n "$_val" ]; then
+        [ "x$_doecho" != "x" ] && echo "$_val";
+        return 0;
+    fi
+    return 1;
+}
+
+getarg() {
+    local _deprecated _newoption
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -d) _deprecated=1; shift;;
+            -y) if _dogetarg $2 >/dev/null; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    echo 1
+                    return 0
+                fi
+                _deprecated=0
+                shift 2;;
+            -n) if _dogetarg $2 >/dev/null; then
+                    echo 0;
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
+                    fi
+                    return 1
+                fi
+                _deprecated=0
+                shift 2;;
+            *)  if [ -z "$_newoption" ]; then
+                    _newoption="$1"
+                fi
+                if _dogetarg $1; then
+                    if [ "$_deprecated" = "1" ]; then
+                        [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
+                    fi
+                    return 0;
+                fi
+                _deprecated=0
+                shift;;
+        esac
+    done
+    return 1
+}
+
+getargbool() {
+    local _b
+    unset _b
+    local _default
+    _default="$1"; shift
+    _b=$(getarg "$@")
+    [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+    if [ -n "$_b" ]; then
+        [ $_b = "0" ] && return 1
+        [ $_b = "no" ] && return 1
+        [ $_b = "off" ] && return 1
+    fi
+    return 0
+}
+
 exec >/dev/console 2>&1
 set -x
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
@@ -20,5 +116,5 @@ done
     echo "$IFACES"
 } > /dev/sda
 
-strstr "$CMDLINE" "rd.shell" && sh -i
+getargbool 0 rd.shell && sh -i
 poweroff -f
index 12c3d5acaa20534c63e47a7261fc7007abfb51fe..01acb195859b7c5a2c06520fd705104e44b8d4c4 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-getarg rd.shell || poweroff -f
-getarg failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
index e0bf7d2fa2838ba5d425dfdb543fdaee82a956a1..656c237be3d037eb39e0d3f8d9ee6013dc503092 100755 (executable)
@@ -54,7 +54,7 @@ client_test() {
         -net nic,macaddr=52:54:00:12:34:$mac2,model=e1000 \
         -net nic,macaddr=52:54:00:12:34:$mac3,model=e1000 \
         -watchdog i6300esb -watchdog-action poweroff \
-        -append "$cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console loglevel=7" \
+        -append "rd.shell=0 $cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console loglevel=7" \
         -initrd "$TESTDIR"/initramfs.testing
 
     { read OK; read IFACES; } < "$TESTDIR"/client.img
@@ -270,6 +270,7 @@ test_setup() {
         . "$basedir"/dracut-init.sh
         inst_multiple poweroff shutdown
         inst_hook shutdown-emergency 000 ./hard-off.sh
+        inst_hook emergency 000 ./hard-off.sh
         inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
     )