Commit Graph
388 Commits
Author SHA1 Message Date
Joachim Nilsson c64188bfc5 plugins: rtc: Simplify failed restore from RTC warning
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-04-29 18:20:38 +02:00
Joachim Nilsson 5e789401d4 Rename hwclock.so plugin to rtc.so since it's now stand-alone
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-04-05 21:35:13 +02:00
Joachim Nilsson 744fdd654f plugins: hwclock: Native ioctl support for RTC, skip hwclock tool
The BusyBox hwclock is really bad at handling, or rather displaying,
errors properly.  When the kernel signals EINVAL, or ENOENT, it just
shows that message on stderr.

This patch implements proper RTC load/store at boot/halt with quite
some improved error handling suitable for embedded systems.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-04-05 21:27:39 +02:00
Robert Andersson 76fc72770e pidfile: monitor renamed files, e.g. rsyslogd.pid.tmp
Signed-off-by: Robert Andersson <robert.m.andersson@se.atlascopco.com>
2018-10-22 12:53:57 +02:00
Robert Andersson 423c8d41a7 modules-load: add task name config
Signed-off-by: Robert Andersson <robert.m.andersson@se.atlascopco.com>
2018-10-22 12:51:58 +02:00
Robert Andersson 33fd6f0049 Add modules-load.d plugin
This plugin scans /etc/modules-load.d for modules to modprobe.

Signed-off-by: Robert Andersson <robert.m.andersson@se.atlascopco.com>
2018-10-22 12:51:58 +02:00
Joachim Nilsson 931565c425 Simplify pidfile_reconf() thanks to the addition of schedule_wq()
We can now rely on service_step() to continue stepping run/taks/services
until no more state transitions are made.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-10-07 18:35:12 +02:00
Jonas Johansson dddd45e3b5 Reassert condition when svc_t goes from WAITING --> RUNNING
Reassert condition when an unchanged/unmodified process goes from
WAITING state to RUNNING.  I.e. it had a condition that went to flux
during `initctl reload`, which drove it to WAITING and was then sent
SIGSTOP during reconf.

Also, on condition update, loop through all services until no more state
changes are observed.  This allows long dependency chains of services to
resolve and actually go back to RUNNING state as intended whenever any
condition changes at runtime.

Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-10-02 19:03:30 +02:00
Joachim Nilsson 682e80fed5 Remove HOOK_SVC_LOST, recommend using accounting instead
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-30 11:28:27 +02:00
Joachim Nilsson 406339e755 Refactor, unify finit_tty_t + tty_node_t --> struct tty
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-18 18:19:31 +01:00
Joachim Nilsson 3092d55ec5 dbus: Fix too short buffer for dbus-daemon command line
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-01 00:40:54 +01:00
Joachim Nilsson cd791afea5 Revert "dbus: Use --syslog-only instead of Finit built-in log redirect"
This reverts commit df89cc79b9.  Not all
distros (Debian, Alpine) have a dbus-daemon that supports --syslog-only

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-01 00:22:01 +01:00
Joachim Nilsson df89cc79b9 dbus: Use --syslog-only instead of Finit built-in log redirect
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-02-17 17:28:57 +01:00
Joachim Nilsson 3429901d83 dbus: Silence dbus daemon, redirect stdout/stderr to syslog
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-02-17 17:26:39 +01:00
Joachim Nilsson c969bda62d bootmisc.so: Create /etc/mtab symlink if missing
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-18 13:34:28 +01:00
Joachim Nilsson f9783b4b41 pidfile: Use realpath() to figure out of _PATH_VARRUN is a symlink
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-13 21:49:18 +01:00
Joachim Nilsson 32d9afc7bb Use pid_runpath() in svc_find_by_pidfile(), used by pidfile plugin
The pidfile plugin just listens to changes in files in /run or /var/run,
so when trying to locate an svc_t from a file change we need to compare
using the proper prefix path.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-13 21:47:11 +01:00
Joachim Nilsson 0d4bc69584 pidfile: Use new svc_find_by_pidfile() in plugin
A service may now have a custom PID file, possibly because it doesn't
really create one itself.  This needs to be taken into account also in
the pidfile plugin.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-11 10:50:19 +01:00
Joachim Nilsson cf6faa9eeb netlink.so: Refactor, break out condition set/clear func.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-31 12:41:27 +01:00
Joachim Nilsson 80a71aff07 netlink.so. Refactor (simplify) and fix problem with loss of events
An interface may come up with IFF_RUNNING already set, but we would
only detect IFF_UP.  This patch simplfies the code a lot by pivoting
the qualifier from using ifi_change to ifi_flags, which is the actual
current status of an interface.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-31 12:25:50 +01:00
Joachim Nilsson 04a4653e9b netlink.so: Add support for IFF_RUNNING => net/IFNAME/running
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-31 12:07:47 +01:00
Joachim Nilsson c605874b26 Remove --with-plugindir=DIR, use --prefix or --libdir instead
The /lib/finit/plugins path is as of this patch not longer possible to
change.  Use --prefix or --libdir instead to change the leading path.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-30 21:20:06 +01:00
Joachim Nilsson 8992e7bf2b Refactor svc_iterator() into a proper iterator, add first flag
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-22 23:56:14 +01:00
Joachim Nilsson 0f1f51b5ad Refactor, change from static array of svc_t to linked list
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-18 17:50:02 +01:00
Joachim Nilsson 7f04382eee Refactor, use new re-entrant svc_iterator1() API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-18 00:21:07 +01:00
Joachim Nilsson 23e0928e5c Minor, unused arguments no longer need magic tricks or hand waving
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-18 00:17:00 +01:00
Joachim Nilsson 9e31bd8a23 Fix #18: Add support for calling run/tasks on HOOK points
This patch implements support for calling run/task jobs on the built-in
`HOOK_*` points in Finit.  To map each HOOK point to a condition a new
classification was made, as shown in plugin.h and in the example below.

