Merge branch 'emergency-shell-improvements'

This commit is contained in:
Joachim Nilsson
2017-08-19 20:17:31 +02:00
2 changed files with 25 additions and 1 deletions
+8
View File
@@ -421,6 +421,14 @@ Finit is configured with this option, Finit will try to start a bare
`/bin/sh` on the boot console. Remember, this is only for debugging
and would leave your production system potentially wide open.
There is also a rescue shell available, in case Finit crashes and the
kernel usually reboots: `configure --enable-emergency-shell`. However,
the behavior of Finit is severely limited when this is enabled, so use
it only for debugging start up issues when Finit crashes.
**NOTE:** Both of these configure options *should not* be enabled for
production systems since they can potentially give a user root access.
Origin & References
-------------------
+17 -1
View File
@@ -202,6 +202,14 @@ done:
/*
* If everything goes south we can use this to give the operator an
* emergency shell to debug the problem -- Finit should not crash!
*
* Note: Only use this for debugging a new Finit setup, don't use
* this in production since it gives a root shell to anyone
* if Finit crashes.
*
* This emergency shell steps in to prevent "Aieee, PID 1 crashed"
* messages from the kernel, which usually results in a reboot, so
* that the operator instead can debug the problem.
*/
static void emergency_shell(void)
{
@@ -210,7 +218,15 @@ static void emergency_shell(void)
pid = fork();
if (pid) {
waitpid(pid, NULL, 0);
while (1) {
pid_t id;
/* Reap 'em (prevents Zombies) */
id = waitpid(-1, NULL, WNOHANG);
if (id == pid)
break;
}
fprintf(stderr, "\n=> Embarrassingly, Finit has crashed. Check /dev/kmsg for details.\n");
fprintf(stderr, "=> To debug, add '--debug' to the kernel command line.\n\n");