From 7f7620286574d6eb8abc012d794c295e20d46a61 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 18 Apr 2021 23:12:11 +0200 Subject: [PATCH] Simplify, drop --enable-fallback-shell from configure script Recommend using `notty` option in tty stanza instead. See the updated docs for details. Signed-off-by: Joachim Wiberg --- configure.ac | 9 +-------- doc/bootstrap.md | 2 +- doc/build.md | 17 ++++++++++------- doc/config.md | 12 +++++++----- src/conf.c | 4 ---- src/svc.c | 2 +- src/tty.c | 26 -------------------------- src/tty.h | 1 - 8 files changed, 20 insertions(+), 53 deletions(-) diff --git a/configure.ac b/configure.ac index c1bc1100..57744b3e 100644 --- a/configure.ac +++ b/configure.ac @@ -53,10 +53,6 @@ AC_ARG_ENABLE(emergency_shell, Use only for debugging very early boot problems with Finit]),,[ enable_emergency_shell=no]) -AC_ARG_ENABLE(fallback_shell, - AS_HELP_STRING([--enable-fallback-shell], [Start a shell if no TTYs can start]),,[ - enable_fallback_shell=no]) - AC_ARG_ENABLE(auto_reload, AS_HELP_STRING([--enable-auto-reload], [Automatic reload on any .conf change]),,[ enable_auto_reload=no]) @@ -130,13 +126,10 @@ AC_ARG_WITH(random-seed, ### Enable features ########################################################################### -# Create config.h from selected features and fallback defautls +# Create config.h from selected features and fallback defaults AS_IF([test "x$enable_emergency_shell" = "xyes"], [ AC_DEFINE(EMERGENCY_SHELL, 1, [Fork off init and let PID 1 wait and start /bin/sh if init crashes.])]) -AS_IF([test "x$enable_fallback_shell" = "xyes"], [ - AC_DEFINE(FALLBACK_SHELL, 1, [Start /bin/sh on console if no TTYs.])]) - AS_IF([test "x$enable_auto_reload" = "xyes"], [ AC_DEFINE(AUTO_RELOAD, 1, [Finit automatically does `initctl reload` on any .conf change])]) diff --git a/doc/bootstrap.md b/doc/bootstrap.md index ea71e9e5..48be724f 100644 --- a/doc/bootstrap.md +++ b/doc/bootstrap.md @@ -34,7 +34,7 @@ Bootstrap 24. Call 4th level hooks, `HOOK_SVC_UP` 25. Call `/etc/rc.local`, if it exists and is an executable shell script 26. Call 5th level (last) hooks, `HOOK_SYSTEM_UP` -27. Start all configured TTYs, or a fallback shell on `/dev/console` +27. Start all configured TTYs In (19) and (22) tasks and services defined in `/etc/finit.conf` and `/etc/sysctl.d/*.conf` are started. Remember, all `service` and `task` diff --git a/doc/build.md b/doc/build.md index a09ed653..4168c486 100644 --- a/doc/build.md +++ b/doc/build.md @@ -153,19 +153,22 @@ kernel messages and add `debug` to enable Finit debug messages. append="init=/sbin/finit debug" ``` -To debug startup issues, in particular issues with getty/login, try -`configure --enable-fallback-shell`. When no TTYs are detected, and -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. +To debug startup issues, in particular issues with getty/login, add +the following to your Finit .conf file: + + tty [12345789] notty noclear + +The `notty` option ensures reusing the stdin/stdout set up by the +kernel. 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:** Neither of these two configure options should be enabled on - production systems since they can potentially give a user root access. +**NOTE:** Neither of these options should be enabled on production + systems since they can potentially give a user root access. [1]: ftp://troglobit.com/finit/finit-3.0.tar.xz diff --git a/doc/config.md b/doc/config.md index 9eb359ba..6bd76366 100644 --- a/doc/config.md +++ b/doc/config.md @@ -522,12 +522,14 @@ can be omitted to keep the kernel default. tty [12345] @console noclear vt220 -On really bare bones systems Finit offers a fallback shell, which -should not be enabled on production systems since. This because it -may give a user root access without having to log in. However, for -bringup and system debugging it can come in handy: +On really bare bones systems Finit can give you a shell prompt as +soon as bootstrap is done, without opening any device node: - configure --enable-fallback-shell + tty [12345789] notty noclear + +This should of course not be enabled on production systems. Because it +may give a user root access without having to log in. However, for +board bringup and system debugging it can come in handy. One can also use the `service` stanza to start a stand-alone shell: diff --git a/src/conf.c b/src/conf.c index df6528ca..805732ea 100644 --- a/src/conf.c +++ b/src/conf.c @@ -737,10 +737,6 @@ int conf_reload(void) globfree(&gl); - /* Verify config, do we have at least one TTY available? */ - if (tty_fallback(FINIT_CONF)) - logit(LOG_WARNING, "warning, no getty enabled on local TTYs."); - /* Mark any reverse deps as chenaged. */ service_update_rdeps(); diff --git a/src/svc.c b/src/svc.c index 599b7af5..59fa4d26 100644 --- a/src/svc.c +++ b/src/svc.c @@ -433,7 +433,7 @@ svc_t *svc_find_by_tty(char *dev) { svc_t *svc, *iter = NULL; - /* this is valid for fallback shells */ + /* this is valid for fallback (notty) shells */ if (!dev) return NULL; diff --git a/src/tty.c b/src/tty.c index ba2ed7b8..b2303040 100644 --- a/src/tty.c +++ b/src/tty.c @@ -286,32 +286,6 @@ int tty_exec(svc_t *tty) return run_getty2(dev, tty->cmd, args, tty->noclear, tty->nowait, tty->rlimit); } -/* - * Fallback shell if no TTYs are active - */ -int tty_fallback(char *file) -{ - svc_t *svc, *iter = NULL; - size_t num = 0; - - for (svc = svc_iterator(&iter, 1); svc; svc = svc_iterator(&iter, 0)) { - if (!svc_is_tty(svc) || svc_is_removed(svc)) - continue; - num++; - } - -#ifdef FALLBACK_SHELL - char line[32] = "tty [12345789] notty noclear"; - - if (!num) { - _d("No TTY active in configuration, enabling fallback shell."); - return service_register(SVC_TYPE_TTY, line, global_rlimit, file); - } -#endif - - return num == 0; -} - /** * Local Variables: * indent-tabs-mode: t diff --git a/src/tty.h b/src/tty.h index ba7f7855..8e543c32 100644 --- a/src/tty.h +++ b/src/tty.h @@ -51,7 +51,6 @@ int tty_parse_args (char *cmdline, struct tty *tty); int tty_exists (char *dev); int tty_exec (svc_t *tty); -int tty_fallback (char *file); #endif /* FINIT_TTY_H_ */