Commit Graph
3322 Commits
Author SHA1 Message Date
Joachim Wiberg a664fd7192 Add plugin and test to reproduce failing tests since c9fe9af
With all the change and revert mess of the HOOK_BASEFS_UP tests started
failing due to usr.so and sys.so failed to set up their conditions.  It
then became clear that boomisc.so cleaned up /run ... with the revert
we got service_register() to be called before global_rlimit[] was setup
causing services registered by plugins, before conf_init(), to crash.

This plugin and test is here to ensure we catch this problem in case of
any future refactor.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-02-05 01:15:49 +01:00
Joachim Wiberg b62ee0ef6d test/common: add missing newline to usage text
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-02-04 23:05:05 +01:00
Joachim Wiberg 0cfd867816 plugins: fix memory leak in sys.so
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-02-04 23:04:41 +01:00
Joachim Wiberg 934a4db7d5 plugins/dbus: adapt to other operating systems
Not all Linux systems are based on Debian, and even if they are inspired
by Debian (Buildroot), they do not necessarily use the same defaults.

This patch probes the current system for:

 - dbus user and group
 - dbus PID file

If the user/group cannot be found we fall back to "root", if the PID
file cannot be determined we ignore PID file readiness.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-25 12:29:08 +01:00
Joachim Wiberg c9fe9afa61 Revert "HOOK_BASEFS_UP must run as soon as all filesystems are mounted"
This reverts commit 5b41c6e since it causes regressions in plugins
adding services to the system.  The proper fix for early bootmisc
is to add a new hook, which will be added in subsequent commits.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-24 10:00:47 +01:00
Joachim Wiberg 320e91653b initctl: add -n,--noerr to return OK(0) if svc doesn't exist
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-19 19:57:25 +01:00
Joachim Wiberg 859d215ca4 Merge pull request #347 from JackNewman12/master
Use realpath in do_change() to ensure symlink directories are correctly reloaded

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-18 07:07:15 +01:00
Jack Newman 0a94f3f303 Use realpath in do_change() to ensure symlink directories are
correctly reloaded.
2023-01-18 15:59:50 +10:00
Joachim Wiberg e83a26b256 Simplify readiness handling for s6 style services
No need for special handling of s6 services, we now have the new
service_notify_reconf() function that is called on init reload.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-17 07:22:59 +01:00
Joachim Wiberg 2508495b8c Fix #343: only mark native services as started in pidfile plugin
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-17 07:22:28 +01:00
Joachim Wiberg 3ef52d9324 test: reproduce pidfile plugin marking systemd services 'started'
Issue #343

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-17 07:22:20 +01:00
Joachim Wiberg 05b72281e6 plugins: minor, fix clang warning
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-16 22:12:03 +01:00
Joachim Wiberg a47abfdc16 Fix #344: check for sysklogd logger tool at runtime, replacing logit
The sysklogd logger is capable of logging the PID of the actual service,
rather than just the logger tool itself (which would be a differet PID
every time).

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 15:45:53 +01:00
Joachim Wiberg 2c9265f8c8 initctl: add 'cat' as alias for 'show'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 14:13:01 +01:00
Joachim Wiberg 56cb6f8613 Fix #343: handle 'initctl reload' of unmodified non-native services
When 'initctl reload' is called new "configuration generation" is
started by Finit.  This mechanism ensures services reaffirm their
readiness and helps distinguish between their ready before reload
and after.

For native services the pidfile plugin handles this.  The s6 style
services are one-shot only, and thus use a static ready condition.

This patch adds support for stepping the configuration generation
of unmodified systemd style services.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 3dd56ed8af test: minor refactor for readability
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg fddeeb683c test: drop debug
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 25835b0edf test: clean up properly between tests phases in notify.sh
To reset the crash counter of the 'serv' daemon we need to remove it
from /etc/finit.conf (and reload) between each test phase.

The repeated test phases can now be dropped, since the lack of reset
was the root cause for it failing sometimes in extended runs.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 27fcfada66 test: add native pid file based daemon to notify.sh for completeness
Correct an obvious oversight, we need to ensure the native pidfile based
daemons also work as intended in the new readiness notification world.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 2dd5fb0f77 test: s6/systemd style services do not necessarily create a PID file
Ensure the test mimics actual real-world scenario where daemons do not
create a PID file at all.

Issue #343.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 63044a4b81 test: extend notify.sh with checks for 'restart serv' and 'reload'
Issue #343.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 4e74f9783a test: minor fix to 'serv' test service
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg c3c662fe64 initctl: ensure 'cond get' support flux state
The 'initctl cond' commands were initiallý added to only manage usr
conditions.  Recently the 'cond get' command was expanded to allow
reading general conditions as well.

