Commit Graph
3090 Commits
Author SHA1 Message Date
Joachim Wiberg f8dfcdf024 Fix #279: allow restart:always, restart:-1, of crashing services
This change allows endless restarts, similar to `respawn` but honors
`restart_sec`.  There is no upper limit on the number of times Finit
tries to restart a crashing service.  Same as `restart:-1`

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-06-12 22:48:12 +02:00
Joachim Wiberg f50b5a4ac6 Fix #285: initctl restart should start crashed service
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-06-12 22:24:27 +02:00
Joachim Wiberg 59525b80e3 Export finit/conf.h and finit/service.h for external plugins
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-06-06 10:38:19 +02:00
Joachim Wiberg 0ce028add1 Fix #283: too quick timeout at bootstrap of lingering tasks
This seemed odd at first, but it turns out we seem to have adjusted the
time scale for the bootstrap worker, so we were off by ... a factor 10.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-06-03 03:45:10 +02:00
Joachim Wiberg 75c5c85f07 test: new regression test for initctl restart self
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-30 06:59:14 +02:00
Joachim Wiberg ccb84ced2e Fix #280: allow calling initctl restart foo from within foo
Move the stop+start from initctl to the state machine by allowing
stopped tasks to restart once it has been collected.  This should
prevent finit from blocking, allowing it to handle other requests
while waiting for the service's PID to be collected.

Effectively, this will allow a service to call initctl to restart
itself, as reported in issue #280.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-30 06:54:27 +02:00
Joachim Wiberg 5ef669fb6c test: fix use-after-free by switching to strdupa()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-30 06:53:37 +02:00
Joachim Wiberg 96ff9c115c Follow-up to 9304024: skip . and ..
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-18 07:25:39 +02:00
Joachim Wiberg 83aa6abb1c Fix potential NULL ptr dereference, found by Coverity
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-17 14:37:06 +02:00
Joachim Wiberg 9304024841 Check return value of remove() when deleting full condition path
Found by Coverity.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-17 14:35:42 +02:00
Joachim Wiberg 0de5981948 initctl: minor, fix invalid format string for print_header()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-17 14:33:45 +02:00
Joachim Wiberg c39106906d Check return value from iwatch_init(), found by Coverity
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-17 14:28:04 +02:00
Joachim Wiberg 929a6e7aac test: fix minor memory leak in test daemon, found by Coverity
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-17 14:26:48 +02:00
Joachim Wiberg ceb4d04d23 Fix potential array overrun, found by Coverity
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-17 14:22:36 +02:00
Joachim Wiberg f483a8aeaa Update ChangeLog and bump version for v4.3 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
4.3
2022-05-15 21:57:32 +02:00
Joachim Wiberg e3e220ce8e Fix links and update with info on new/existing features
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 21:55:38 +02:00
Joachim Wiberg fc653e4293 man: document initctl cond get
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 20:45:00 +02:00
Joachim Wiberg 94d55cb7dd initctl: allow 'cond get' read any type of condition
Fixes #265

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 11:52:02 +02:00
Joachim Wiberg 0e84ecf143 Minor refactor
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 11:44:24 +02:00
Joachim Wiberg 0e93dfd640 initctl: use standardized exit codes for all fatal errors
This change diversifies the exit codes used by initctl on fatal errors.
Previously only Std C codes 0 and 1 were used, with the initctl specific
255 for some cases.

Both the LSB init script codes and BSD sysexits.h codes are used.  See
util.c exitcodes[] for the full list.  The idea is to complement the
change in 9a76f08, issue #266, so that initctl can be used silently for
scripting purposes.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 11:32:06 +02:00
Joachim Wiberg 4dff8237f1 initctl: fix fallback handling in log command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 11:01:58 +02:00
Joachim Wiberg 35400f2a8b Minor, drop unused header file
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 10:36:47 +02:00
Joachim Wiberg 9a76f0862c initctl: let -q silence all commands
This patch introduces ERR(), ERRX(), WARN(), and WARNX() as replacements
to their lower case counterparts.  These log macros respect the 'quiet'
flag to initctl, leaving only the return code as indicator to user.

