Fix #342: prevent certain commands at bootstrap and shutdown

Over the years there have been multiple cases of invalid and/or unsafe
uses of signals and initctl commands at bootstrap and shutdown.  These
cases cannot be safely supported.  This commit locks down finit a bit
to avoid the most common cases.

If you run into this, please open a new discussion at GitHub and we'll
talk about it.  Maybe I've been overzealous or you have another use-case
that warrants opening up some or parts of the API.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-01-10 17:18:50 +01:00
1 parent 947d91acd5
commit a39ee0b44d
2 files changed
+39

No files matched your search

+20
View File
@@ -431,6 +431,11 @@ static void sighup_cb(uev_t *w, void *arg, int events)
return;
}
if (runlevel == 0 || runlevel == 6) {
warnx("SIGHUP ignored in runlevel S and 6.");
return;
}
/* Restart initctl API domain socket, similar to systemd/SysV init */
api_exit();
api_init(w->ctx);
@@ -482,6 +487,11 @@ static void sigusr1_cb(uev_t *w, void *arg, int events)
return;
}
if (runlevel == 0 || runlevel == 6) {
warnx("SIGUSR1 ignored in runlevel S and 6.");
return;
}
/* Restart initctl API domain socket, similar to systemd/SysV init */
api_exit();
api_init(w->ctx);
@@ -498,6 +508,11 @@ static void sigusr2_cb(uev_t *w, void *arg, int events)
return;
}
if (runlevel == 0 || runlevel == 6) {
warnx("SIGUSR2 ignored in runlevel S and 6.");
return;
}
halt = SHUT_OFF;
service_runlevel(0);
}
@@ -513,6 +528,11 @@ static void sigterm_cb(uev_t *w, void *arg, int events)
return;
}
if (runlevel == 0 || runlevel == 6) {
warnx("SIGTERM ignored in runlevel S and 6.");
return;
}
halt = SHUT_REBOOT;
service_runlevel(6);
}