Commit Graph
2146 Commits
Author SHA1 Message Date
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
Joachim Wiberg 549aeda1fd Set process name of finit fallback shell, when active
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 13:00:22 +01:00
Joachim Wiberg 5903ebeb62 cgreaper.sh: update path to logit after relocation
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 13:00:22 +01:00
Magnus Malm 4d4fd40286 Follow-up to 72a892e, Add missing '/'
Signed-off-by: Magnus Malm <magnusmalm@gmail.com>
2021-02-17 11:46:39 +01:00
Joachim Wiberg 27aa7ad1e1 Follow-up to 72a892e, fix string concatenation
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 11:41:49 +01:00
Magnus Malm 72a892ef55 Fix #151: Install logit in libexec
Signed-off-by: Magnus Malm <magnusmalm@gmail.com>
2021-02-17 11:33:48 +01:00
Joachim Wiberg 4ff6f6a1f1 doc: minor, pid condition syntax has changed
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 11:32:47 +01:00
Joachim Wiberg 07da8aecac doc: some helpful pointers
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 11:32:13 +01:00
Joachim Wiberg 352ffb1582 doc: Major refactor, change layout
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 11:26:49 +01:00
Joachim Wiberg ad08f30b31 doc: Simplify and update with new cond format
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 11:06:46 +01:00
Joachim Wiberg 13893b9f32 Refactor, simplify command + args composition for readability
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 11:06:46 +01:00
Joachim Wiberg e5a53c175a initctl: fix too long cmd arglist with 'initctl -v show'
Only append args that have length, MAX number of args are many.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-17 11:06:46 +01:00
Joachim Wiberg 224fbedbf4 Merge pull request #153 from troglobit/logit-post-signal
Logit post SIGTERM, SIGINT etc.
2021-02-17 10:56:20 +01:00
Magnus Malm 97196d6520 contrib: alpine: Add finit builtin watchdog daemon
Signed-off-by: Magnus Malm <magnusmalm@gmail.com>
2021-02-17 10:34:10 +01:00
Jacques de Laval 06aea7d3f3 Keep logit alive until stdin is closed
By not putting logit in the same process group as the service whose
output is consumed by logit, we can send signals to the service,
and it's group, without affecting logit. This means that logit will
continue to log away until it's stdin is closed, which will happen
when the service is reaped.

Signed-off-by: Jacques de Laval <jacques@de-laval.se>
2021-02-17 00:00:50 +01:00
Jacques de Laval 703ae0caf3 Avoid lingering stdout fd logit process
Delay duplication of stdout/stderr until after forking a logit
process, otherwise we'd have a ligering reference to stdout/stderr.

Signed-off-by: Jacques de Laval <jacques@de-laval.se>
2021-02-17 00:00:37 +01:00
Magnus Malm 20c5788430 contrib: debian: Change sshd config to use absolute path
Signed-off-by: Magnus Malm <magnusmalm@gmail.com>
2021-02-15 13:53:22 +01:00
Joachim Wiberg d449329d3d Merge pull request #152 from troglobit/fix#139-set-system-timezone
Fix #139: System timezone changes does not 'take' in Finit
2021-02-15 13:43:16 +01:00
Andreas Egeberg 65f25756bf Fix #139: System timezone changes does not 'take' in Finit
The tzset() function sets the global variables 'daylight', 'timezone' and 'tzname'
according to the value of the TZ environment variable, or to the value of the
_CS_TIMEZONE configuration string if TZ isn't set, or to UTC0 if neither is set.

Signed-off-by: Andreas Egeberg <andreas.egeberg@gmail.com>
2021-02-15 12:38:20 +00:00
Joachim Wiberg 272db0d41d Use fallback to syslog if logit tool is not installed
In the case of redirect to a logfile, if logit tool is not enabled,
then log to syslog instead.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-15 08:00:24 +01:00
Joachim Wiberg 47d89ba2f6 contrib: Drop --enable-progress, enabled by default now
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 20:53:52 +01:00
Joachim Wiberg 6dd65d33ca Fix formatting of banner in classic style progress
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 20:14:18 +01:00
Joachim Wiberg 70ca64a392 New cmdline options to control debug and progress/status
Modeled after systemd.show_status, currently without the 'auto' setting.

- finit.debug[=bool]
- finit.show_status[=bool]
- finit.status_style[=old,classic,new,modern]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 20:11:45 +01:00
Joachim Wiberg 35e4e0d073 Drop confusing splash cmdline and --enable-progress configure option
This patch reverts back to the progress/status behavior of Finit < v3.0
because this is what most users expect, including the maintainer.  The
resulting code and configure script is a lot simpler to understand and
maintain:

- No more --enable-progress or --enable-progress-classic configure
  flags.  Instead a progress_style variable in helpers.c that can
  be changed at compile time for those that really need it.
- No more 'splash' kernel commnand line option.  This turned out to
  be *very* confusing to many users who believed it was some sort of
  graphical splash screen à la Plymouth.

Also, when Finit debug is enabled we now have a global 'debug' flag
which now alo controls if klogctl() should be called to prevent the
kernel logs to the console or not.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 20:11:08 +01:00
Joachim Wiberg 13a33d345b plugins: bootmisc: add missing include
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 14:18:08 +01:00
Joachim Wiberg e30e6ad6c9 plugins: bootmisc: skip UTMP/WTMP/BTMP on non-utmp systems (musl)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 04:35:26 +01:00