Commit Graph
3023 Commits
Author SHA1 Message Date
Joachim Wiberg e50fe3b060 plugins: use reentrant API getmntent_r()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-01 22:12:02 +02:00
Joachim Wiberg d6c55282ef Fix #253: use reentrant getmntent_r() API
When iterating over the system fstab file to call fsck, Finit calls the
helper function ismnt(), which opens /proc/mounts to make sure mounted
file systems are not fsck'ed.  Both the main function and ismnt() used
the same non-reentrant getmntent() API which caused ismnt() to set the
fstab pointer for the first out of whack.

This change replaces getmntent() in the two critical functions with the
getmntent_r() API instead.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-01 21:43:13 +02:00
Joachim Wiberg 1015124530 Use sys/sysmacros.h, if available, for minor() and major()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-01 20:50:17 +02:00
Joachim Wiberg 38885aaa67 Issue #253: handle fsck of magic /dev/root device
Some systems have /dev/root declared in their /etc/fastb as /.  This is
as special device node created by the kernel based on the root=, and a
few other variables.  This may be a symlink, and if so, and on a mdev
system, the symlink may point to the wrong device node ... so we must
try to figure out the major:minor from / and then traverse /sys/block
to find our root device.

Note: this commit also does a bit of refactoring for readability and
      also adds a few debug lines that may be dropped before release.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-01 19:31:51 +02:00
Joachim Wiberg a685b698c2 Follow-up to 5593372f, regression in remounting read-write at boot
A subtle regression was introduced in 5593372f, when moving to get
getmntent() family of APIs.  Finding the 'ro' flag (or not) in the
system fstab broke and Finit never tried to remount / read-write.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-01 19:28:50 +02:00
Joachim Wiberg 9bce8f9584 initctl: add cond get foo, supports -v option
Fix issue #255

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-30 10:28:47 +02:00
Joachim Wiberg d04b04d73a Follow-up to 7212543, fix args to svc_ident()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-30 10:20:53 +02:00
Joachim Wiberg 72125430e6 Fix #252: run/task success+failure conditions do not use :ID
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-30 08:50:14 +02:00
Joachim Wiberg 561387ce57 test: new test, verify pre:post: scripts with optional env:file
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-30 08:46:05 +02:00
Joachim Wiberg e2d1930e6c Fix #248: source env:file also in pre:post: scripts
This change basically add this for pre/post scripts:

    sh -ac '. /path/to/env; exec ./pre-post.sh'

Meaning the env file can be a simple foo=bar file, which Finit reads and
call setenv() on all variables, and the user do not need to call export
on all variables -- additionally, any functions defined in an env file
can be used by the pre-post scripts, but are ignored by Finit.  I.e.,
the service only gets the variables set, no functions.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-30 08:43:44 +02:00
Joachim Wiberg 6f2a124240 doc: update documentation for modules-load plugin
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-27 07:50:21 +02:00
Joachim Wiberg 10392e9639 plugins: modules-load: skip lines starting with '#'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-27 07:46:03 +02:00
Joachim Wiberg 605c489937 Follow-up to 57c97d8, issue #224: add swapon/swapoff fstab wrappers
The swapon and swapoff commands do not support a custom fstab, they
assume /etc/fstab is the only true source of swap devices and files.

This change adds rudimentary (!) support for figuring out any swap
device or file to use from any finit.fstab.  Please note, options are
not supported at the moment.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-26 22:57:22 +02:00
Joachim Wiberg 26409bc860 Follow-up to 57c97d8, issue #224: fsck needs FSTAB_FILE env. set
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-26 21:59:11 +02:00
Joachim Wiberg b01f9f38f2 Improve logging of forking services having started and stopped
Since a forking service, e.g. a sysv init script, will exit very early
we cannot log the same as for regular services "Starting foo[123]", so
instead we log "Started bar[321]" when we get the pidfile update and
the same when stopping a forking service, log "Stopped bar[321]" when
we collect the PID.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-26 20:58:57 +02:00
Joachim Wiberg 2ddbb805ca Improve logging of sysv start/stop scripts, include full command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-26 20:58:57 +02:00
Joachim Wiberg ed999d9a80 Fix log regression introduced in 82cc10be
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-26 20:58:57 +02:00
Joachim Wiberg 82cc10be88 Fix #246: conditions for running/halted services
This change adds the following service conditions, which can be used to
synchronize other stanzas:

  - service/foo/running
  - service/foo/halted
  - service/foo/missing
  - service/foo/crashed
  - service/foo/stopped
  - service/foo/busy
  - service/foo/restart

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-26 00:07:44 +02:00
Joachim Wiberg 30fb9780d7 initctl: slight improvement to status output for sysv services
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-26 00:07:44 +02:00
Joachim Wiberg 09f46f62b4 Support args to sysv-like scripts, e.g. bridge-stp br0 start
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-26 00:07:44 +02:00
Joachim Wiberg bc4e7a8d8d Revert "Fix starting and stopping of SysV init scripts"
This reverts commit c63279630b which
clearly was not needed to fix the problem.  After this revert the
test(s) still pass, but now we can also start bridge-stp, e.g.

     bridge-stp br0 start

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-25 23:38:52 +02:00
Joachim Wiberg e2753d75f8 plugins: silence netlink developer debug messages
Default debug level for the netlink plugin is just too noisy.  Let's
drop debug messages (mostly) intended for developers.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-25 23:35:02 +02:00
Joachim Wiberg addb8c4019 Fix #247: fall back to reboot -f in sulogin mode
When logged in from sulogin we cannot send IPC to Finit, not even
signals, to delegate reboot.  For usability, attempt to tell reboot that
it's in sulogin mode -- provided the bundled sulogin is used -- to let
reboot trigger over to forced reboot.

