Commit Graph
2957 Commits
Author SHA1 Message Date
Joachim Wiberg 7d831170ae plugins: close/exit iwatch *after* event loop has been detached
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-14 08:33:24 +02:00
Joachim Wiberg 6a21ac55ad Enable more printf format attributes
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-14 08:32:18 +02:00
Joachim Wiberg a0820c7f20 Fix printf format specifier and formatting issues in use of log fns
Almost all related to and (less likely) possible causes of issue #236.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-14 00:26:14 +02:00
Joachim Wiberg 6d58c9ed0b Enable printf format attributes to logit() and flog()
We don't want repeats of issue #236, so let's start by tracking down any
bugs hidden in logging functions.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-14 00:17:15 +02:00
Joachim Wiberg bc2ffbc767 Fix printf style function missing argument to %s
This is very likely the root cause of issue #236, let's see.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-14 00:10:30 +02:00
Joachim Wiberg 4c1fc2410e Show progress output also for unmount
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 22:41:12 +02:00
Joachim Wiberg 70e1aa889a Ignore errors from the first two remount,ro they are just decoys
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 22:28:10 +02:00
Joachim Wiberg c8c5e4e88a Revert "Simplify shutdown, no need for workarounds to remount / read-only"
This reverts commit 7c42986800 since we
seem to still need this werid thing on some systems.  The key seems
to use 'any' device at remount[1].  Anyway, the key issue before was
the noisy output, but like Debian we'll just redirect to /dev/null.

[1]: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/29187

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 22:22:18 +02:00
Joachim Wiberg 86c1398778 Run swapoff interactively, let user know what's happening.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 22:21:52 +02:00
Joachim Wiberg b37fa2b417 Silence process killer at shutdown, too noisy on regular systems
On regular desktop systems, like Debian, the dbus-daemon forks off a
dbus-launch process to start up things like your desktop for you.  This
process is not known to Finit and lingers in the background since it's
been reparented to init, and to top things off it seems to ignore any
SIGTERMs send to it.

Obviously this makes a shutdown on such systems very noisy, so this
patch changes the print() to a _d() so anyone debugging a system can see
it with `-- finit.debug` on the kernel command line, or `initctl debug`.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 22:16:57 +02:00
Joachim Wiberg a91e197553 Avoid looping forever trying to unmount busy tmpfs
This split unmount is a bit crude, unfortunately.  A user may have set
up a bind or overlayfs mount on top of a tmpfs -- so unmounting tmpfs
first will then always result in EBUSY.

Avoid logging busy errors and fake OK.  We'll catch it later in the
second stage unmount.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 21:57:14 +02:00
Joachim Wiberg 5adb92ca1b Catch and print any errors when unmounting filesystems at reboot
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 21:45:37 +02:00
Joachim Wiberg cfc99c4e8b Follow-up to ef9e9ec, run ifdown also in background, with --force
Turns out that on Debian `ifdown -a` can block for quite a while at
shutdown/reboot.  So we'd like to use the --force option.  However,
the BusyBox ifdown tool doesn't support --force, only -f, which in
turn the regular ifdown tool doesn't support.

Regardless, we can allow network shutdown to run in the background
like bring-up, at reboot we want to reboot quickly and don't care
so much, and on runlevel change to single-user mode we can allow
for some lagging behind in the background.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 21:45:37 +02:00
Joachim Wiberg 3e51ed1c55 Run swapon interactively, let user know what's happening.
Let's try this, should be OK for all types of systems.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 21:45:37 +02:00
Joachim Wiberg b5df0a6274 Fix swapoff at shutdown, does not support -e flag
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 21:33:54 +02:00
Joachim Wiberg cbe8d56042 Mention lack of mainline distro testing on non-x86 archs
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 08:35:13 +02:00
Joachim Wiberg a3ec792b44 doc: minor updates to build script, again
- Mention why configure script is missing from GIT
  - Adjust command line for enabling Finit debug
  - Plus some minor formatting issues

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-12 08:33:50 +02:00
Joachim Wiberg c24855d4d5 keventd: add support for toggling debug messages w/ SIGUSR1
Useful to debug system events after the system has started up and you
don't want to rebuild Finit to add the `-d` command line flag.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-11 22:38:35 +02:00
Joachim Wiberg 014e457fda doc: note which plugins are enabled by default
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-11 21:35:16 +02:00
Joachim Wiberg 21d89c7e24 doc: mention kernel command line option loglevel=7
This is needed since 5ff27c4f when support for debugging Finit and the
kernel independently was added.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-11 21:32:28 +02:00
Joachim Wiberg 639fb76f5a doc: update build ref, add "or later" to required libraries
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-11 21:14:35 +02:00
Joachim Wiberg 30c189b116 initctl: add helpful hint when showing/editing built-in services
Built-in services, like keventd, do not have a .conf file to edit.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-11 20:51:46 +02:00
Joachim Wiberg e2a8803f7a test: minor, extend log message a bit
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-10 22:46:45 +02:00
Joachim Wiberg 209e140ddd test: let Finit's bootmisc plugin create the /var/run symlink
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-10 22:46:15 +02:00
Joachim Wiberg 2e3fa72924 Revert "plugins: bootmisc: use relative symlink for /var/run"
This reverts commit f0e328edc9.
2022-04-10 22:38:27 +02:00
Joachim Wiberg 1502838a0d Fix regression in _pe() log macro, introduced in 685f332
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-10 12:39:20 +02:00
Joachim Wiberg 377c8bce8c test: fix dist and tenv-root/ regression from refactor
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-09 17:52:48 +02:00
Joachim Wiberg a39d958d25 Follow-up to 7dc7f9a, protect against stalling on non-existing pids
A forking service, e.g. a SysV init script, that returns is no longer
running, even though the monitored service may still be starting.  We
must mark the svc->pid as terminated until we know more -- otherwise
we may stall on a shutdown at that exact point.

