]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
remove openvt and use "setsid -c", if possible
authorHarald Hoyer <harald@redhat.com>
Wed, 14 Mar 2012 15:19:53 +0000 (16:19 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 14 Mar 2012 15:19:53 +0000 (16:19 +0100)
dracut.conf.d/fedora.conf.example
modules.d/99base/dracut-lib.sh
modules.d/99base/module-setup.sh
modules.d/99shutdown/shutdown.sh

index efec77eb07852f621932382c571611f642f99b2d..02a530e5f313e744b196d1c852868443eee0ff25 100644 (file)
@@ -7,4 +7,4 @@ omit_dracutmodules+=" dash "
 omit_drivers+=" .*/fs/ocfs/.* "
 stdloglvl=3
 realinitpath="/usr/lib/systemd/systemd"
-install_items+=" vi /etc/virc ps grep cat rm openvt "
+install_items+=" vi /etc/virc ps grep cat rm "
index 80e093b27397856ae3420e15d30afc2115f86937..a6c4e24573471dadbb1482722a4d90fb50a474dc 100755 (executable)
@@ -803,16 +803,19 @@ emergency_shell()
         echo
         export PS1="$_rdshell_name:\${PWD}# "
         [ -e /.profile ] || >/.profile
-        _ctty=/dev/console
-        if [ -n "$(command -v setsid)" ]; then
-            _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
-            [ -c "$_ctty" ] || _ctty=/dev/tty1
-            setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
-        elif [ -n "$(command -v openvt)" ] && ! getarg "console=" >/dev/null 2>&1 && getargbool 1 "rd.openvt" ; then
-            openvt -f -c 1 -w -s -l -- sh
-        else
-            sh -i -l 0<$_ctty 1>$_ctty 2>&1
+
+        _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
+        if [ -z "$_ctty" ]; then
+            _ctty=console
+            while [ -f /sys/class/tty/$_ctty/active ]; do
+                _ctty=$(cat /sys/class/tty/$_ctty/active)
+                _ctty=${_ctty##* } # last one in the list
+            done
+            _ctty=/dev/$_ctty
         fi
+        [ -c "$_ctty" ] || _ctty=/dev/tty1
+        strstr "$(setsid --help)" "control" && CTTY="-c"
+        setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
     else
         warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
         # cause a kernel panic
index 98742f5c2f72f4adcec89b38ddcf34198b5debbc..581ba93bbd6a727f2da28b42f903ca3568942800 100755 (executable)
@@ -14,7 +14,7 @@ depends() {
 install() {
     local _d
     dracut_install mount mknod mkdir modprobe pidof sleep chroot \
-        sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink
+        sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink setsid
     dracut_install -o less
     if [ ! -e "${initdir}/bin/sh" ]; then
         dracut_install bash
index 2576687ff2a36ed2d5add092ea5c19979749734a..c8ca6641ec63bf454317cfb216bc6347a6a57fa8 100755 (executable)
@@ -30,16 +30,19 @@ emergency_shell()
         echo
         export PS1="$_rdshell_name:\${PWD}# "
         [ -e /.profile ] || >/.profile
-        _ctty=/dev/console
-        if [ -n "$(command -v setsid)" ]; then
-            _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
-            [ -c "$_ctty" ] || _ctty=/dev/tty1
-            setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
-        elif [ -n "$(command -v openvt)" ] && ! getarg "console=" >/dev/null 2>&1 && getargbool 1 "rd.openvt" ; then
-            openvt -f -c 1 -w -s -l -- sh
-        else
-            sh -i -l 0<$_ctty 1>$_ctty 2>&1
+
+        _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
+        if [ -z "$_ctty" ]; then
+            _ctty=console
+            while [ -f /sys/class/tty/$_ctty/active ]; do
+                _ctty=$(cat /sys/class/tty/$_ctty/active)
+                _ctty=${_ctty##* } # last one in the list
+            done
+            _ctty=/dev/$_ctty
         fi
+        [ -c "$_ctty" ] || _ctty=/dev/tty1
+        strstr "$(setsid --help)" "control" && CTTY="-c"
+        setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
     else
         exec /lib/systemd/systemd-shutdown "$@"
         warn "Shutdown has failed. To debug this issue add \"rdshell\" to the kernel command line."