Fixes #266

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 10:34:36 +02:00
Joachim Wiberg fb8a7caa99 initctl: simplify error output of start/stop/restart/signal
No need for the verbose output on error, simply state the cause of the
problem.  The user can issue `initctl -h` to check the syntax of the
command.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 10:30:49 +02:00
Joachim Wiberg f8bed5c7af Minor, fix local shadowing of scope global variable
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 09:38:05 +02:00
Joachim Wiberg da6fa482e7 Follow-up to 195155a, drop unused variable from refactor
... and it's obviously spelled "unlimited", *sigh*

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 09:38:05 +02:00
Joachim Wiberg fdf8e48c99 Minor, reduce scope of local variable
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 09:21:48 +02:00
Joachim Wiberg 195155a7f5 initctl: make log command unlimented
Drop `| tail -10` from 'log foo' command.  Let user call tail themselves
and only limit with tail on status command.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-13 13:53:38 +02:00
Joachim Wiberg 6934ba4dbc initctl: improve log digger in 'status foo' command
Grep in /var/log/syslog, or messages, for both the service identity (not
just svc->cmd) and also try to find [PID] for more relevant information.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-13 13:38:26 +02:00
Joachim Wiberg fdbd25c1b5 Use svc_ident() for more cases
- Drop basename() of svc->cmd from remaining code
  - Replace uses of svc->cmd with svc_ident(svc)
  - Use svc_ident() as default log tag

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-13 13:36:33 +02:00
Joachim Wiberg 467f1cca81 initctl: options alphabetically in usage text
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-10 08:11:37 +02:00
Joachim Wiberg d6fdf4a806 README: update initctl usage text
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-10 08:11:37 +02:00
Joachim Wiberg 4be9d97e61 README: make sure to mention auto-disable of cgroups
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-10 08:11:37 +02:00
Joachim Wiberg 021d011493 man: mention the UNIX pipe at least once in every man page
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-10 08:11:37 +02:00
Joachim Wiberg e988d38f71 initctl: minor, fix indentation in usage text
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-10 08:06:13 +02:00
Joachim Wiberg 8690fc732b Fix #263: document confusing initctl reload foo command
What a ride, apparently we support restarting run/tasks in the same
runlevel they have already started once in.  Still unsure if adding
support for reloading a particular Finit .conf file for a service
should be in the context of this command (it isn't now).  Maybe it
is better left as a future expansion when we switch to the new .conf
format?

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-10 08:03:36 +02:00
Joachim Wiberg ceb2945da9 Update ChangeLog and bump version for v4.3-rc2
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
4.3-rc2
2022-05-09 06:55:21 +02:00
Joachim Wiberg 1b8a0951f5 initctl: update usage text with missing initctl cond get <COND>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-08 14:09:27 +02:00
Joachim Wiberg a27b8462d1 Fix #260: drop limit on device name in "Checking filesystem" output
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-08 09:59:51 +02:00
Joachim Wiberg edc2d53923 cgroup: reduce loglevel for missing/disallowed cgroup support
A user with no cgroup support in kernel does not know what they are
missing, and a user running in a container has someone else managing
cgroups.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-08 09:57:18 +02:00
Joachim Wiberg 4aae3403f5 test: new test, verify default runlevel from command line
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-08 09:57:18 +02:00
Joachim Wiberg 73423699fd test: add support for overriding default runlevel
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-08 09:57:18 +02:00
Joachim Wiberg 0cce69892a Fix #261: support for overriding default runlevel from command line
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-08 09:57:18 +02:00
Joachim Wiberg 3ca6256f87 doc: update modules-load plugin description, recommend .conf files
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-07 16:29:18 +02:00
Joachim Wiberg eca3098c0e plugins: refactor modules-load to read files in lexicographic order
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-07 16:29:18 +02:00
Joachim Wiberg 7af3461e3c Merge pull request #262 from wkz/hook-scripts
plugins: hook-scripts: new plugin for run-parts scripts on hooks

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-06 15:04:27 +02:00
Tobias Waldekranz b62c975dc4 plugins: hook-scripts: Add
Add a plugin that will allow the user to trigger the execution of
scripts from plugin hook points. This is particularly useful for early
boot debugging that needs to take place before regular services are
available.

For example, let's say that you want to enable some kernel tracing
before modules are loaded. With hook-scripts, you can just drop in a
shell script in /libexec/finit/hook/mount/all/ that will poke the
right control files in tracefs.
2022-05-06 10:36:37 +02:00
Joachim Wiberg b368bd1420 Document hidden HOOK_BANNER
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-06 08:22:01 +02:00
Joachim Wiberg 060e97d64e test: minor, drop comment within comment confusing shellcheck
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-06 08:07:44 +02:00
Joachim Wiberg 9b17ce0b7c Fix restart logic of sysv start/stop scripts and forking services
Init script return pretty quickly after launch, so we cannot use that to
detect if they, or the daemon they launched, have crashed.  So we start
the service_retry() with a 2 sec delay, which should be ample time to
allow the pidfile plugin to detect a forking service's new PID.

In release-cycle regression, no public issue needed.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-06 07:57:08 +02:00