Commit Graph
2072 Commits
Author SHA1 Message Date
Joachim Wiberg ed0e65e5bb contrib: alpine: enable acpid, crond, ntpd by default
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 20:11:33 +01:00
Joachim Wiberg a43f54f960 Merge pull request #144 from troglobit/drop-old-init-client
Fix #136: drop old init client tool

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 19:10:21 +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 673a9a55a2 Updates for upcoming v4 release, including planned release date
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 11:12:29 +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 46c028f58c contrib: drop local symlinks, created by Makefile on install
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-10 13:50:52 +01:00
Joachim Wiberg 5105ff91d9 contrib: install .conf files from installed (fixed) services
This fixes the problem with lingering Makefile's in /etc/finit.d/ on the
target systems.  We also get the new enabled services properly set up.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-10 13:46:32 +01:00
Joachim Wiberg 91750fd1da contrib: use "new" enabled/ directory for pre-enabled services
The initctl tool's enable/disable command can then be used to manage
these services after install.  This is what most users expect.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-10 13:45:06 +01:00
Joachim Wiberg 4ca5204acb contrib: drop absolute paths => simpler conditions
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-10 13:26:08 +01:00
Joachim Wiberg 43d73e3c01 plugins: Use len field from inotify_event to calc dest buffer
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-10 12:14:51 +01:00
Joachim Wiberg f6b6ed211c Fix gcc warning, too small destination buffer may be truncated
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-10 11:56:34 +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 c93e9a30cd Scrap v3.2 release cycle and move to v4.0 directly
Planned changes will directly change the behavior of conditions, and
instead of having to implement compatibility wrappers and further
complicate the code, we've taken the decision to go for v4 directly.
This allows us to also rip out the complex inetd support.

Other changes in this commit:

- Revert back to .tar.gz distribution archives, by popular demand
- Add .sha256 checksum for .tar.gz archive

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-10 11:47:26 +01:00
Joachim Wiberg 4b54ae46ea Update changelog, so many changes and fixes ...
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 22:31:36 +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
Joachim Wiberg 36de18ec55 Clarify PID conditions and non-standard PID file locations a bit
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 22:07:03 +01:00
Joachim Wiberg a5714a058c Update copyright years
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 22:07:03 +01:00
Joachim Wiberg a8b113185d Major change, rename <svc/...> conditions to <pid/...> conditions
The <svc/foo> condition was created to synchronize starting services,
hence the abbreviation.  Example: the Quagga ripd needs to start after
the zebra daemon to ensure its UNIX domain socket is active, otherwise
events may be lost.

However, considering that synchronization was implemented with UNIX PID
files, e.g. waiting for /var/run/quagga/zebra.pid to be created, the
condition abbreviation name <svc/foo> was hard to understand by most
newcomers to Finit.  To make matters worse, a new feature to track or
even create PID files for services that don't create one themselves,
using the syntax 'pid:/path/to/foo.pid' was added.

Connecting the dots between these wasn't obvious.

This patch renames service conditions pid conditions and also adds
a compatibility wrapper to the Finit .conf parser.  Any condition
given in old .conf files with 'svc/' prefix are internally renamed
'pid/', along with a LOG_INFO notice in syslog.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 22:07:03 +01:00
Joachim Wiberg ff41868b59 Reorder, call conf_init() *after* all cond_init()
This to ensure that services, and conditions they may create, actually
are recorded in the condition subsystem.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 15:27:29 +01:00
Joachim Wiberg d068684154 plugins: fix possible ordering bug; pidfile --> bootmisc
The recently updated pidfile plugin now also watches the subdirectories
in /var/run, but for that to work it must witness the creation of these
subdirectories.  The bootmisc plugin creates several, e.g., /run/quagga/
in which PID files like zebra.pid are created.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 15:25:35 +01:00
Joachim Wiberg 4a83c95d2b contrib: simplify example service stanzas; skip path, reduce conds
- Absolut paths are only necessary in case of ambiguities
- Without absulute paths conditions are shorter, e.g. <svc/syslogd>
- Drop <net/lo/up> condition for SSH daemons, not necessary

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 15:07:09 +01:00
Joachim Wiberg 5d7ce3a92b configure: drop remaining --with-console, auto-probed now
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-08 20:20:08 +01:00
Joachim Wiberg 82664396d6 Refactor 3e8d63c: use consoles from /sys/class/tty/console/active
As documented in the kernel docs and systemd[1], the default system
console is the first listed in /sys/class/tty/console/active, which
is the reverse order of console= given on the kernel cmdline.

Some distros don't have console= on their default command line in
their bootloader, e.g. Alpine Linux, some multiple, e.g Buildroot.
Instead of relying on the value given at configure time we probe
sysfs and open all (at most three) consoles listed.  This way we
at least get the default console for our progress output.

- drop old --with-console from configure script
- drop /proc/cmdline fishing in favor of sysfs
- replace CONSOLE from configure with new console()

