Commit Graph
636 Commits
Author SHA1 Message Date
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
Tobias Waldekranz 7a3408c173 Optionally skip stripping binaries during install-exec
One may wish to build and install with debug symbols intact, so allow
overriding the arguments sent to install.
2016-01-05 14:50:13 +01:00
Tobias Waldekranz af7b6c17cb Correctly parse service configuration stanzas containing slashes
Parser would erroneously interpret an event specification containing
slashes as an inet service/proto specification.

E.g. "<net/gw>" was interpreted as port "<net" using protocol "gw>".
2016-01-05 14:50:13 +01:00
Joachim Nilsson a822a7657c Update ChangeLog and bump version for v2.4 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2.4
2015-12-04 19:15:48 +01:00
Joachim Nilsson e46271c1a9 Revert change in v2.3 listing stopped services as "paused"
Stopped services are now (again) listed as "stopped" and halted
services, due to a runlevel change, are listed as "halted". Several
users complained that this change was just not intuitive. I agreee.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-12-04 19:05:35 +01:00
Joachim Nilsson 1028725079 Add support for 'initctl show dropbear:2'
By popular request, this patch adds support for querying status of a
single service.  The syntax is similar to that of stop/start/reload.

Both `initctl show ...` and `initctl status ...` is supported.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-12-03 20:05:25 +01:00
Joachim Nilsson ed5ee667ae [Patch 2/2]: Make sure to start/SIGHUP services when none were stopped
When no services were stopped we must ensure to start/SIGHUP any new or
SIGHUP:able services as the last pass of the `initctl reload` cycle.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-12-02 13:06:16 +01:00
Joachim Nilsson 4c3e053041 [Patch 1/2]: System reconfiguration causing system freeze
This patch fixes a hang when performing a system reconfiguration using
`initctl reload`, `SIGHUP` or running `(f)init q`, which caused Finit
to wait for SIGHUP:able services to stop.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-12-02 13:02:40 +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 fa3a97366c Update Debugging section, all interesting stuff is in configure now
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-12-01 22:30:08 +01:00
Joachim Nilsson 5b3e3da7ff Attempt to clarify how BusyBox getty works wrt. the TTY device path
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-12-01 22:24:21 +01:00
Joachim Nilsson 59d96f264d Reenable verbose mode at reboot, if disabled at boot
This patch reenables verbose mode at shutdown/reboot, if it was disabled
at boot.  This allows the user to see the output from the `urandom.so`
and `hwclock.so` plugins at reboot.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-30 22:31:48 +01:00
Joachim Nilsson 7027cbc439 Enforce terse mode after boot, if verbose is disabled
The urandom.so plugin uncovered that `print_desc()` does not honor the
`verbose` flag.  At runtime `print_desc()` et al should no be displaying
anyting when we finit operates in terse mode.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-30 19:45:27 +01:00
Joachim Nilsson 8218fff7e5 Update ChangeLog and bump version for v2.3 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2.3
2015-11-28 13:59:47 +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 1f88e1ff8a Refactor svc_status() used by 'initctl show'
Leverage new svc_t states in initctl status/show output.  Also, ensure
different svc_t types have correct start state.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-26 20:51:04 +01:00
Joachim Nilsson b4ccc8b008 Clean up bootstrap-only tasks when leaving bootstrap 'S' runlevel
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-26 20:22:24 +01:00
Joachim Nilsson 8df2b7b6e9 service_stop_dynamic(): Skip already stopped and HALT removed services
new postponed stop handling tried to reload already stopped and removed
services.  We should of course skip already stopped services and halt
those that have been removed.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-26 19:13:39 +01:00
Joachim Nilsson 8073f7cf27 Revert semantic change in 'initctl restart' introduced in 924bf04
This patch reverts the change in behavior introduced in Finit v2.2,
commit 924bf041, where `initctl restart JOB` changed from 'stop + start'
to `SIGHUP` for services that support `SIGHUP`.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-25 10:14:18 +01:00
Joachim Nilsson e303e1f833 Fix column alignment in initctl show for services not in current runlevel
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-25 09:36:56 +01:00
Joachim Nilsson 3ea4be9343 Fix NULL ptr dereference causing kernel panic
When `service_stop_done()` is called with a `NULL` argument and no
dynamic services have been stopped, this regression is triggered.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-25 09:30:53 +01:00
Joachim Nilsson d8188428ed Bump version for v2.2 release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2.2
2015-11-23 13:20:44 +01:00
Joachim Nilsson d9f1882204 Update ChangeLog and prepare for release of v2.2
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-23 00:59:04 +01:00
Joachim Nilsson 4d899851cc Upgrade libite (LITE) to v1.2.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-23 00:45:55 +01:00
Joachim Nilsson ad8feca3e7 Upgrade libuEv to v1.2.4
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-23 00:45:20 +01:00
Joachim Nilsson 7569c479b8 Improve event debugging
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-22 22:18:56 +01:00
Joachim Nilsson e7db6c6ac6 Update README with latest changes to initctl help
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-22 22:18:40 +01:00
Joachim Nilsson f12535dc19 Clarify that the GW event to listen for in service declarations is GW:UP
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-22 22:18:15 +01:00
Tobias Waldekranz b19ea16e9d Only trigger on events that matches the service's specification
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
2015-11-22 19:59:01 +01:00
Joachim Nilsson eb59155dad Enable mdev logging when Finit runs in debug mode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-22 19:53:44 +01:00
Joachim Nilsson f38dfaf2dc Pretty printing of current runlevel in initctl show
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-22 15:58:32 +01:00
Joachim Nilsson 4ada42f380 Add debug flag to initctl client tool
This patch makes it possible to see debug traces when running the client
program initctl, using `--debug`.  Please note, this does not affect the
debug command to the daemon.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-22 15:57:56 +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 b1d57d6828 Set default value for svc->sighup, even if service has no event mask
The `initctl reload <JOB>` command did not work properly.  This
was due to the service not being properly initialized to default
settings when reading the Finit configuration file.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-22 10:05:57 +01:00
Joachim Nilsson 87f9b94b42 Call HOOK_SVC_RECONF only when all processes have been stopped
This patch fixes a race condition when doing an ordered RELOAD and STOP
event sequence.  For services that shall be stopped it is imperative
that we wait for them to be colleced by the `service_monitor()`, so that
we know they have really been stopped, before calling HOOK_SVC_RECONF.

