Libraries and system headers should be included with <> instead of "".
This makes a great difference for the automatic dependency tracking.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Both the new initctl API and the new pidfile watcher plugin failed to
set CLOEXEC on their sockets. This caused forked-off and exec()'d
children to inherit all these descriptors.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch replaces the verbose and kernel-quiet runtime options with
a (hopefully) more useful quiet and silent modes of operation.
By default Finit progressively shows all services it starts at boot, but
when boot has completed and services are started/restarted Finit prints
nothing. If `--disable-quiet` is given all started/restared/stoppping
messages are shown even after boot.
However, if `--enable-silent` is given Finit is completely silent even
at boot, no progress is shown, until the first service is started, which
on most systems is login.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When cleaning up removed services, the assumption was made that if a
service was not 'removed', it was 'clean'. In reality, it could also
be 'updated', which was then overwritten, causing services not being
restarted. Don't do that.
As a future precaution, make the dirty field const, only allowing
updates from accessor methods.
Old event system has been replaced with a more generic condition
concept. The idea is that finit plugins may provide arbitrary
conditions that services may specify as dependencies that they require
to run.
In order to accomodate this, the service management has been
redesigned to use a state machine.
This patch adds support for declaring *why* a service is being stopped
or reloaded. This is later used when all stopped services have been
collected by the `service_monitor()` to issue start or postponed SIGHUP.
As an added benefit we can now also see why a service is not running.
If it has been paused by a user, halted when moving to another runlevel,
waiting for a condition (event), or similar.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
service.c:
Don't declare find_inetd_svc() if inetd is disabled.
api.c:
Disable inetd API
initctl.c:
Disable presentation of inetd services
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch makes it possible to communicate process name or JOB[:ID]
from initctl to Finit. When the process name translates into a service
with multiple instances Finit applies the requested command to all
instances. For example, two Dropbear SSH services running on two
different ports, calling `initctl stop dropbear` stops both services.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Replace `remove()` with our own `erase()` which checks the return value
and warns on actual real failure.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
We must check the return value from `accept()`, it may fail. Also, we
should probably retry the syscall in some cases ...
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When receiving a start/stop/reload/restart request from initctl we must
make sure to validate and NUL terminate the job ID. The `read()` API
does not NUL terminate strings for us and we cannot rely on `initctl` or
any other external API user to do so for us.
This patch improves error and boundary checking.
- Use memcpy() + hard termination instead.
- Fix use of strchr() on possibly non-NUL terminated string.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>