Commit Graph
2171 Commits
Author SHA1 Message Date
Joachim Wiberg 6b1ba37438 doc: bump required versions of libuEv and libite
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-26 10:57:30 +01:00
Joachim Wiberg a579e0e8ae travis-ci: bump libuEv and libite versions, for systemf()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-26 10:57:30 +01:00
Joachim Wiberg 8077169ea9 Merge pull request #157 from troglobit/usr/kandeg/initctl-edit
initctl: add edit command, fix #154 

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-26 10:54:00 +01:00
Andreas Egeberg bf2272c6b3 Beautify code 2021-02-26 10:51:30 +01:00
Andreas Egeberg 60d0ca1075 Added Edit command
Command Edit <CONF>  opens file /etc/finit.d/available/<CONF>.conf in
the editor referenced by Linux environment variable $EDITOR
If $EDITOR is not set it will try to open emacs and if emacs is not
found it will try to open the file in vim.

Signed-off-by: Andreas Egeberg <andreas.egeberg@gmail.com>
2021-02-26 10:28:21 +01:00
Joachim Wiberg e3b27d47bc Follow-up to dfd41a1: fix default finit.conf path regression
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-26 09:52:42 +01:00
Joachim Wiberg 6b7255fdeb Fix regression introduced in 7ef25ab, global rlimits not initialized
Services that are instantiated by plugins, and thus don't have a .conf
file, tried to use uninitialized rlimits.  This caused the kernel to
immediately kill those services for violating their own rlimits.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-26 09:11:56 +01:00
Joachim Wiberg 80e4f025d3 flog: new helper function for debugging to file
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-26 09:09:34 +01:00
Joachim Wiberg 45a374b50a configure: allow custom directory for --with-sysconfig
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 18:28:11 +01:00
Joachim Wiberg ea9f88b9fb contrib: alpine: update to use env: files for service arguments
- Check for env in /etc/conf.d on Alpine
- Update all services with their respective env: file
- Disable default modules, noew modprobe plugin should handle this
- Add watchdog service
- Rename syslogd -> syslog, in case we want to integrate sysklogd

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 18:16:53 +01:00
Joachim Wiberg da2dde879e contrib: debian: update to use env: files for service arguments
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 18:16:53 +01:00
Joachim Wiberg 064d124e19 Refactor, add new helper fn paste() to concat directory compoents
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 17:41:39 +01:00
Joachim Wiberg f8a989439b Minor, insert '/' only if pasting components require it
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 17:18:44 +01:00
Joachim Wiberg dfd41a1b37 configure: minor refactor, simplify to reduce duplication
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 17:17:30 +01:00
Joachim Wiberg 74d3194775 Follow-up to f4a0b99: track modifications of service env: files
Add support for monitoring environment files for services declared with
the `env:[-]/path/to/file` option.  The default path to such files has
been chosen to follow Debian and Buildroot /etc/default/*

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 17:14:26 +01:00
Joachim Wiberg 7ef25abecf Refactor, use new iwatch module for inotify of Finit *.conf files
- Use iwatch, modeled after pidfile plugin
- Use one .conf watcher for all *.conf paths/files
- Use full path of conf file for changes, from realpath().
  This fixes a long-standing limitation on unique filenames
  for services, that absolutely nobody knew about

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 14:28:03 +01:00
Joachim Wiberg ea278a6370 plugins: pidfile: simplify, use constructs from src/conf.c
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 14:27:28 +01:00
Joachim Wiberg 8790fcabf3 iwatch: minor, check if file/dir exists before trying to add
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 14:27:01 +01:00
Joachim Wiberg 3d9ee49759 Follow-up to 6cdcacf, fix minor regression, premature clear of pid
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 14:23:45 +01:00
Joachim Wiberg cafbb18626 plugins: hotplug: log output from udevd/systemd-udevd to syslog
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 00:27:29 +01:00
Joachim Wiberg 939c6f2f67 Fix regression in displaying progress at runtime
We don't want to show progress (starting/stopping/restaring) at
runtime, since Finit v3.  Many systems hooked up to a console
get confused by sudden output, or even ansi escape sequences.

This patch drops code added recently which caused a regression
in this policy.  The resulting code is even more readable.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 00:22:01 +01:00
Joachim Wiberg 477b50b7a6 Check return value from kill(pid, SIGHUP), maybe lost pid
This patch handles a corner case when Finit may not have detected a
supervised process has died.  When a user calls `initctl restart foo`
we now send such lost PIDs to the service_monitor() for restart.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 23:58:25 +01:00
Joachim Wiberg 6cdcacf20b Refactor, shared cleanup fn for service_kill() and service_monitor()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 23:45:14 +01:00
Joachim Wiberg d37c20f467 Terminate children in the same process group when monitored PID dies
Really kill them, our monitored process may be about to restart, so we
don't want any unintended side effects from lingering children in prior
instances.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 23:43:03 +01:00
Joachim Wiberg 14f0443bd7 Allow services to be added *and removed* from /etc/finit.conf
This patch fixes a long standing issue where removing a service from
/etc/finit.conf does not stop and unregister it.  The issue was caused
by the Finit support for "protected" services, e.g. services created
by plugins like hotplug.so

To reproduce issue before this fix:

    cat /etc/finit.d/available/ntpd.conf >> /etc/finit.conf
    initctl reload

The NTP service now runs smoothly, as expected.  Later on, we decide to
drop it from our system:

    sed -i 1,2d /etc/finit.conf
    initctl reload

... and the NTP service continues to run unaffected.  Not what most sane
users expect.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 22:12:05 +01:00
Joachim Wiberg 81d8f3cccc Drop unnecessary service_step() in cond_reload()
The cond_reload() fn is called on `initctl reload`, thus we don't need
to call service_step(), since we call service_step_all() later in that
cycle.  So we can drop cond_update(NULL), which calls service_step().

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 22:12:05 +01:00
Joachim Wiberg d27b3948af Drop unnecessary and confusing debug message in mkcond()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 22:12:05 +01:00
Joachim Wiberg f906bb357a plugins: pidfile: only scan directory if watch added successfully
Also, update condition example in comment.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 22:12:05 +01:00
Joachim Wiberg e0d3aa8e06 iwatch: handle watching paths for same inode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 22:12:05 +01:00
Joachim Wiberg 84248e1c56 Merge pull request #156 from troglobit/fix-hard-coded-rcsd
Use FINIT_RCSD instead of hard coded value
2021-02-24 21:09:12 +01:00
Jacques de Laval 51fe974ee5 Use FINIT_RCSD instead of hard coded value
Signed-off-by: Jacques de Laval <jacques@de-laval.se>
2021-02-24 18:58:05 +01:00
Joachim Wiberg bc4d4b7f35 plugins: pidfile: set up I/O callback on successful iwatch_init()
In case of trouble, make sure we don't have a callback set up w/o
a valid file descriptor.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 09:52:34 +01:00
Joachim Wiberg e067f23ef2 iwatch: add license+copyright header and initialized guard
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-24 09:49:39 +01:00
Joachim Wiberg dd6ebc3b65 Drop svc pidfile matching, only match against PID in pidfile
With the redesign from <svc/path/to/pidfile> to <pid/name:id> in d1fac6f
we moved to matching svc_t only against their PID, which could pop up in
any *.pid or */pid in /var/run.  This patch drops the (hopefully) last
remnants of the old <svc/> legacy.

