Commit Graph
141 Commits
Author SHA1 Message Date
Joachim Nilsson 38a274114d Allow registering TTYs that are not yet available
This patch removes the following very annoying warning for TTY devices
not yet available, i.e. plugged-in to the system.

Loading configuration ............................................................................. [ OK ]
[   11.097414] finit[1]:tty_register():Incomplete or non-existing TTY device given, cannot register.
[   11.101457] finit[1]:tty_register():Incomplete or non-existing TTY device given, cannot register.
Mounting filesystems .............................................................................. [ OK ]

Finit will not start a getty (built-in or external) if the TTY does not
exist, but having the configuration enabled makes it possible to do a
simple `initctl reload` to activate a plugged in TTY.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-14 13:14:48 +02:00
Joachim Nilsson e97c5e5860 Increase log level for poweroff/reboot/halt
In case the kernel is incapable of handling a reboot,
power-off, or halt request we want to be able to let
the user perform some basic diagnose of the system.

The existing debug messages are good enough, and use
the correct grammar form, to be enabled always.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-12 09:03:24 +02:00
Joachim Nilsson 660a09c7c1 Reduce log level when skipping re-register of boostrap tasks
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-12 09:02:05 +02:00
Joachim Nilsson 41c003b221 Don't reload *.conf files when changing to runlevel reboot
... or if someone manages (regression) to change to runlevel bootstrap.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-12 08:56:08 +02:00
Joachim Nilsson 12d8ac2399 service_register(): Skip bootstrap services if not in bootstrap
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-12 08:55:42 +02:00
Joachim Nilsson 8dc263d508 Revert live logging of state machine
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-12 01:28:38 +02:00
Joachim Nilsson afb3fada50 cond_reassert(): Use cond_set_path(), not cond_clear(), for reconf
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-12 01:23:43 +02:00
Joachim Nilsson 227dda34f7 cond_set_path(): Log error if unlink() fails
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-12 01:23:16 +02:00
Joachim Nilsson 06479aa5f1 Remove reconf condition when .conf reload completes
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-12 01:07:09 +02:00
Joachim Nilsson 75d29de3cc initctl: Use entire screen width for task/service description
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-12 00:19:10 +02:00
Joachim Nilsson 40fc95047d Prevent 100% CPU, allow bootstrap tasks to fully complete
When collecting a bootstrap task we need to allow its state machine to
complete before cleaning them out.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 23:53:34 +02:00
Joachim Nilsson 5551324291 Minor, comment style
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 23:52:20 +02:00
Joachim Nilsson 46cef811d6 Make sure to step state machine when collecting bootstrap tasks
During the runlevel change from S --> 2 the state machine will pause,
waiting to collect all S-only tasks/services, before continuing.

When an S-only task/service is collected we therefore need to call the
state machine again so that it can reassert all conditions properly.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 23:02:13 +02:00
Joachim Nilsson 70afaa16f5 sm_step(): Log pending stopped svc if we exit state machine
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 22:05:33 +02:00
Joachim Nilsson 8a1015cf3e API refactor, allow svc_stop_completed() to return the pending svc
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 22:04:17 +02:00
Joachim Nilsson 586f0a7799 Live debug stopped but not yet collected tasks
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 21:56:49 +02:00
Joachim Nilsson 474bd2f361 Minor, comment style
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 21:56:31 +02:00
Joachim Nilsson 0caa8330b7 Increase live debugging of main state machine
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 21:41:42 +02:00
Joachim Nilsson 0d9542c222 Live debug
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 21:29:15 +02:00
Joachim Nilsson b6be354508 Minor, whitespace
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-10 23:39:22 +02:00
Joachim Nilsson 0f09c1b0dc Minor, comment fix
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-10 22:53:05 +02:00
Joachim Nilsson 2d9c147e0e Minor, fix comment within comment GCC warning
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-09 09:03:58 +02:00
Joachim Nilsson 53de1c8575 Follow-up to issue #81, don't append error message again.
Also, when called multiple times, return workaround immediately instead
of warning again.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-01 22:07:21 +02:00
Joachim Nilsson 3d4e3c99ed Fix #81: Workaround for systems without SYSV shm IPC support
We should not let PID 1 fail on systems where Linux is built without
CONFIG_SYSVIPC, or the libc does not support shmget()/shmat().

