diff --git a/src/conf.c b/src/conf.c index 805732ea..861caf00 100644 --- a/src/conf.c +++ b/src/conf.c @@ -672,7 +672,7 @@ int conf_reload(void) if (rescue) { int rc; - char line[80] = "tty [12345] @console noclear nologin"; + char line[80] = "tty [12345] rescue"; /* If rescue.conf is missing, fall back to a root shell */ rc = parse_conf(RESCUE_CONF, 0); diff --git a/src/rescue.conf b/src/rescue.conf index 9769f55d..69231099 100644 --- a/src/rescue.conf +++ b/src/rescue.conf @@ -1,3 +1,2 @@ runlevel 1 -hostname rescue -tty [12345] @console noclear nologin +tty [12345] rescue diff --git a/src/service.c b/src/service.c index 7530d44b..81ca2c6d 100644 --- a/src/service.c +++ b/src/service.c @@ -1301,6 +1301,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file) svc->nowait = tty.nowait; svc->nologin = tty.nologin; svc->notty = tty.notty; + svc->rescue = tty.rescue; /* TTYs cannot be redirected */ log = NULL; diff --git a/src/svc.h b/src/svc.h index 6c74f985..6a08c8c7 100644 --- a/src/svc.h +++ b/src/svc.h @@ -149,6 +149,7 @@ typedef struct svc { char nowait; char nologin; char notty; + char rescue; }; }; diff --git a/src/tty.c b/src/tty.c index 6497f1e9..af047ce7 100644 --- a/src/tty.c +++ b/src/tty.c @@ -158,7 +158,9 @@ int tty_parse_args(char *cmd, struct tty *tty) else if (!strcmp(cmd, "nologin")) tty->nologin = 1; else if (!strcmp(cmd, "notty")) - tty->notty = 1; /* for rescue shells */ + tty->notty = 1; /* for board bringup */ + else if (!strcmp(cmd, "rescue")) + tty->rescue = 1; /* for rescue shells */ else if (!access(cmd, X_OK)) tty->cmd = cmd; else @@ -167,6 +169,10 @@ int tty_parse_args(char *cmd, struct tty *tty) cmd = strtok(NULL, " \t"); } while (cmd && tty->num < NELEMS(tty->args)); + /* rescue shells are always notty */ + if (tty->rescue) + tty->notty = 1; + /* skip /dev probe, we just want a bríngup shell */ if (tty->notty) return 0; @@ -242,12 +248,15 @@ int tty_exec(svc_t *svc) /* try to protect system with sulogin, fall back to root shell */ if (svc->notty) { - /* util-linux or busybox, no args for compat */ - if (whichp("sulogin")) - return execlp("sulogin", "sulogin", NULL); - /* check if bundled one is available */ - if (whichp(_PATH_SULOGIN) && !systemf(_PATH_SULOGIN)) - _exit(0); + if (svc->rescue) { + /* check if bundled one is available */ + if (whichp(_PATH_SULOGIN)) + return execl(_PATH_SULOGIN, _PATH_SULOGIN, NULL); + + /* util-linux or busybox, no args for compat */ + if (whichp("sulogin")) + return execlp("sulogin", "sulogin", NULL); + } /* * Become session leader and set controlling TTY @@ -257,7 +266,7 @@ int tty_exec(svc_t *svc) ioctl(STDIN_FILENO, TIOCSCTTY, 1); prctl(PR_SET_NAME, "finitsh", 0, 0, 0); - return execl(_PATH_BSHELL, _PATH_BSHELL, NULL); + return execl(_PATH_BSHELL, "-sh", NULL); } dev = tty_canonicalize(svc->dev); diff --git a/src/tty.h b/src/tty.h index 8e543c32..37797d95 100644 --- a/src/tty.h +++ b/src/tty.h @@ -40,6 +40,7 @@ struct tty { char nowait; char nologin; char notty; + char rescue; }; char *tty_canonicalize (char *dev);