mirror of
https://github.com/troglobit/finit.git
synced 2026-10-13 10:14:47 +00:00
conf: read /run/finit/system before /lib/finit/system
Stanzas in /lib/finit/system cannot use if:keventd, or any other built-in service: if: is evaluated at parse time, and the generated .conf files for built-ins were read after the system directory, so the referenced service did not exist yet and the stanza was dropped. The late position was deliberate: it kept bundled services from starting before udev (5d703fd3). The motivating case was dbus, which has since moved to a build-time 20-dbus.conf (2e0b1d6f), and the built-ins that remain want the early slot: watchdogd should start as soon as possible, keventd is the device manager, and runparts is gated on int/bootstrap so its position never mattered. Reading /run/finit/system first also puts the override chain in its natural order: built-in/generated defaults, then bundled (read-only) system files in /lib, then the administrator (override) .conf file in /etc/finit.d, always read last. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
3 files changed
+41
-37
No files matched your search
@@ -8,6 +8,12 @@ All relevant changes are documented in this file.
|
||||
|
||||
### Changes
|
||||
|
||||
- The generated `/run/finit/system/*.conf` files for built-in services
|
||||
(keventd, watchdogd, runparts) are now read before
|
||||
`/lib/finit/system/*.conf` instead of after. Built-ins can now be
|
||||
referenced in `if:` statements from system .conf files and overridden
|
||||
by name from both `/lib/finit/system` and `/etc/finit.d`, the latter
|
||||
is still always read last
|
||||
- The `dbus.so` plugin, which starts an external `dbus-daemon`, is now
|
||||
enabled by default. It does nothing on systems without a
|
||||
`dbus-daemon` installed, and `--disable-dbus-plugin` opts out. The
|
||||
|
||||
+17
-14
@@ -26,7 +26,6 @@ the following layout is recommended:
|
||||
`- finit/
|
||||
|- bus # Finit's own D-Bus socket, see doc/dbus.md
|
||||
`- system/
|
||||
|- dbus.conf
|
||||
|- keventd.conf
|
||||
|- runparts.conf
|
||||
|- watchdogd.conf
|
||||
@@ -36,18 +35,21 @@ Configuration files in `/etc` are provided by the user, or projects like
|
||||
[finit-skel](https://github.com/finit-project/finit-skel) and extended by
|
||||
the user.
|
||||
|
||||
The files in `/run/finit/system/*.conf` are generated by Finit for its
|
||||
built-in services: runparts, [watchdog](../watchdog.md), and
|
||||
[`keventd`](../keventd.md), if they are enabled. They are read before
|
||||
the other .conf directories, so any later file can reference them in
|
||||
`if:` statements and override them by name.
|
||||
|
||||
The files in `/lib/finit/system/*.conf` are system critical services and
|
||||
setup provided by Finit, e.g. udev/mdev that must run very early at system
|
||||
bootstrap. This system directory was introduced in Finit v4.4 to replace
|
||||
the hard-coded services provided by plugins before. All .conf files in this
|
||||
directory be either replaced by a system administrator or overridden by a
|
||||
file with the same name in `/etc/finit.d/`.
|
||||
the hard-coded services provided by plugins before.
|
||||
|
||||
The files in `/run/finit/system/*.conf` are created by plugins and Finit
|
||||
bundled services like runparts, [watchdog](../watchdog.md), and
|
||||
[`keventd`](../keventd.md) if they are enabled. Like
|
||||
`/lib/finit/system/*.conf`, these files can be overridden by file with
|
||||
the same name in `/etc/finit.d/`.
|
||||
All .conf files in both directories can be either replaced by a system
|
||||
administrator or overridden by a file with the same name in
|
||||
`/etc/finit.d/`, which is always read last -- copy a .conf there and
|
||||
modify it, or symlink it to `/dev/null` to disable it outright.
|
||||
|
||||
Services in the `available/` and `enabled/` sub-directories are called
|
||||
dynamic services, in contrast to static services -- the only difference
|
||||
@@ -56,16 +58,17 @@ with the `enable` and `disable` commands. An administrator can always
|
||||
create files and symlinks manually.
|
||||
|
||||
At bootstrap, and `initctl reload`, all .conf files are read, starting
|
||||
with `finit.conf`, then `/lib/finit/system/*.conf`, `finit.d/*.conf`,
|
||||
and finally all `finit.d/enabled/*.conf` files. Each directory is a
|
||||
unique group, where files within each group are sorted alphabetically.
|
||||
with `finit.conf`, then `/run/finit/system/*.conf`,
|
||||
`/lib/finit/system/*.conf`, `finit.d/*.conf`, and finally all
|
||||
`finit.d/enabled/*.conf` files. Each directory is a unique group,
|
||||
where files within each group are sorted alphabetically.
|
||||
|
||||
**Example:**
|
||||
|
||||
/run/finit/system/keventd.conf
|
||||
/run/finit/system/runparts.conf
|
||||
/lib/finit/system/10-hotplug.conf
|
||||
/lib/finit/system/90-testserv.conf
|
||||
/run/finit/system/dbus.conf
|
||||
/run/finit/system/runparts.conf
|
||||
/etc/finit.d/10-abc.conf
|
||||
/etc/finit.d/20-abc.conf
|
||||
/etc/finit.d/enabled/1-aaa.conf
|
||||
|
||||
+18
-23
@@ -701,9 +701,9 @@ char *conf_escape(const char *str, char *buf, size_t len)
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by plugins and similar that dynamically generate system
|
||||
* services. @body holds the block contents, one indented line per
|
||||
* setting.
|
||||
* Generates /run/finit/system/<file> for Finit's built-in services,
|
||||
* which must probe the running system before registering. @fmt holds
|
||||
* the block contents, one indented line per setting.
|
||||
*/
|
||||
void conf_save_service(int type, const char *name, char *file, const char *fmt, ...)
|
||||
{
|
||||
@@ -2307,28 +2307,23 @@ int conf_reload(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Next, read all *.conf in /lib/finit/system and /etc/finit.d/
|
||||
* The system files were previously created at runtime by plugins
|
||||
* but are now regular files that can be overridden by files in
|
||||
* /etc/finit.d -- similar to how tmfiles.d(5) work. E.g., add
|
||||
* an override .conf, or an ignore by symlinking to /dev/null
|
||||
* Next, read all *.conf in /run/finit/system, /lib/finit/system,
|
||||
* and /etc/finit.d/. The runtime directory holds files Finit
|
||||
* generates for its built-in services (keventd, watchdogd,
|
||||
* runparts), read first so later files can reference them in
|
||||
* if: statements. A same-named file in a later directory
|
||||
* overrides an earlier one, similar to how tmpfiles.d(5) work,
|
||||
* so /etc/finit.d, always read last, is how users override any
|
||||
* built-in or bundled configuration.
|
||||
*
|
||||
* The .conf files (and run/task/service stanzas) are parsed and
|
||||
* started in order. Each directory is sorted alphanumerically
|
||||
* and then the result is appended to the overall order:
|
||||
*
|
||||
* /lib/finit/system/10-hotplug.conf
|
||||
* /lib/finit/system/90-testserv.conf
|
||||
* /run/finit/system/dbus.conf
|
||||
* /run/finit/system/tty.conf
|
||||
* /etc/finit.d/10-abc.conf
|
||||
* /etc/finit.d/20-abc.conf
|
||||
* /etc/finit.d/enabled/1-aaa.conf
|
||||
* /etc/finit.d/enabled/1-abc.conf
|
||||
* /etc/finit.d/enabled/2-aaa.conf
|
||||
* The .conf files (and their run/task/service stanzas) are
|
||||
* parsed and started in order. Each directory is sorted
|
||||
* alphanumerically before being appended to the overall order,
|
||||
* recorded in /run/finit/conf.order at bootstrap. See
|
||||
* doc/config/files.md for an example.
|
||||
*/
|
||||
glob_append(&gl, 0, "%s/*.conf", FINIT_SYSPATH_);
|
||||
glob_append(&gl, 1, "%s/*.conf", FINIT_RUNPATH_);
|
||||
glob_append(&gl, 0, "%s/*.conf", FINIT_RUNPATH_);
|
||||
glob_append(&gl, 1, "%s/*.conf", FINIT_SYSPATH_);
|
||||
glob_append(&gl, 1, "%s/*.conf", finit_rcsd);
|
||||
glob_append(&gl, 1, "%s/enabled/*.conf", finit_rcsd);
|
||||
|
||||
|
||||
Reference in new issue
Block a user