Commit Graph
639 Commits
Author SHA1 Message Date
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 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 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 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
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
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 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 e9a89248ec Minor refactor
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 04:31:51 +01:00
Joachim Wiberg 46bb09c331 Fix #145: default to power-off system, fix -h for shutdown command
- Default to power-off the system, even for shutdown command
- Fix -h switch for SysV init shutdown command compatibility
- Add -P switch for systemd shutdown command compatibility

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 04:20:42 +01:00
Joachim Wiberg 89a57054f5 initctl: drop utmp/wtmp functionality on systems w/o it (musl)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 04:18:34 +01:00
Joachim Wiberg c1e4c24136 Skip UTMP/WTMP update on systems w/o support for it (musl)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 04:17:39 +01:00
Joachim Wiberg d9b705ab98 Runtime detection of working UTMP/WTMP support in system
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 04:17:15 +01:00
Joachim Wiberg 87f6769c51 Revert "Workaround for _PATH_UTMP and _PATH_WTMP defines on musl libc"
This reverts commit 8a71f2d323 because
if no other application has a working utmp then there's no poit for
Finit to have one.  Instead we'll be disabling all utmp support when
running on a musl based system.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 03:59:52 +01:00
Joachim Wiberg 8a71f2d323 Workaround for _PATH_UTMP and _PATH_WTMP defines on musl libc
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 03:52:56 +01:00
Joachim Wiberg 5fbcf6814c Warn if a new service asserts the same condition as an existing one
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-13 12:07:20 +01:00
Joachim Wiberg b175b4a2ae initctl: add PID and IDENT to 'cond dump' command
Instead of just walking /run/finit/cond, also show the source of each
condition.  The hook and net conditions are hard-coded to init[1] atm.
and unknown conditions are shown as unknown[0].

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-13 12:07:20 +01:00
Joachim Wiberg 3aeb150eef initctl: minor refactor and set min column width
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-13 12:07:20 +01:00
Jacques de Laval 0557c83d40 Fix #127: communicate run-parts progress/status
Printing the progress of run-parts script just like for `rc.local`
seems reasonable. Also log a warning if any script exits abnormally.

Signed-off-by: Jacques de Laval <jacques@de-laval.se>
2021-02-12 16:33:18 +01:00
Joachim Wiberg 27bd9423bc initctl: add job number to "show foo"
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 22:32:37 +01:00
Joachim Wiberg 72a0ba6a55 initctl: primarily check for /var/log/syslog, fallback to messages
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 22:32:12 +01:00
Joachim Wiberg 56eb2c6b21 initctl: slight adjustment to whitespace between columns
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 22:31:35 +01:00
Joachim Wiberg 02d7c6747b initctl: minor refactor, keep related functions together
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 22:17:54 +01:00
Joachim Wiberg 10d4964106 Remove last traces of inetd support
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 21:50:17 +01:00
Jacques de Laval cb64c068e3 Fix #136: drop old init client tool
The SysV API compatibility layer gives too little value to be worth
the effort of maintaining it. Users are encouraged to use the
`initctl` tool instead.

Signed-off-by: Jacques de Laval <jacques@de-laval.se>
2021-02-11 17:52:08 +01:00
Joachim Wiberg eb6ac5ee22 Fix service state transition regression introduced in e88a9b1
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 17:01:08 +01:00
Joachim Wiberg e8561b7f90 initctl: add '-n, --numeric' mode to prefer JOB:ID over NAME:ID
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 16:16:43 +01:00
Joachim Wiberg 815454c065 initctl: fix missing '--no-heading' longopt in getopt()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 16:16:07 +01:00
Joachim Wiberg d1afc705ab initctl: refactor, reduce code duplication
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 16:14:28 +01:00
Joachim Wiberg ab8e813c7a initctl: name:id also for conditions and adjust column widths
Slight reshuffle of columns so status and condition listings are more
similar.  Also, calculate and adjust necessary column widths.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 15:37:43 +01:00
Joachim Wiberg 99d22a7c21 initctl: add '-t' switch to hide table headings
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 14:11:47 +01:00
Joachim Wiberg a226c93539 initctl: change layout to put (name,id) tuple in focus
With the recent change in the condition handling we've decided to put
the (name,id) tuple in focus for everything Finit.

This patch changes from job:id in the status listing to name:id instead.
In verbose mode we change to show the job:id and the command + args.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 14:07:43 +01:00
Joachim Wiberg e88a9b14ff Fix #101: remove built-in inetd from finit
This patch removes the built-in inetd support from Finit.  We recommend
using an external inetd instead, e.g. xinetd.

If you liked the feature set our inetd provided; filtering per interface
and port redirection, then please let us know or use the code in this
patch (MIT licensed) to recreate it.  We are open to reintroducing it,
but then as a stand-alone daemon like the bundled watchdogd and getty.

So long for now, old friend.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 12:46:40 +01:00
Joachim Wiberg d1fac6f5b3 Fix #143: redesign condition subsystem
Change service conditions from the non-obvious <svc/path/to/foo> to
<pid/foo:id>, utilizing the unique name of the service instead of the
weird composition of paths from /run and PID file names.  Hopefully
making it more clear that one service's pidfile is another service's
`<pid/foo>` condition.

Note: this is an incompatible change to the condition system!
      The Finit major version will be stepped to indicate this.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 07:58:06 +01:00
Joachim Wiberg 3e9c170e6b Refactor syslog output from ca210f5 to new canonical format
From, e.g.,

	Starting foo:, PID: 123
to
	Starting foo[123]

or, when an ID has been given

	Starting foo:id[123]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 07:55:25 +01:00
Joachim Wiberg 59d5601f8f svc_ident(): new function, returns service's unique identifier
A service is identifier using the (name,id) tuple on the form 'name:id'

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 07:53:51 +01:00
Joachim Wiberg 1fb78742c7 Fix gcc warning, prevlevel may be used uninitialized
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-10 11:56:16 +01:00
Joachim Wiberg e147cf7a8c Relocate IPC socket file from /run/finit.sock -> /run/finit/socket
We have our own subdirectory alread in /run, for conditions, and the FHS
recommends services maintain their own subdirectory if they have >1 file
for runtime storage.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 22:07:03 +01:00