task <hook/mount/root> /sbin/attachubi.sh      # run in parallel with other tasks/services
run  <hook/net/up>     /sbin/dosomething.sh    # run in sequence with other commands

Please note, only rudimentary tested.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-13 17:58:48 +01:00
Joachim Nilsson b68c5c1291 Fix #45: add support for rlimit per service/run/task/inetd/tty
This patch extends the existing rlimit implementation to support setting
limits per service, run/task, inetd, and tty.

Use rlimit in /etc/finit.conf to change the global setting, which is
then inherited to each /etc/finit.d/*.conf.  For each .conf file the
rlimit is reinitialized to the global finit.conf settings.

Also, add `unlimited` keyword, to replace the now deprecated `infinity`
keyword.  The latter is however kept, for compatibility with previous
releases, for the foreseeable future.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-26 16:35:37 +01:00
Joachim Nilsson 3fd45eac7c bootmisc: Handle _PATH_VARDB inconsistency gracefully
Some systems use /var/db while others use /var/lib/misc, we need to
support both and cannot rely on _PATH_VARDB, since it too might not
be set properly.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 15:24:25 +01:00
Joachim Nilsson 5af1f05606 plugin: Only close() PID file descriptors >0, skip -1
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 14:34:08 +01:00
Joachim Nilsson 6b2678c2ed pidfile: On HOOK_SVC_RECONF the netlink plugin must run first
When performing an `initctl reload` with one (unchanged) service
depending on, e.g. `net/iface/lo`, its condition will not be set
to ON by the pidfile plugin unless the netlink plugin hook runs
first.

Example:

    service <net/iface/lo> /sbin/dropbear ...

Which provides the <svc/sbin/dropbear> condition, will not be
set by pidfile.so during `initctl reload` because dropbear is
still SIGSTP:ed waiting for <net/iface/lo>.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-24 15:55:35 +02:00
Joachim Nilsson faca84a590 Fix GCC 7 string truncation warning, too small temporary buffer
In GCC 7 the -Wall infers the new -Wformat-truncation which finds
problems with string truncation in functions like snprintf().

This patch fixes a problem in condition parsing for very long
PID filenames which might be truncated in internal buffers
causing a mismatch in Finit condition tracking.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 09:58:05 +02:00
Joachim Nilsson 920df09cd5 Fix GCC 7 warning, convert "Fall through" to "fallthrough" comment
In GCC 7 the -Wextra infers the new -Wimplicit-fallthrough which can be
suppressed by adding a simple comment

    /* fallthrough */

Which we had, but was too verbose (and misspelled) for GCC to notice.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 09:58:05 +02:00
Joachim Nilsson bacaea0e02 bootmisc: Fix misspelled uuidd
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:14:56 +02:00
Joachim Nilsson 07d6e69c30 bootmisc: Check return value from getgroup()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:10:13 +02:00
Joachim Nilsson d2053bd07d bootmisc: Follow-up to f4662d8
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:09:15 +02:00
Joachim Nilsson f4662d8c06 boomisc: Create /run/uuid for Void Linux if uuid user exists
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:05:46 +02:00
Joachim Nilsson 7a2667d34c plugins/dbus: Free cmd returned from which() when done
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 23:01:10 +02:00
Joachim Nilsson f39cd50762 plugins/dbus: Use cmd found by which() to start dbus-daemon
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 22:48:04 +02:00
Joachim Nilsson ddeed15191 plugins/dbus: Start dbus-daemon with absolut path
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 22:45:01 +02:00
Joachim Nilsson b02f241e5e plugin/dbus.c: Minor, documentation
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 21:18:21 +02:00
Joachim Nilsson 888ce56f3e plugin/dbus.c: Register dbus-daemon as a service
This patch changes how the D-Bus plugin starts dbus-daemon, from being
started in the background to letting Finit start and monitor it.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-15 20:46:22 +02:00
Joachim Nilsson 6818813ff8 plugins/dbus: Conditionalize, don't run if dbus-daemon is missing
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-13 08:02:59 +02:00
Joachim Nilsson c8d8c817e7 Minor, cleanup
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-11 21:29:21 +02:00
Joachim Nilsson 448c6749d6 Add missing debug calls to RTM_NEWLINK and RTM_DELLINK
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-10 22:53:19 +02:00
Joachim Nilsson a2f4b35e4e Fix #77: Remove deprecated startx and user .conf settings
It is strongly recommended to instead use the service stanza to start
XDM/GDM, or use startx after a regular login.

Note: the `user NAME` setting was always reserved for use with startx

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-30 15:01:05 +02:00
Joachim Nilsson 963b736d8b tty: Refactor, remove useless runlevel argument
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-09 15:05:32 +02:00
Joachim Nilsson 6f61e8e915 Remove hard-coded paths to system tools available in $PATH
Since at least a44daf2 both run() and run_interactive() can access all
system tools in _PATH_STDPATH.  A system that uses non-standard paths,
e.g. /system/bin and /apps/bin, should update _PATH_STDPATH.

For reference, see issue #69 and PRs #70 and #72.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-03 13:18:42 +02:00
Joachim Nilsson 9c6e046d93 Remove hard-coded paths to system tools available in $PATH
This patch implemements a new feature of libite v1.9.1, whichp(), which
instead of fexist() that requires an absolute path, searches $PATH.

For reference, see issue #69 and PRs #70 and #72.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-03 13:13:55 +02:00
Joachim Nilsson 30822f0d68 Remove UNUSED() macro and disable the compiler warning instead
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 21:59:23 +02:00