Allow service IDs up to 64 characters to support SHA-256 hashes,
UUIDs, and other long unique identifiers. This increases memory
usage by ~98 bytes per service instance, which is negligible for
typical deployments.
The IDENT column width in initctl output adapts dynamically based
on actual ID lengths in use, so short IDs remain unaffected.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Both service and sysv stanzas support a cleanup:script (since v4.10), with an
optional timeout. These timers must be stopped when collecting a PID for an
svc_t, or when unregistering an svc_t, otherwise the timer callback will be
continuously called, reporting "spurious problem", and cause 100% CPU usage.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This patch fixes an ordering issue where the configuration generation is
stepped before all old/disabled services had been stopped. Finit should
ensure disabled services are stopped before entering the next generation.
If the genation is stepped first, all conditions are put in "flux" state,
so, e.g, a podman container running as a sysv service may lock-up until
it is killed by Finit. Found in the Infix OS project.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Also, added benefit, we don't get compiler warnings for ignoring the
return value of system(), which we don't care about in this case.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
- Allow scripts to take space separated arguments with quoting
- Simplify script-exists check, which already checks for leading /
- Unset current script on parse error
- Allow setting no timeout
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
These variables really belong in conf.c. Relocate and move external
decls. from finit.h -> conf.h to simplify linking of other programs.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
With the relocation of several functions, including inline functions,
from helpers to util, we no longer need to include log.h. Which is a
good thing, since any subsystem that needs logging should explicitly
include log.h
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The file helpers.c should strictly only be used for misc. helper
functions to the main Finit daemon. The functions moved in this
commit are generic enough to be used by any deamon or programs,
and for that we have util.c
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This refactor should have been done years ago when we first introduced
the big state machine. The old functions service_runvel() and the oddly
named service_reload_dynamic() are actually state machine control fns,
so let relocate them.
Also in this commit, remove the global variable 'sm' and rename a few of
the critical functions to better names.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Historically we've kept these two apart, but their commonalities are far
more than what separates them.
This fixes a bug where ready:scripts were not called for sysv daemons,
and also opens up for adding support for a reload:script for both types.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit also switches the stdout/stderr log capture backend for all
notify:systemd services from the sysklogd project's logger tool to the
bundled logit tool.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
clang-tidy complained that parse_prio() always returned OK(0), turns out
it was right. This patch adds validation of the parsing.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit introduces a bare-bones replacement for libsystemd:
- Build .so file and add --with-libsystemd to configure
- Add capabilities support to test/src/serv.c
- Update tests to account for a Finit built w/o libsystemd support
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This patch fixes issue #440 which details how systemd readiness
notification has been broken since its inception in Finit.
In addition to now providing a proper abstract socket, the refactor
also drops the reliance on the Finit client API to fetch a socket.
Now an s6 descriptor is the write end of a pipe() and the systemd
socket is instead created before forking off the service.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>