2

In the rare cases that a RHEL or CentOS 6 system is prevented from booting by (for instance) an improper shutdown, or a forced fsck-check failure on boot, the console will prompt the user for a root password.

How do I disable the password check and drop directly to a root-shell?

Unacceptable answers:

  • overriding init on kernel command line (ie, grub)
  • linking / replacing /sbin/sulogin with /sbin/sushell. (This would work, but it would raise red flags with the security framework).
  • booting from some other device
Otheus
  • 6,138
  • Many rc faults will invoke rcS-emergency, and adding EMERGENCY=/bin/sushell to /etc/sysconfig/init will make it run sushell. I don't know if this covers every conceivable fault that rc stuff can run into, though. – Mark Plotnick Jul 21 '15 at 19:30
  • Ah, so the "environment" from rcS-emergency comes from /etc/sysconfig/init? Post that as an aswer; I will test and accept. – Otheus Jul 22 '15 at 13:39

1 Answers1

1

At several points in rc.sysinit, rcS-emergency will be run when there's a problem requiring administrator intervention, such as:

echo $"*** An error occurred during the file system check."
echo $"*** Dropping you to a shell; the system will reboot"
echo $"*** when you leave the shell."
str=$"(Repair filesystem)"
PS1="$str \# # "; export PS1
[ "$SELINUX_STATE" = "1" ] && disable_selinux
start rcS-emergency

Here is the rcS-emergency script:

. /etc/sysconfig/init
plymouth --hide-splash || true
[ -z "$EMERGENCY" ] && EMERGENCY=/sbin/sulogin
exec $EMERGENCY

If you add EMERGENCY=/bin/sushell to /etc/sysconfig/init, it'll run sushell, which doesn't ask for a password.

Mark Plotnick
  • 25,413
  • 3
  • 64
  • 82
  • Great job! Any chance you can answer this for systemd / rhel7 :D http://unix.stackexchange.com/questions/217383/how-to-permanently-disable-root-password-prompt-for-recovery-mode-rhel7 – Otheus Jul 22 '15 at 18:03