Also, when shutting down, and stopping all services, ensure we do not
start the carousel for non-existing PIDs.  This might also cause our
stalling at shutdown.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-08 07:27:42 +02:00
Joachim Wiberg 7f8a96a73e test: refactor test framework to use a rootfs skeleton
Instead of having to create files, and copying them in place for each
test, we move all static test files to a skeleton rootfs.  This makes
it a lot easier to get an overview of how things and how they work.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-08 07:22:33 +02:00
Joachim Wiberg 5c2577214d test: ask BusyBox its tools and recommended paths
Note: we need to add /usr/bin and /usr/sbin to the standard PATH
      for tests and the test environment itself.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-06 22:42:49 +02:00
Joachim Wiberg f03206a694 .github: due to regression in ubuntu-latest, use older ubuntu runner
In https://github.com/actions/virtual-environments/commit/12fa229 the
ubuntu-latest runner was updated to Ubuntu 20.04.4, with Linux kernel
version: 5.13.0-1014-azure.  This broke the Finit tests completely
and the only possible solution, for now, seems to be reverting back
to the ubuntu-18.04 runner instead.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-06 21:16:46 +02:00
Joachim Wiberg f0e328edc9 plugins: bootmisc: use relative symlink for /var/run
In an upside world, much like the Finit test cases, the root may be
relocated.  This make /var/run relative to /var, instead of /.  Which
hopefully is safer and covers more use-cases.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-06 21:13:43 +02:00
Joachim Wiberg 13342f2bd9 .github: debug failing tests again, see what setup-root does
All tests except the first two now suddenly started failing.  Might be
the new caching support for the busybox binary, but that works on other
clean clones -- working theory now is that there's something subtle
with the setup-root.sh test -- which PASSes ...

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-04 19:43:43 +02:00
Joachim Wiberg c926160853 Issue #223: add type:forking service option, with updated docs
- Add `type:forking` service option to trigger guessing pidfile to
   watch for, instead of `pid:!foo` option, which is not intuitive.
   This option may likely also survive into the new file format :)
 - Update docs and add examples
 - Update start-stop-serv.sh test case with this new variant

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-04 19:13:28 +02:00
Joachim Wiberg 462d5b22b4 Fix parse bug, always set service's respawn flag
Before this fix, a service declared with respawn could not be changed at
runtime to remove the respawn flag.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-04 18:06:35 +02:00
Joachim Wiberg b1bfab08f3 Coding style, reverse Christmas tree ordering
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-04 08:26:13 +02:00
Joachim Wiberg aeb48ef04b test: add support for caching busybox-x86_64 binary in ~/.cache
While without a working Internet connection today I ran into the issue
of not being able to run the tests.  This adds a basic caching mechanism
to setup-root.sh which saves busybox-x86_64 in ~/.cache, if available.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-04 08:20:48 +02:00
Joachim Wiberg b8b200ad75 doc: move state machine to inside its section
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-03 12:13:42 +02:00
Joachim Wiberg c148d8d783 doc: document supported types of forking/non-forking daemon's
Issue #223

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-03 12:03:21 +02:00
Joachim Wiberg 27ba3b27f5 test: extend start-stop-serv test w/ all supported combinations
serv: add support for foregrounding, running with and without PID file,
      including custom PID filename.

test: verify Finit can start & monitor services that:
      1) Fork and creates a PID file in a known location
      2) Don't fork and don't create a PID file, but Finit does
      3) Don't fork but create a PID file
      4) Don't fork and create custom named PID file

Note: Finit cannot support a service that forks and doesn't create a PID
      file.  This combination is impossible to support without tracking
      all processes created in /proc -- which Finit does not do atm.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-03 11:56:42 +02:00
Joachim Wiberg b4af86255d test: rename fserv -> serv, more features to be added
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-03 11:55:11 +02:00
Joachim Wiberg 01a007b388 .github: detect Finit version and figure out build dir on failure
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-02 12:38:44 +02:00
Joachim Wiberg 0e28741dcb test: fserv is built in another directory
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-02 12:38:20 +02:00
Joachim Wiberg c993feeb44 .github: dump start-stop-fserv.log on make check error
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-02 12:21:01 +02:00
Joachim Wiberg ec17f0aa23 test: add new test to dist, fixes CI build
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-02 12:14:32 +02:00
Joachim Wiberg 6baf2990e8 test: new test to verify support for forking services
Issue #223

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-02 12:08:10 +02:00
Joachim Wiberg 6416e2a1a4 test: minor refactor in build system
Add Makefile.am in tenv and common for EXTRA_DIST.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-02 12:07:34 +02:00
Joachim Wiberg 7c42986800 Simplify shutdown, no need for workarounds to remount / read-only
Calling sync is not needed, remount does this for us.

Remount with 'dummydev' causes warnings and is not needed.  It appears
sysvinit used this to try and fix a sparc related bug.  Instead, use the
rootfs keyword to ensure we don't accidentally remount a bind mounted /.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-02 11:09:29 +02:00
Joachim Wiberg 6f802a7ff1 test: whitespace changes only
Coding style for shell scripts:

  - Tabs for indent (change in Emacs needed)
  - Braces on their own line, like C functions

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-02 10:45:30 +02:00
Joachim Wiberg 879721839e test: slight formatting change in log() output
Encase (stripped) test name in [] and use decreased intensity ANSI coloring.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-02 10:26:07 +02:00