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>
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>
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>
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>
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>
- 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>
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>
After forking off a new child, all signals that are blocked by finit
should be unblocked before exec-ing the final binary. Also, finit now
blocks SIGHUP, so add it to the set of signals that should be
unblocked.
We should not use -Os as default optimization, it is sometimes unstable
in cross compilers. Instead, default to -O2, which is the more tried
and tested path.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When integrating finit as a component in another system, that build
system may set VERSION as an environment variable for that OS -- we do
not want that version to be set as the version of finit.
Also, bump version to 2.0.1-dev for upcoming patch release cycle.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Check return code from `mount -na`, if there where any errors give
plugins a chance to do something about it.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds a simple `service <script> <stop|start|reload|restart>`
script for for SysV init compatibility. Very common with users of the
Ubuntu upstart init as well.
Also, fixed `make uninstall` for plugins.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Even though libite and libuEv can be disabled, using the --with-libnnn
option to configure, we let make descend into those submodules for the
clean and distclean targets. This way we can rely on make dev to work.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit makes it possible to build Finit with an external libuEv.
Without this configure script option the libuev submodule is used.
With an external libuEv we make sure to set the SONAME to libuev.so.1
to prevent any future runtime ABI issues.
Fixes issue #4.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit makes it possible to build Finit with an external libite.
Without this configure script option the libite submodule is used.
With an external libite we make sure to set the SONAME to libite.so.2
to prevent runtime ABI issues with older libite versions.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit adds support for event based services to Finit. Along with
the previously added support for multiple instances of the same process,
the feature scope for Finit v2.0 has been reached!
As of now a service can be declared in /etc/finit.conf or /etc/finit.d/
like this:
service :1 [2345] <!IFUP:eth0,GW> /sbin/dropbear -R -F -p 22 -- SSH daemon
Here the first instance `:1` of dropbear is declared to run in runlevels
2-5, but only if eth0 `IFUP:eth0` is up and a gateway `GW` is set. When
the configuration changes, a new gateway is set, or somehow a new `IFUP`
event for eth0 is received, then dropbear is not SIGHUP'ed, but instead
stop-started `<!>`. The latter trick applies to all services, even
those that do not define any events.
Currently inetd services are not supported for event based starting, but
it could easily be added. Likely scenario is to deny incoming requests
on, e.g., eth0 if there is no gateway.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The event API, including Netlink events to services, looks OK now
to build the remaining two features on:
- Netlink plugin for GW and IFUP IFDN events
- Generic event support for services
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Previously `HOOK_SVC_RECONF` was only called on `initctl reload`,
now we also call it on `initctl emit "STOP"`. This seems like a
good idea atm, hopefully it will remain a good idea.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This part of the README must be completely overhauled before the
release, so much of the contents is basically just TODO or design
ideas atm.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>