However, since general conditions support three states the command
returned 'on' for conditions that were in flux.  This patch fixes
that oversight.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 7c2764790c Issue #343: READY state lost when service is restarted after crash
The svc_set_state() function not only handles state transitions, it also
makes sure to cancel any outstaing service timeouts.  Before the service
readiness support was added, service conditions were simply a single bit
of information, so clearing its conditions before changing states had no
impact.  With readiness we have multiple bits of information that are
set as conditions.

When restarting a crashing service we set a timeout to retry restarting,
or ensure the service is now running.  This means that the service can
signal READY before RUNNING is reasserted, but the RUNNING state can be
set also by the service state machine, so we need to ensure we do not
re-assert RUNNING if it's already set, and thereby clearing READY.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:33:55 +01:00
Joachim Wiberg 732d500cf5 Avoid reserved keyword 'new'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-13 07:50:45 +01:00
Joachim Wiberg 4e1ac726ac Minor, update debug message to align PID output
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-13 07:49:17 +01:00
Joachim Wiberg fba58085c6 test: verify readiness notification on crash/restart
Issue #343 reports that readiness notification on crash/restart is lost.
This update to notify.sh reproduces that bug.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-12 09:03:10 +01:00
Joachim Wiberg d1ebb255c6 initctl: add 'kill' alias to 'signal' command
Principle of least surprise.  When no even the maintainer remembers
the correct command, it is time to add an alias.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-12 09:00:57 +01:00
Joachim Wiberg a39ee0b44d 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>
2023-01-10 17:18:50 +01:00
Joachim Wiberg 947d91acd5 Minor, whitespace only
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 10:51:12 +01:00
Joachim Wiberg 8c206d52e5 Fix imlicit declaration build warning
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 10:49:32 +01:00
Joachim Wiberg 0f445dc9f4 doc: add missing /etc/finit.d and fix indendation (untabify)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 10:38:14 +01:00
Joachim Wiberg c71b35e61a doc: document recommended filesystem layout + automounter
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 10:00:43 +01:00
Joachim Wiberg d20308b7d7 Follow-up to e4e54a8: spellcheck hook name
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 09:08:33 +01:00
Joachim Wiberg e4e54a88d9 Adjust boundaries for when conditions are allowed
Not until fs_mount_all() has completed do we have /run, or /var/run, and
never after shutdown has been initiated.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 09:00:35 +01:00
Joachim Wiberg 308b7c5197 Follow-up to #338: return early if conditions are not available
As pointed out by Jack Newman in issue #338, when conditions are not
available (at boot before cond_init(), or shutdown when /var or /var/run
have been unmounted) we should not try to create any conditions.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 08:17:09 +01:00
Joachim Wiberg 89772bf6c0 Merge pull request #338 from JackNewman12/shutdown-hook-fix
Fix shutdown hooks not running

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 08:08:32 +01:00
Joachim Wiberg 077002e647 doc: follow-up to 02a110e, rename new section, add list of runlevels
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 07:07:18 +01:00
Joachim Wiberg 988cdf9878 Merge pull request #341 from troglobit/reboot-delay
Add support for optional reboot delay

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 06:25:45 +01:00
Joachim Wiberg 97db2078f5 Follow-up, spell check
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 14:19:09 +01:00
Joachim Wiberg 02a110e6c2 Fix #336: update main config.md Introduction with new .conf overview
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 14:18:30 +01:00
Joachim Wiberg 681ef8de6f doc: minor, styling
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 14:18:30 +01:00
Joachim Wiberg 0147e0e64f Minor, ensure pointer is legit in --enable-static mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 14:18:30 +01:00
Joachim Wiberg 311c6be9aa Add support for optional reboot delay
Slightly different take on issue #334 making it optional, possible to
enable per system.

    reboot-delay <0-60>           # default: 0 (disabled)

When enabled (non-zero), runs after filesystems have been unmounted,
the root filesystems has been remounted read-only, and sync(2) has
been called, twice.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 09:37:19 +01:00
Joachim Wiberg c22d123ab0 plugins: sys.so and usr.so must run after bootmisc
The bootmisc plugin sets up the base path for finit and figures out if
the system has /run or /var/run -- needed by the other plugins.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 18:07:40 +01:00
Joachim Wiberg 96b5991355 .github: ::set-output is deprecated
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 18:04:45 +01:00
Joachim Wiberg 06bd352863 .github: fix missing quote
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:59:47 +01:00
Joachim Wiberg a918f7497a .github: revise weekly check
For details, see https://stackoverflow.com/a/67527144/1708249

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:56:42 +01:00
Joachim Wiberg 8bbae3d414 plugins: ensure /var/run/finit/cond exists
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:42:49 +01:00
Joachim Wiberg bfd1f36fdd .github: spellcheck yaml
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:26:08 +01:00