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>
Prevent name clash with upcoming refactor and any confusion with
src/plugin.c functions with the same name.
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>
A systemd service should only use NOTIFY_SOCKET and an s6 style
service reads its notify descript from the command line. For
details, see notify.sh
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit introduces a stripped down sd_notify(), taken from the
systemd man page example, which is used by the serv daemon in lieu
of the previous broken implementation.
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>
When building with global CFLAGS=-Wunused-parameter the output from the
build looks terrible. This commit explicitly declares unused variables
to prevent triggering -Wunused-parameter
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
An svc_t (service/sysv) that is in setup, teardown, or cleanup state
must be ignored by the pidfile plugin for any events regarding PID
files. E.g., a setup script for a sysv service may create a PID file
to alert the system that a setup process for the service is running.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The service_fork() function blocks all signals for the new process, it
is up to the callee to call sig_unblock() before calling exec().
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
All run/tasks must complete before Finit moves to runlevel 2. This
critical piece of information has mysteriously been missing from the
documentation since the start.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Add explicit argument separator before username to ensure correct
parsing of the login command regardless of username format. This
follows best practices for command execution and prevents unexpected
behavior when processing special characters in usernames.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
When a service is stopped, but does not respond to the default SIGTERM,
a fallback kicks in after 3 seconds (default) to send SIGKILL. Since
91a9c83 (v3.2-rc2) this has however not worked since the signal was
only sent to the process group.
It is the job of service_monitor(), when it reaps the process leader,
to forward the signal to the process group.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Don't try to source an optional env:file if it is missing. Otherwise
execution of pre/post/ready/cleanup script will fail.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>