To ensure we don't try reading the PID value from socket files, like
/var/run/initctl, we add simple fnmatch() of the inotified file.  Two
calls to fnmatch(), for portability reasons, not every system has GNU
libc extensions like FNM_EXTMATCH.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-23 20:26:57 +01:00
Joachim Wiberg 8dc1ad00d5 plugins: refactor, break out inotify watcher to src/iwatch.[ch]
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-23 20:26:38 +01:00
Joachim Wiberg 8381976f05 plugins: boilerplate for made-easy integration with FRR
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-23 15:03:03 +01:00
Joachim Wiberg c0bbb0fc51 plugins: pidfile: rename variables and local fns
- new namespace before breaking out to shared object
- use inotify naming fd -> wd

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-23 09:04:53 +01:00
Joachim Wiberg f4a0b99df8 Fix #155: add support for env:/a/bc to service/run/task
This patch makes it possible to create a service with optional
arguments, similar to the systemd EnvironmentFile= setting.

The major difference to systemd, is that Finit does not attempt
to start a service if it cannot find the env. file, unless it
is prefixed with '-'.

Example:

    /etc/default/syslogd:
    SYSLOGD_OPTS="-m0 -r 128k:10 -s"

    /etc/finit.d/enabled/syslogd.conf
    service env:-/etc/default/syslogd syslogd -F $SYSLOGD_OPTS

Only downside, right now, is that changing the contents of the file
/etc/default/syslogd does not mark the syslogd.conf as modified and
a subsequent `initctl reload` will *not* restart syslogd.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-22 16:18:22 +01:00
Joachim Wiberg fc82f0242c doc: another reformat of cmdline tips
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 22:57:21 +01:00
Joachim Wiberg 8c7a3bc476 contrib: add sysklogd to available services on debian
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 17:12:10 +01:00
Joachim Wiberg 7e42203627 Fix #147: refactor reboot as multi-call to initctl
This patch drops the stand-alone reboot binary and folds it into the
initctl tool, which now becomes a multi-call binary.

With this change the reboot/shutdown/poweroff/halt/suspend commands also
no longer default to sending signals to PID 1, instead it now uses the
initctl <--> finit UNIX domain socket API.  Signals are only used as a
fallback in case of non-working domain socket.  The -f,--force mode of
operation still works, where `reboot(2)` is called directly.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 10:59:08 +01:00
Joachim Wiberg 649a269526 Add reboot/halt/poweroff/suspend commands to Finit API
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 10:49:13 +01:00
Joachim Wiberg e80edbb401 If Finit API call fails (NACK), return non-zero to client
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 10:47:48 +01:00
Joachim Wiberg 1cb37a3ee7 plugins: update conditions for udevd and udevadm commands
On systems with udevd, or systemd-udevd, we must wait for udevd to start
before calling udevadm.  This patch updates service and runtask stanzas
to the new condition system naming and adds 'log' to the udevadm cmds.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 01:12:26 +01:00
Joachim Wiberg 27a4c8cd9a Follow-up to 70ca64a, handle missing bool argument to cmdnline opts
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 01:06:02 +01:00
Joachim Wiberg 97a0baaf93 Fix regression introduced in 13893b9
The refactor in 13893b9 caused a regression in composing service
arguments.  This patch should rectify that.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 00:57:21 +01:00
Joachim Wiberg 7b561044a9 doc: slight refactor of signals document 2021-02-21 00:57:12 +01:00
Joachim Wiberg 346320f669 doc: update text on conditions to reflect new world 2021-02-21 00:57:12 +01:00
Joachim Wiberg e941a510c1 doc: document new cmdline options
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 00:57:03 +01:00
Joachim Wiberg dda59503ac Refactor, drop #ifdefs and logger fallback, probe for logit
Simplify log redirection, probe for logit early and fall back to
use a while-loop of syslog() instead.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 13:00:58 +01:00