This workaround implements a fallback to using calloc() for PID 1,
which means the initctl tool will not work properly.  A better fix
would be to refactor the shm implementation to instead have initctl
call Finit using api.c for each svc_t.  This has been added to the
TODO file as future work.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-01 20:52:01 +02:00
Jörg Krause 48262e4250 helpers.h: fix build error: unknown type name ‘va_list’
Building finit with a uclibc-ng-toolchain fails with:
```
../src/helpers.h:53:43: error: unknown type name ‘va_list’
 void    printv          (const char *fmt, va_list ap);
```
2017-10-01 16:50:39 +02:00
Joachim Nilsson 1677436137 initctl: Allow C99 style
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-26 10:39:45 +02:00
Joachim Nilsson 56eec5164d Minor, update code comment
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-25 19:02:19 +02:00
Joachim Nilsson d22ffa05bd initctl: Refactor initctl list slightly
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-24 20:41:40 +02:00
Joachim Nilsson 2e66db3fea helpers.c:printv() - Iterate over size of buffer
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-24 20:40:44 +02:00
Joachim Nilsson 686193b701 Only load modules at bootstrap
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-10 14:03:56 +02:00
Joachim Nilsson b43bca529c Minor, fix build error
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-10 13:57:23 +02:00
Joachim Nilsson 545171a8b2 Minor, improve comments in parse_dynamic()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-10 13:50:44 +02:00
Joachim Nilsson d54d5b7f20 Allow kernel modules to be loaded from /etc/finit.d/*.conf
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-10 13:48:07 +02:00
Joachim Nilsson 633a56054b Add support for boot[S]trap services in /etc/finit.d/*.conf
This patch enables support for bootstrap services in /etc/finit.d/

Please note, however, that this does not mean that all configuration
directives are now allowed in /etc/finit.d/*.conf -- the intention is
only to simplify distribution setups.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-10 13:21:11 +02:00
Joachim Nilsson f3a000560f exec_runtask(): Refactor, remove GLIBC:isms to build with musl
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-04 20:05:22 +02:00
Joachim Nilsson 9e7e92b4b7 run stanzas are never caught in service_monitor()
A run stanza blocks operation by calling waitpid(), so it will never be
caught by the service_monitor() function.  Hence, we need to clean up
any bootsrap calls after waitpid(), or at least perform a manual state
change.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-04 16:02:23 +02:00
Joachim Nilsson 29822ef0f7 Always collect bootstrap tasks, regardless of previous runlevel
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-04 16:02:01 +02:00
Joachim Nilsson 718e82bc10 svc_clean_dynamic(): Actually clean dirty services ...
Add missing call to svc_mark_clean() in while() loop.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-04 16:01:05 +02:00
Joachim Nilsson 684314db0f Allow pipe + redirect in task/run stanzas, exec() in /bin/sh
This patch extends the capabilities of task and run .conf stanzas by
enabling pipes and redirects.

Example:

    task [s] echo "foo" | cat >/tmp/bar
    run  [s] echo "$HOME" >/tmp/secret

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-04 16:00:49 +02:00
Joachim Nilsson 8eea64cebf getty: Set $TERM environment variable if given in tty config
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-01 06:41:22 +02:00
Joachim Nilsson b8a7cb6b93 tty-register(): Fix regression in built-in TTY baud + term parser
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-01 06:40:52 +02:00
Joachim Nilsson 529b39ebba tty: Add 'noclear' + 'nowait' options to built-in and external tty's
This patch aligns the two tty configuration stanzas, thus clear and wait
are now the default for both.

    tty [LVLS] <DEV> [BAUD] [noclear] [nowait] [TERM]
    tty [LVLS] <CMD> <ARGS> [noclear] [nowait]

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-01 06:10:08 +02:00
Joachim Nilsson f029ba2111 Reorder functions a bit, group run_getty*() family
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-01 05:50:50 +02:00
Joachim Nilsson 277c3dbb14 getty: Remove TTY clear from built-in getty, delegate to run_getty()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-01 05:47:53 +02:00
Joachim Nilsson f273ecc135 Fix #79: Add 'nowait' option to tty setting, external getty
This patch makes it possible to disable the "Please press Enter" prompt
when using an external getty. Simply append `nowait` to the .conf entry
and Finit will spawn the getty immediately.

A future patch will add support for `noclear` as well to external getty,
as well as a change in default (=> `wait`) for the built-in getty.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-31 00:51:11 +02:00
Joachim Nilsson 2fe257b7af getty.c: Handle Ctrl-U properly, erase line to beginning
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-30 17:19:43 +02:00
Joachim Nilsson 907595d9ed getty.c: Ignore signals like SIGINT, SIGHUP
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-30 17:19:12 +02:00
Joachim Nilsson 55c12aa6f6 Remove developer debug message
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-30 15:08:14 +02:00
Joachim Nilsson a2f4b35e4e Fix #77: Remove deprecated startx and user .conf settings
It is strongly recommended to instead use the service stanza to start
XDM/GDM, or use startx after a regular login.

Note: the `user NAME` setting was always reserved for use with startx

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-30 15:01:05 +02:00
Joachim Nilsson dec21e758a Fix #78: Support agetty cmd line format for external getty
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-30 14:44:10 +02:00