The latter is a promise to external services that all services have been
indeed stopped.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-19 19:29:16 +01:00
Joachim Nilsson c8f0b97d0f tty.c: Handle EINVAL and use recommended inotify event size.
The TTY plugin might fail in read() with EINVAL if the inotify event
buffer is too small.  Fix: set the receive event buffer to the size
recommended in inotify(7).  Also add a handler for EINVAL to close and
reinitialize the inotify descriptor so we do not accidentally overrun
the CPU with any unhandled errors.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-26 04:33:51 +01:00
Joachim Nilsson f902505b5d Declare name for all plugins, needed for static builds.
When building a static Finit the plugins do not get a unique name
automatically from the file.  This led to only the first plugin being
loaded, since its name was 'unknown' it was registered as such and all
other plugins conflicted, since 'unknown' was already ... known and
loaded.

This patch gives all plugins a default name, __FILE__, making it
possible to use all of them when building a static Finit.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-26 03:44:43 +01:00
Joachim Nilsson a6b78d57c0 Clarify why we must define the name for inetd plugins.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-26 03:39:05 +01:00
Joachim Nilsson a33478d563 Improve urandom plugin for embedded systems w/o random seed.
For embedded systems with no initial random seed, usually stored in
/var/lib/urandom/urandom-seed on desktops, servers and laptops, we now
provide an initial seed file using a built-in PRNG.

Also, let the configure script default to *enable* the random seeding
at boot, granted the urandom plugin is enabled.  We should encourage
users to properly seed their random, for security reasons.

Moreover, the plugin did not properly regenerate the random seed on
reboot, or shutdown, this patch also rectifies that problem.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-26 03:31:19 +01:00
Joachim Nilsson 369fcf2100 Issue #14: Improved support for static Finit builds
- Upgrade libite (LITE) for new UNIX file parser API to improve static
  builds of Finit.
- Re-enable bootmisc plugin for static builds by adding built-in support
  for reading GID from /etc/group.
- Allow inetd support for static builds by adding built-in support for
  reading service and protocol from /etc/services and /etc/protocols.
- Do not try to install/uninstall any plugins for static builds.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-26 00:56:50 +01:00
Joachim Nilsson b2c5e97417 Disable bootmisc plugin entirely if configure --enable-static
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-22 19:01:19 +02: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 58980c72fa Misc. fixes to silence warnings when building a static Finit.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-22 18:39:46 +02:00
Joachim Nilsson bcc70ec774 Update libite and libuev to handle static builds.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-22 18:38:47 +02:00
Joachim Nilsson 44579cc089 README: Clarify how arguments to ./configure --with-plugins= work
This should help clarify any misunderstandings detailed in issue #13.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-22 15:19:01 +02:00
Joachim Nilsson da361f460d Update ChangeLog slightly, off by one fix
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-16 20:56:56 +02:00
Joachim Nilsson bc2cb21005 Update version links.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2.1
2015-10-16 20:46:34 +02:00
Joachim Nilsson e1169628ce Update ChangeLog and bump version for v2.1 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-16 20:44:47 +02:00
Joachim Nilsson 48b420b757 Simplify execution and _exit() of service callback.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-16 19:45:09 +02:00
Joachim Nilsson 9796809907 Merge pull request #12 from westermo/wkz/sighup-fix
Unblock blocked signals after forking off a child
2015-10-16 18:42:47 +02:00