Services, like dbus and teamd for instance, may create their PID files
in a subdirectory of /var/run (today often /run). E.g.,
- /var/run/teamd/a1.pid -- For aggregate A1
- /var/run/dbus/pid
- /var/run/lxc/foo.pid -- For container foo
This patch adds support for dynamically adding inotify watchers to any
new subdirectory created in /var/run (discarding too deep directories).
To match services in this directory the run/task/service/sysv stanza
must contain the pid:!/path/to/pidfile.pid syntax. This pid file name
is also used to create the condition this service asserts using the
following formula:
svc/ + <dirname of service> + <subdir and file without .pid>
E.g., the case of teamd (above) gives condition 'svc/usr/bin/teamd/a1'
The special case of dbus is interesting, since it may not be a special
case, but rather the norm for services using a subdirectory. It is
handled as follows; when a new subdirectory is detected, the directory
is scanned for files matching *.pid. Matching files follow the teamd
case. The directory is also scanned for 'pid', which then gives us the
condition 'svc/usr/bin/dbus'
One last example, illustrated by lxc-start, where we want to track the
condition for the LXC container foo. The service stanza:
service pid:!/run/lxc/foo.pid lxc-start -n foo -F -p /run/lxc/foo.pid -- Container foo
This command has no leading path so the condition is composed entirely
from the PID file location:
svc/ + '' + lxc/foo => svc/lxc/foo
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds a new plugin to Finit called modprobe. It probes in
/sys/devices after modalias files and then calls 'modprobe -ab' for
each alias listed.
For hot-plugging we recommend adding the following to /etc/mdev.conf
$MODALIAS=.* root:root 0660 @modprobe -b "$MODALIAS"
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The BusyBox hwclock is really bad at handling, or rather displaying,
errors properly. When the kernel signals EINVAL, or ENOENT, it just
shows that message on stderr.
This patch implements proper RTC load/store at boot/halt with quite
some improved error handling suitable for embedded systems.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
We can now rely on service_step() to continue stepping run/taks/services
until no more state transitions are made.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Reassert condition when an unchanged/unmodified process goes from
WAITING state to RUNNING. I.e. it had a condition that went to flux
during `initctl reload`, which drove it to WAITING and was then sent
SIGSTOP during reconf.
Also, on condition update, loop through all services until no more state
changes are observed. This allows long dependency chains of services to
resolve and actually go back to RUNNING state as intended whenever any
condition changes at runtime.
Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This reverts commit df89cc79b9. Not all
distros (Debian, Alpine) have a dbus-daemon that supports --syslog-only
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The pidfile plugin just listens to changes in files in /run or /var/run,
so when trying to locate an svc_t from a file change we need to compare
using the proper prefix path.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
A service may now have a custom PID file, possibly because it doesn't
really create one itself. This needs to be taken into account also in
the pidfile plugin.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
An interface may come up with IFF_RUNNING already set, but we would
only detect IFF_UP. This patch simplfies the code a lot by pivoting
the qualifier from using ifi_change to ifi_flags, which is the actual
current status of an interface.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The /lib/finit/plugins path is as of this patch not longer possible to
change. Use --prefix or --libdir instead to change the leading path.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch implements support for calling run/task jobs on the built-in
`HOOK_*` points in Finit. To map each HOOK point to a condition a new
classification was made, as shown in plugin.h and in the example below.
task <hook/mount/root> /sbin/attachubi.sh # run in parallel with other tasks/services
run <hook/net/up> /sbin/dosomething.sh # run in sequence with other commands
Please note, only rudimentary tested.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch extends the existing rlimit implementation to support setting
limits per service, run/task, inetd, and tty.
Use rlimit in /etc/finit.conf to change the global setting, which is
then inherited to each /etc/finit.d/*.conf. For each .conf file the
rlimit is reinitialized to the global finit.conf settings.
Also, add `unlimited` keyword, to replace the now deprecated `infinity`
keyword. The latter is however kept, for compatibility with previous
releases, for the foreseeable future.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Some systems use /var/db while others use /var/lib/misc, we need to
support both and cannot rely on _PATH_VARDB, since it too might not
be set properly.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When performing an `initctl reload` with one (unchanged) service
depending on, e.g. `net/iface/lo`, its condition will not be set
to ON by the pidfile plugin unless the netlink plugin hook runs
first.
Example:
service <net/iface/lo> /sbin/dropbear ...
Which provides the <svc/sbin/dropbear> condition, will not be
set by pidfile.so during `initctl reload` because dropbear is
still SIGSTP:ed waiting for <net/iface/lo>.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
In GCC 7 the -Wall infers the new -Wformat-truncation which finds
problems with string truncation in functions like snprintf().
This patch fixes a problem in condition parsing for very long
PID filenames which might be truncated in internal buffers
causing a mismatch in Finit condition tracking.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
In GCC 7 the -Wextra infers the new -Wimplicit-fallthrough which can be
suppressed by adding a simple comment
/* fallthrough */
Which we had, but was too verbose (and misspelled) for GCC to notice.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch changes how the D-Bus plugin starts dbus-daemon, from being
started in the background to letting Finit start and monitor it.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
It is strongly recommended to instead use the service stanza to start
XDM/GDM, or use startx after a regular login.
Note: the `user NAME` setting was always reserved for use with startx
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>