Commit Graph
803 Commits
Author SHA1 Message Date
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
Tobias Waldekranz a3193b34a6 Unblock blocked signals after forking off a child
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.
2015-10-16 18:32:53 +02:00
Joachim Nilsson c0af01db6d Upgrade libite (LITE) to v1.1.1
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-10 17:36:24 +02:00
Joachim Nilsson 3c1c7df420 Default to -O2, not -Os, and use CPPFLAGS for includes, not CFLAGS.
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>
2015-10-10 17:34:31 +02:00
Joachim Nilsson 258efd4101 Cleanup, minor bug fixes and silencing of netlink plugin.
Patch courtesy of Westermo.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-08 19:59:19 +02:00
Joachim Nilsson 5e33647f80 Fix too small MAX args in initctl and too few args in svc_t
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-07 21:03:35 +02:00
Joachim Nilsson d2f23e281f Allow Finit to set hostname at dynamic reload.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-06 19:35:02 +02:00
Joachim Nilsson b5e3e69553 Do not allow VERSION to be overloaded by build system.
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>
2015-10-02 15:09:07 +02:00
Joachim Nilsson 8d85e59214 Optimization is a CFLAG, not a CPPFLAG
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-29 22:39:49 +02:00
Joachim Nilsson a1c8ada320 Play around a bit with project title heading.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-29 22:39:19 +02:00
Tobias Waldekranz ae15988eb8 Add hook point on fstab mount failure
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>
2015-09-29 22:38:06 +02:00
Joachim Nilsson 9491f18972 service_enabled(): Only check WCOREDUMP() from if WIFSIGNALED()
Patch courtesy of Westermo.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-28 19:17:30 +02:00
Joachim Nilsson 545f3105e2 Update ChangeLog and bump version for v2.0 release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2.0
2015-09-20 12:27:41 +02:00
Joachim Nilsson eec166a9eb Add simple service script for SysV init compat.
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>
2015-09-19 22:04:26 +02:00
Joachim Nilsson 125fc661a3 Makefile: Allow clean and distclean targets when libite/libuev are disabled.
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>
2015-09-18 09:14:49 +02:00
Joachim Nilsson 6531b2f20a Add --with-libuev=PATH to configure script to use external libuEv
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>
2015-09-17 12:59:20 +02:00
Joachim Nilsson 1f84edfb8c Add --with-libite=PATH to configure script to use external libite
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>
2015-09-17 11:59:46 +02:00
Joachim Nilsson c354d0e7e6 Upgrade libite to v1.1.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-17 11:19:19 +02:00
Joachim Nilsson 98eb7cfea1 Upgrade libuEv to v1.2.3
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-17 11:18:38 +02:00
Joachim Nilsson ec80ce1c9b Add distclean step after Coverity run.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-15 11:58:53 +02:00
Joachim Nilsson ef05983dc8 Fix Coverity CID #149216: Buffer not NUL terminated
We should of course always use `strlcpy()` instead of `strncpy()`.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-15 11:49:47 +02:00
Joachim Nilsson 1c04097dca Update ChangeLog with new features and some Markdown syntax fixes.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-15 09:32:12 +02:00
Joachim Nilsson 36aba8952f Bump version to v2.0-beta1 for upcoming release and rename CHANGELOG.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-15 09:25:05 +02:00
Joachim Nilsson 6e07dd8dec Add support for starting/stopping services on Netlink events
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>
2015-09-15 09:13:33 +02:00
Joachim Nilsson ffa32c6674 README: Clearify how multiple events can be emitted by initctl.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-15 09:05:10 +02:00
Joachim Nilsson c30039facf Minor refactor and cleanup.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-14 01:23:17 +02:00
Joachim Nilsson b13c6421b3 First Netlink plugin prototype.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-11 13:10:20 +02:00
Joachim Nilsson fcaf5d7b76 README.md: Commit to spec for v2.0 release.
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>
2015-09-11 09:51:10 +02:00
Joachim Nilsson f9ddb1bdfc Make sure to always run HOOK_SVC_RECONF when services have been stopped.
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>
2015-09-11 08:58:39 +02:00
Joachim Nilsson 5701a00558 Update with idea on generic event support.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-08 08:19:16 +02:00
Joachim Nilsson 9a81bbccbb Update section on new emit <EVENT> support.
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>
2015-09-08 08:18:49 +02:00
Joachim Nilsson 2fcd0fd899 Merge branch 'wishdev-makefile-glibc-2.20' into dev 2015-09-08 08:01:12 +02:00
Joachim Nilsson 5126017c7e Merge branch 'makefile-glibc-2.20' of https://github.com/wishdev/finit into wishdev-makefile-glibc-2.20 2015-09-08 08:00:39 +02:00
John W Higgins d2ed03e74c Update Makefile for glibc-2.20+ 2015-09-07 16:56:32 -07:00