[1]: http://0pointer.de/blog/projects/serial-console.html

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-08 20:09:49 +01:00
Joachim Wiberg 3fb700c17d Deprecation warning: inetd removal, update TODO accordingly
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-08 17:39:13 +01:00
Joachim Wiberg 1a5aabc034 Update configure examples and build scripts with correct paths
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-08 17:27:05 +01:00
Joachim Wiberg aa4addfa86 configure: drop note at bottom, we use std gnu defaults now
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-08 09:28:36 +01:00
Joachim Wiberg 06fdcf51b9 configure: revert to using GNU defaults, update summary
- Changing the GNU defaults is messy.  The best way is to leave them
  alone and let the user set their install locations themselves.
- Show --exec-prefix in config Summary, that's where the binaries go

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-08 07:58:25 +01:00
Joachim Wiberg 7d6eb2b59b initctl: use same headings for ls as show
From the start, the output from the 'list' command has been different
from the output of the 'show' command.  No longer.

Also, drop the 'AVAILABLE', 'ENABLED', and 'STATIC' prefixes.  They were
a bit screamy and superfluous.  'STATIC' wasn't even a good name for the
locally administered ones.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-08 07:29:05 +01:00
Joachim Wiberg 5c2ba8ef3a Adapt ifupdown support to new world, run 'ifup -a' in the background
All Debian based distros are moving towards a /etc/network/interfaces.d/
world.  Adding support for that is too complex, so we're reverting back
to calling 'ifup -a' or 'ifdown -a'.  We still guard this by checking
both for 'ifup' and the existence of /etc/network/interfaces (which in
the new world only contains a line to source per-interface files).

By popular demand, this patch also changes to bring up/down networking
in the background.  Useful for embedded system bringup and containers.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-07 14:54:53 +01:00
Joachim Wiberg fccba7cd4c Replace %m GNUism with strerror(errno)
Even musl libc supports %m today, as well as most syslog daemons, but
that's no excuse to use this.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-07 13:21:55 +01:00
Joachim Wiberg 3e8d63c29c Support for multiple (3) console= on kernel cmdline
Some targets, like Raspberry Pi, have both serial and HDMI console
enabled.  Depending on the order of arguments on the kernel cmdline
either one were selected the default 'stderr', which finit used.

This patch adds support for parsing the console= string(s) and
opening multiple outputs for system startup/progress.  In the
end, however, a getty still needs to be started on each of the
consoles to use.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-07 13:15:46 +01:00
Joachim Wiberg 18359ef448 Follow-up to 4febd28: bring back /dev, /proc, and /sys
We need /proc for rs_remount_root() and conf_parse_cmdline(), /dev for
early multi-console support, and /sys for the cgroups support.  All of
these may be in the system /etc/fstab, which fs_mount() later remounts.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-07 12:53:35 +01:00
Joachim Wiberg 0c85f8adfe initctl: add 'ls' alias for 'list'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-06 20:55:09 +01:00
Joachim Wiberg 84c6ab737e Silence kernel output on console when starting up
Many systems have a very verbose kernel by default.  This patch calls
`klogctl(SYSLOG_ACTION_CONSOLE_OFF, NULL, 0)`, which is sysklogd also
calls but later when it starts emptying /dev/kmsg.

We do this to get an undisturbed console while starting up.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-06 20:37:41 +01:00
Joachim Wiberg 9e73fda2ac Follow-up to 4febd28: remount / as rw requires /proc to be mounted
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-06 20:37:41 +01:00
Joachim Wiberg 254d7e0238 Merge pull request #142 from jackuess/sigpwr-handling
Follow-up to eeb59eb: handle SIGPWR like SIGUSR2

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-02 16:10:00 +01:00
Jacques de Laval 022f140b3a Handle SIGPWR like SIGUSR2
This seems to be inline with Busybox init, SysV init and, according
to the comments in code, the intended behaviour of Finit.

The effect is that `SIGPWR` will lead to Finit issuing the syscall `reboot`
with `cmd` parameter set to `RB_POWER_OFF` (rather than `RB_AUTOBOOT`), which
in turn will lead to a halt rather than a reboot.
The effect of the above inside a PID namespace other than the initial PID
namespace is that `wait` inside the parent of Finit will report that Finit was
killed with a `SIGINT` signal rather than `SIGHUP`.
2021-02-02 15:13:16 +01:00
Joachim Wiberg 378456b6bd Merge pull request #138 from wkz/boot-refactor
Bootstrap refactor
2020-10-20 19:21:15 +02:00
Tobias Waldekranz adcc78039e Bring back the hotplug-daemon-heuristic as a plugin
This way, the default behavior stays the same, but users can opt out
by disabling the plugin.
2020-10-20 14:57:10 +02:00
Tobias Waldekranz bdceeb83d5 Ensure that plugins are loaded before the first hook point
We want plugins to be able to register themselves at the banner hook
point, but that requires that we have actually loaded them before
then.
2020-10-20 09:48:33 +02:00