We cannot do much about initctl, just document this as a limitation.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-25 21:44:33 +02:00
Joachim Wiberg 0c4a9b62c2 initctl: allow client_connect() to return error
This lets any callers of client_connect() decide what to do wrt. error
recovery and fallback mechanisms.  E.g., reboot may want to check if
it's in sulogin mode, or fall back to sending signals to PID 1.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-25 21:44:33 +02:00
Joachim Wiberg 57c97d8190 Fix #224: support for cmdline -- finit.fstab=/etc/fstab.secondary
This adds support for bringing up the system with an alternate fstab at
boot.  E.g., when using a primary/secondary setup for boot partitions.

By default /etc/fstab is read, like before, this can now be changed
using configure --with-fstab=/path/to/fstab.primary, which sets the
default that can be overridden using finit.fstab=/etc/fstab.secondary

If mounting, or fsck, fails in any way, Finit calls its own bundled
sulogin, or the system sulogin(8), to let the user handle the issue.
If there is no sulogin available, Finit will try to start up in its
rescue.conf boot mode.

Please note, in either of these rescue modes, use `reboot -f` to get the
system to reboot.  Finit is on pause in the background in rescue mode
and cannot be relied on (since there may not be any writable filesystems
available.).

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-25 21:44:33 +02:00
Joachim Wiberg b0d0ca76cf Minor, coding style
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-25 21:37:59 +02:00
Joachim Wiberg 5240c0cf19 Follow-up to a91e197: allow umount fail on EBUSY, skip error message
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-25 18:52:16 +02:00
Joachim Wiberg a02f369a89 Minor, rename local variable
The iterator works on any fstab like file, but to keep confusion to a
minimum, rename local variable.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-25 18:51:17 +02:00
Joachim Wiberg fa2a113cbf test: fix path to Finit rcs.d in distcheck
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 15:22:35 +02:00
Joachim Wiberg 4c5ac38e2c test: attempt to use /etc/finit.conf instead, azure 5/N
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 14:42:49 +02:00
Joachim Wiberg f89ebb91a8 test: even more azure debug 4/N
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 14:39:03 +02:00
Joachim Wiberg 477bc064d5 test: more debug azure 3/N
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 14:28:57 +02:00
Joachim Wiberg 96376126b3 test: debug azure 2/N
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 14:21:58 +02:00
Joachim Wiberg 1c150928cb test: debug cond test in azure
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 14:14:35 +02:00
Joachim Wiberg 7a8d4e2c6b test: wait for Finit to reach runlevel 2 before starting tests
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 13:19:10 +02:00
Joachim Wiberg fb956fd2f5 test: silence Hint:, does not work anymore, need to debug it
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 13:18:41 +02:00
Joachim Wiberg e6e4d814f3 test: extend initial wait for azure env.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 12:55:37 +02:00
Joachim Wiberg 544d44886a test: let Finit start up properly before starting tests
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-24 11:36:30 +02:00
Joachim Wiberg cec2d5a4db test: add missing sbin/task.sh to skeleton dist.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-22 18:21:19 +02:00
Joachim Wiberg 539d215d0e test: add missing finit.d to skeleton rootfs
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-22 17:51:04 +02:00
Joachim Wiberg 10ef0e7de6 doc: document previously secret service option respawn
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-22 07:21:19 +02:00
Joachim Wiberg 05e6b3e752 test: new test, verify task behavior with conditions
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-21 20:52:34 +02:00
Joachim Wiberg 3e4be9a122 man: document command line options, complementing bootparam(7)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-20 07:51:58 +02:00
Joachim Wiberg 5593372ffb Refactor, replace deprecated setfsent() & C:o with setmntent()
The setfsent() family of APIs was never standardized and on Linux only
GLIBC implement them.  We've tried to overcome this limitation, and to
support uClibc/uClibc-ng and musl libc, by providing replacements APIs
in helpers.c.

However, and since we want to support alternative /etc/fstab files, the
setmntent() family of APIs is more widespread and supports reading from
any fstab or mtab file.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-20 07:20:33 +02:00
Joachim Wiberg 05be281301 Rely on (now working) fstab.h check in configure
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-19 20:04:03 +02:00
Joachim Wiberg 108bbf56dd Update copyright years
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-19 19:35:49 +02:00
Joachim Wiberg a61aa73419 configure: check for fstab.h, no fstaby.h
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-19 19:29:01 +02:00
Joachim Wiberg f39626f132 Minor, fix format string to systemf()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-17 14:25:32 +02:00
Joachim Wiberg c0b6f3af08 .github: build with latest libite version
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-17 14:22:09 +02:00
Joachim Wiberg 5d8fcfdf13 .github: allow release builds for -rcN
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
4.3-rc1
2022-04-17 12:06:10 +02:00