Commit Graph
16 Commits
Author SHA1 Message Date
Tobias Waldekranz c641a1374e Do not ignore updated services when cleaning up removed ones
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.
2016-01-13 15:14:27 +01:00
Tobias Waldekranz 2232aea0f7 Dynamically manage service states based on user defined conditions
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.
2016-01-05 15:01:58 +01:00
Joachim Nilsson a5c5a5c644 Allow debug mode to override terse mode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-12-01 22:36:16 +01:00
Joachim Nilsson 263e23a0df initctl: Support for stop/start services by name:id
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-26 21:22:05 +01:00
Joachim Nilsson 924bf041bc On reload/restart we must wait for services to stop first
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>
2015-11-22 10:11:27 +01:00
Joachim Nilsson 8725200260 Build fixes for configure --disable-inetd
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>
2015-10-22 18:59:20 +02:00
Joachim Nilsson 05a8ace030 Add support for 'initctl emit EVENT' for more granular control.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-29 00:58:12 +02:00
Joachim Nilsson a05f920292 Refactor: Cleanup internal API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-28 17:23:07 +02:00
Joachim Nilsson 8e12dba8d9 Refactor: Move conf.c declarations from finit.h --> conf.h
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-22 15:12:20 +02:00
Joachim Nilsson ac0edc9b37 initctl: Fix broken presentation of inetd services in verbose mode.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-21 18:54:29 +02:00
Joachim Nilsson d0da3b8b98 Followup to 'initctl with process name as well as JOBID'
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-21 17:56:41 +02:00
Joachim Nilsson 577622c945 Add support for calling initctl with process name as well as JOBID
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>
2015-06-21 15:54:47 +02:00
Joachim Nilsson 1f19b50846 Fix Coverty CID #96208: Unchecked return value from library.
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>
2015-06-17 13:36:17 +02:00
Joachim Nilsson dbcece81ea Fix Coverty CID #96210: Argument cannot be negative.
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>
2015-06-17 13:36:06 +02:00
Joachim Nilsson 70f4d99922 Fix Coverty CID #96211: String not NUL terminated.
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>
2015-06-17 13:35:10 +02:00
Joachim Nilsson b0c759e518 Add missing file api.c
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-15 14:06:55 +02:00