Daan De Meyer [Tue, 21 Mar 2023 13:51:56 +0000 (14:51 +0100)]
log: Add key/value support to the log context
Now that we have reference counting, it's useful to be able to push
single key values onto the log context separately, so that we don't
have to allocate new storage to join the separate string together into
a single field which means we won't be able to reuse a context containing
the same field.
Daan De Meyer [Tue, 21 Mar 2023 13:06:21 +0000 (14:06 +0100)]
log: Avoid pushing the same fields more than once on the log context
Let's try to optimize against pushing the same fields multiple times
onto the log context. To achieve this we make the log context reference
counted and return an existing context object if it's using the same
fields.
A consequence of this is that we have to make sure attaching/detaching
is coupled to the lifetime of the context object, so we make the attach
and detach functions private for now. If we need independent attach/detach
in the future, we can make that work with some extra complexity but since
we don't need it yet, let's not support it for now.
man/network-generator: replace dracut.kernel reference with dracut.cmdline
`dracut.kernel.7` is just a symlink to `dracut.cmdline.7`, so the web reference
points to a non-existent URL
(https://man7.org/linux/man-pages/man7/dracut.kernel.7.html).
Dmitry V. Levin [Thu, 16 Mar 2023 08:00:00 +0000 (08:00 +0000)]
udev-rules: fix matching of token types that support alternative patterns
For those token types that support matching of alternative patterns,
their token values are interpreted as nulstr, so make sure the parser
does the right thing and makes these token values terminated by two
subsequent NULs so they could be safely interpreted as nulstr.
Before this fix, the following rules would result to "echo foo" invocation:
ENV{foo}=", RUN"
ENV{foo}=="bar", RUN+="echo foo"
because the value of `ENV{foo}` is treated as nulstr, and it used to match
against alternative patterns, in this case `bar`, `, RUN`, and `="echo foo`.
Yu Watanabe [Sat, 18 Mar 2023 13:24:53 +0000 (22:24 +0900)]
test-systemd-tmpfiles.py: create global temporary directory
For some unknown reasons, the temporary directory created by the test
below is not removed:
```
# Test the case that a valid symlink is in the path.
label = 'valid_symlink-deep'
test_content('f= {} - - - - ' + label, label, user=user, subpath='/deep/1/2', path_cb=valid_symlink)
```
To keep /tmp clean, let's create the global temprary directory.
Daan De Meyer [Fri, 17 Mar 2023 12:07:56 +0000 (13:07 +0100)]
units: Order user@.service after systemd-oomd.service
The user manager connects to oomd over varlink. Currently, during
shutdown, if oomd is stopped before any user manager, the user
manager will try to reconnect to the socket, leading to a warning
from pid 1 about a conflicting transaction.
Let's fix this by ordering user@.service after systemd-oomd.service,
so that user sessions are stopped before systemd-oomd is stopped,
which makes sure that the user sessions won't try to start oomd via
its socket after systemd-oomd is stopped.
Yu Watanabe [Thu, 16 Mar 2023 04:33:28 +0000 (13:33 +0900)]
kernel-install: check all entry candidates first, then check existence of $pref/loader/entries only once
If we have multiple entries in $ENTRY_TOKEN_SEARCH, and $pref/loader/entries
exists, then previously we would always exit after the first candidate and
ignore the second and later candidates.
> Hmm, this is highly problematic, no? if I boot from my ssd and then
> plug in a fedora live usb stick, then there will be two ESPs around,
> the one from my ssd and the one from the live usb one, and this code
> might find the wrong one and bad things will happen
Daan De Meyer [Thu, 16 Mar 2023 10:22:58 +0000 (11:22 +0100)]
journald-console: Add colors when forwarding to console
Let's color output when we're forwarding to the console. To make this
work, we inherit TERM from pid 1 and use it to decide whether we should
output colors or not.
Daan De Meyer [Thu, 16 Mar 2023 10:21:28 +0000 (11:21 +0100)]
terminal-util: Don't assume terminal is dumb if connected to /dev/null
If we're connected to /dev/null, we're likely going to be writing
colors to something that's not stdout/stderr, so let's fall back to
checking TERM if that's the case.
Yu Watanabe [Wed, 15 Mar 2023 06:12:41 +0000 (15:12 +0900)]
sd-journal: fix segfault
Unfortunately, journal_file_next_entry() returns 0 when the next entry
not found. The commit cc938e4a0ab67707e489cc3970a8557ad89801ca adds
FIXME comment about that. We should really fix that, but the function and
its return value are used in many place, hence checking all usecases is not
easy. So, let's workaround that here, and handle the 0 return value by
the caller.
Let's make use of SD_EVENT_SIGNAL_PROCMASK so that we don't have to mask
the signals manually. Let's use sd_event_set_exit_signal() instead of
rolling our own SIGTERM/SIGINT handling. Let's use "floating" event
sources instead of keeping references on our own.
Let's also debug log if we can't enable watchdog handling.