Commit Graph
169 Commits
Author SHA1 Message Date
Joachim Nilsson 03a33fc0ee Check stat() return value, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:56:02 +02:00
Joachim Nilsson 22192acce4 initctl: Make sure to NUL terminate info string from Finit
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:53:23 +02:00
Joachim Nilsson 500d301700 tty_unregister(): Fix possible out-of-bounds access, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:45:02 +02:00
Joachim Nilsson e8f26709e2 service_register(): Fix possible memory leak, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:41:13 +02:00
Joachim Nilsson 91b3e5eeb4 inetd: Fix possible tcp socket leaks, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:37:21 +02:00
Joachim Nilsson 71026adf03 tty_register(): Fix possible memory leak, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:32:26 +02:00
Joachim Nilsson 978beb8e7e Don't log if failed to remove non-existing condition
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:05:00 +02:00
Joachim Nilsson f1c9581da9 service_start(): Must set GID before dropping user privs, obvs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 11:05:59 +02:00
Joachim Nilsson 38ba9930d0 helpers.c:getuser() - Make @home an optional argument
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:03:54 +02:00
Joachim Nilsson 00fe37174d Refactor initial /dev popoulation
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 09:57:38 +02:00
Joachim Nilsson 33916a2097 Fix #82: Revert parts of 34a1524 and add workaround from Void Linux
In commit 34a1524 the start of udevd was refactored to allow it to be a
properly monitored service caused systems using eudev to malfunction.

This patch reverts part of that commit and adds a workaround found when
trying to reproduce issue #82 on Void Linux:

   - Start a temporary udevd in the background
   - Call udevadm to trigger bringup of all subsystems and devices
   - Wait for everything to settle
   - Tell temporary udevd to exit (new)

In the world of `mdev` this song and dance act is not required.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 09:43:37 +02:00
Joachim Nilsson eb870efaff Add support for setting effective group ID of services
Finit has long since supported an @user:group syntax to services, tasks,
and run stanzas.  Setting UID was implemented at that time, but setting
GID never was.  This patch fixes that oversight.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 09:11:23 +02:00
Joachim Nilsson 1c9f2e9b55 initctl: Fix set/clear condition
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-16 16:49:35 +02:00
Joachim Nilsson 9b8e7a0793 Minor, update documentation on raw condition dumps
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-16 14:54:48 +02:00
Joachim Nilsson 3f150901fe initctl: Align STATUS output from cond show and dump
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-16 11:26:43 +02:00
Joachim Nilsson fd090a6785 initctl: Fix 'cond dump/set/clear' commands, only show worked
This patch fixes an invalid use of strpbrk() causing all cond
sub-commands, except initctl cond show, to fail.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-16 11:23:57 +02:00
Joachim Nilsson 83445f1ebe initctl: show, use '-' for runlevels service is not member of
This patch adds a '-' for each runlevel a service/task is not part of.
The resulting listings are easier to read and also makes it clearer to
the user what happens when changing runlevels.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-16 09:43:58 +02:00
Joachim Nilsson e88241316b Prune bootstrap tasks/services that never ran
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-16 09:42:08 +02:00
Joachim Nilsson f91205cbad initctl: list, only print whitespace separator between services
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-16 08:43:29 +02:00
Joachim Nilsson 94aec26e8c initctl: shoow, adjust width of runlevels column, needs 12 chars
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-16 08:42:47 +02:00
Joachim Nilsson 11026d9da3 initctl: Minor, use local screen_cols rather than SCREEN_WIDTH
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-16 08:42:03 +02:00
Joachim Nilsson a6a3299f08 Free cmd from which() after having registered the udevd service
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 23:10:42 +02:00
Joachim Nilsson 34a15241ca Convert udevd to a regular system service
This patch, similar to the work done in the d-bus plugin, converts the
udevd service from a non-monitored run_interactive() task that forks
itself into the background, to a proper Finit monitored service.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 23:10:18 +02:00
Joachim Nilsson 2b173e831f service_start(): Redirect service output to /dev/null by default
This patch prevents output of stderr/stdout from services to leak to the
console.  Use the 'log' keyword to service/run/task stanza to redirect
output to syslog.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 21:39:58 +02:00
Joachim Nilsson 1a45045a0f service_register(): Do not modify input string, may be read-only
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 21:17:00 +02:00
Joachim Nilsson e131b20a6c service_register(): Make sure to initialize username to NULL
Follow-up to 7d9f873, which converted this from a function argument to a
local variable.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 20:47:18 +02:00
Joachim Nilsson 7d9f873b7c Follow-up to a2f4b35, remove username arg from service_register()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 20:32:11 +02:00
Joachim Nilsson cf60cdd9c9 Fix termios regression on PPC introduced in 907595d
For some reason PPC is much more sensitive than ARM when it comes to
termios changes.  This patch fixes a regression in Ctrl-C handling
after login introduced in 907595d when blocking of Ctrl-C was added
to prevent breaking the login-prompt.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 20:12:37 +02:00
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