Commit Graph
81895 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 2b2ca7ff2a core: do not include names directly in error messages
This allows some strings constants to be deduplicated.
libsystemd-core.so + systemd are about 2k smaller.

Also tweak some messages for consistency. We used 'exec' in one place and
'execute' in all other messages.
2025-05-31 15:35:02 +02:00
Zbigniew Jędrzejewski-Szmek 9e2befbf4b sd-device: do not include file name directly in error messages
$ diff -u <(strings -n 10 build/libsystemd.so.0.40.0.0 | sort) <(strings -n 10 build/libsystemd.so.0.40.0 | sort)
--- /proc/self/fd/11    2025-05-31 15:17:16.968761963 +0200
+++ /proc/self/fd/12    2025-05-31 15:17:16.970159823 +0200
@@ -3860,11 +3860,6 @@
 Failed to fstat() journal file '%s', ignoring: %m
 Failed to fstat %s: %m
 Failed to get basic: %m
-Failed to get device "ACTION" property, ignoring: %m
-Failed to get device "DEVNUM" property, ignoring: %m
-Failed to get device "DISKSEQ" property, ignoring: %m
-Failed to get device "IFINDEX" property, ignoring: %m
-Failed to get device "SEQNUM" property, ignoring: %m
 Failed to get device "%s" property, ignoring: %m
 Failed to get inode number of pidfd for pid %i: %m
 Failed to get peer's socket address, ignoring: %m

$ ls -l build/libsystemd.so.0.40.0{,.0}
-rwxr-xr-x 1 zbyszek zbyszek 7631640 May 31 15:16 build/libsystemd.so.0.40.0
-rwxr-xr-x 1 zbyszek zbyszek 7635736 May 31 15:16 build/libsystemd.so.0.40.0.0

$ size build/libsystemd.so.0.40.0{,.0}
   text    data     bss     dec     hex filename
1241382   56185    3554 1301121  13da81 build/libsystemd.so.0.40.0
1241606   56185    3554 1301345  13db61 build/libsystemd.so.0.40.0.0

So the savings are ~4kB, which is more than I expected.
2025-05-31 15:35:02 +02:00
Zbigniew Jędrzejewski-Szmek 4df8fc99ce sleep: do not include file name directly in error messages
Here the .text section becomes smaller, but the file size doesn't change
(I guess some alignment issue). But is seems to be reasonable change to
anyway, we might get some savings in different compilations anyway.

Also improve two messages.
2025-05-31 15:34:53 +02:00
Zbigniew Jędrzejewski-Szmek 53059edcb4 random-seed: do not include file name directly in error messages
The path is fairly long and by embedding it in the message, we get a longer
data section in our binary. By using %s, we can make the template strings
shorter, deduplicating bytes in our binary. Those are error messages, i.e. by
definition they are only used very rarely, so it's completely fine if printf
does a bit more work when generating the message.

$ strings build/systemd-random-seed.0 | rg '/var/lib/systemd/random-seed'
/var/lib/systemd/random-seed
Failed to open /var/lib/systemd/random-seed for writing: %m
Failed to open /var/lib/systemd/random-seed for reading: %m
Failed to open /var/lib/systemd/random-seed: %m
Failed to stat() seed file /var/lib/systemd/random-seed: %m
Failed to read seed from /var/lib/systemd/random-seed: %m
Seed file /var/lib/systemd/random-seed not yet initialized, proceeding.

$ strings build/systemd-random-seed | rg '/var/lib/systemd/random-seed'
/var/lib/systemd/random-seed

$ ls -l build/systemd-random-seed{,.0}
-rwxr-xr-x 1 zbyszek zbyszek 68872 May 31 13:39 build/systemd-random-seed.0
-rwxr-xr-x 1 zbyszek zbyszek 64912 May 31 13:45 build/systemd-random-seed
That's a ~6% smaller binary!
2025-05-31 14:49:16 +02:00
Lennart Poettering 1105f8d20f tree-wide: only use .si_pid field in siginfo_t, if .si_code indicates that's safe
Fixes: #37498
2025-05-31 14:48:37 +02:00
Yu Watanabe 91c60ff528 bootctl: do not print slash more than once
When bootctl is called by an unprivileged user, then previously we got
```
Failed to read "/boot/EFI/systemd": Permission denied
Failed to open '/boot//loader/loader.conf': Permission denied
```
Now, with this patch, we get
```
Failed to read "/boot/EFI/systemd": Permission denied
Failed to open '/boot/loader/loader.conf': Permission denied
```
2025-05-31 13:53:04 +02:00
Christian Glombek 0af9937691 portable,sysext: match extension OS ID also against host ID_LIKE 2025-05-31 10:02:11 +09:00
Luca Boccassi 703fbb0bba test: wait for coredump to appear before parsing
A new core was added to the test, but the loop counter was not increased
to wait for it, so the test races against systemd-coredump's processing.

This failed at least once in debci:

8015s [   32.227813] TEST-87-AUX-UTILS-VM.sh[1038]: + coredumpctl info COREDUMP_TIMESTAMP=1679509902000000
8015s [   32.228684] TEST-87-AUX-UTILS-VM.sh[1723]: No coredumps found.

Follow-up for 0c49e0049b

Fixes https://github.com/systemd/systemd/issues/37666
2025-05-31 10:01:30 +09:00
Yu Watanabe 3ec92f2f74 terminal-util: fix typo
Follow-up for 5321b957b4.
2025-05-31 04:44:34 +09:00
Shubhendra Kushwaha 2948f981dd docs: add man page for sd_device_enumerator_get_device_first() and friends
For #20929.
2025-05-31 04:40:33 +09:00
Yu Watanabe 8e9c003e29 core/cgroup: update comment
We do not have SetProperty() method, but SetProperties().
2025-05-31 04:15:04 +09:00
Yu Watanabe ab5587d674 core/transaction: restart dependency loop when a new dependency is added (#37465)
Fixes #36031.
2025-05-31 04:01:06 +09:00
Yu Watanabe e018cf0c67 TODO: drop entry about removal of unnecessary INTERFACE_OLD check in udevadm trigger
Done by fde9f2bc48.
2025-05-31 03:46:53 +09:00
Luca Boccassi fe8cdd18d6 docs: small improvements for html man pages menu selector (#37663)
Result is already live at
https://www.freedesktop.org/software/systemd/man
2025-05-30 12:33:48 +01:00
Luca Boccassi 90b0222091 sync-docs: add '(latest stable)' next to the latest version in the menu
Add visual indicator of what is the latest version in the
version menu
2025-05-30 11:54:01 +01:00
Luca Boccassi 1cd995185b sync-docs: fix selection menu when opening 'latest' man
'devel' will always sort first, so the highest version is the second
entry, not the first one
2025-05-30 11:54:01 +01:00
Luca Boccassi 34d63ac879 sync-docs: fix syntax warning
sync-docs.py:94: SyntaxWarning: invalid escape sequence '\d'
  m = re.match("v?(\d+).*", tag)
2025-05-30 11:54:01 +01:00
Zbigniew Jędrzejewski-Szmek 2e8d47f21c core/exec-invoke: rework $TERM fallback logic (#37647)
Inspired by https://github.com/systemd/systemd/pull/37538, see a
detailed rationale in
https://github.com/systemd/systemd/pull/37538#discussion_r2110229075.
2025-05-30 12:39:51 +02:00
Eisuke Kawashima 9521222222 chore: fix editorconfig pattern and add setting for zsh 2025-05-30 14:53:45 +09:00
Jörg Behrmann 5b5155dbf8 NEWS: fix typos 2025-05-30 06:26:57 +09:00
Mike Yuan 6131dc0aad core/exec-invoke: skip query of /dev/console $TERM if we're child of pid1 2025-05-29 21:25:28 +02:00
Mike Yuan 8ffebaaf4d core/exec-invoke: propagate $COLORTERM and $NO_COLOR from pid1 as well
Follow-up for 19aff5f775
2025-05-29 21:16:28 +02:00
Mike Yuan 3235fae685 core/exec-invoke: rework where to apply $TERM fallback logic
Follow-up for 728dbaeffb
and ad6ca4a612

This is inspired by #37538, see the discussion in
https://github.com/systemd/systemd/pull/37538#discussion_r2110229075.

If the user already specifies $TERM (which is actually
quite common if you look at run0), we'd needlessly invoke
the "fallback" logic and
a) possibly issue a DCS query whose result we end up simply
   discarding in strv_env_merge()
b) set $COLORTERM to "truecolor" unconditionally, whereas
   the explicit $TERM value might intend to disable the color output

To address this, the logic of setting fallback $TERM and friends
has been split out of build_environment(), and we'd call into it
only after all envvars have been collected.
2025-05-29 21:16:25 +02:00
Mike Yuan 94f533e305 core: strv_env_clean() modifies in-place, no need to set buf to itself 2025-05-29 21:01:43 +02:00
Mike Yuan 4d67fcabed env-util: add missing assertions 2025-05-29 21:01:43 +02:00
Mike Yuan a9b053deb1 env-util: modernize *_is_valid() 2025-05-29 21:01:43 +02:00
Mike Yuan c51379e6d8 Use DCS sequence to query terminal name and set $TERM automatically (#37538)
This code seems to work quickly and nicely for a bunch of modern
terminals. Setting $TERM automatically removes an common annoyance for
users. This code will not work for all terminal emulators, but by adding
it in systemd we'll entice maintainers of those terminals to add support
for the sequences. For the terminals that don't support the sequence, we
get a bit of a slowdown of `< 1 ms`, which seems hardly noticeable. The
user can always set TERM explicitly to avoid this if upgrading to a
newer terminal emulator is not possible.

Closes https://github.com/systemd/systemd/issues/36994.
2025-05-29 21:01:01 +02:00
Temuri Doghonadze b222e71211 po: Translated using Weblate (Georgian)
Currently translated at 100.0% (257 of 257 strings)

Co-authored-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/ka/
Translation: systemd/main
2025-05-30 02:55:28 +09:00
Zbigniew Jędrzejewski-Szmek f256e48d4e basic/terminal-util: drop now-unused default_term_for_tty 2025-05-29 19:20:31 +02:00
Zbigniew Jędrzejewski-Szmek ad6ca4a612 core: use terminal DCS sequence to set $TERM
query_term_for_tty() is used in two places: in fixup_environment(),
which affects PID1 itself, and in build_environment(), which affects
spawned services. There is obviously some cost to the extra call,
but I think it's worthwhile to do it. When $TERM is set incorrectly,
basic output works OK, but then there are various annoying corner
cases. In particular, we get the support for color (or lack of it)
wrong, and when output is garbled, users are annoyed. Things like
text editors are almost certain to behave incorrectly. Testing in
test-terminal-util indicates that the time required to make a successful
query is on the order of a dozen microseconds, and an unsuccessful
query costs as much as our timeout, i.e. currently 1/3 ms. I think
this is an acceptable tradeoff.

No caching is used, because fixup_environment() is only called once,
and the other place in build_environment(), only affects services
which are connected to a tty, which is only a handful of services,
and often only started in special circumstances.

Fixes https://github.com/systemd/systemd/issues/36994.
2025-05-29 19:20:31 +02:00
Zbigniew Jędrzejewski-Szmek e3b050a5c2 basic/terminal-util: add a heuristic check whether terminfo file exists 2025-05-29 19:20:31 +02:00
Zbigniew Jędrzejewski-Szmek 38b79aa0ea test-terminal-util: print how long the asynchronous queries take 2025-05-29 19:20:31 +02:00
Zbigniew Jędrzejewski-Szmek 5321b957b4 basic/terminal-util: query terminal name by DCS
As requested in https://github.com/systemd/systemd/issues/36994,
use DCS + q name ST. This works, but has limited terminal support:
xterm, foot, kitty.
2025-05-29 19:20:31 +02:00
Zbigniew Jędrzejewski-Szmek 505a5d2bcd Merge remote-tracking branch 'systemd-security/coredump-d' 2025-05-29 17:22:19 +02:00
Luca Boccassi f13bc8533c login: receive synthetic events for devices with 'uaccess' tag (#37654)
Fixes #37579.
2025-05-29 15:11:14 +01:00
Luca Boccassi 5cfc9c34f4 sysupdate: change status once operation has completed
Otherwise after the service exits it will still show
"Installing 'foobar'" as the status, which is confusing
2025-05-29 15:44:31 +02:00
Allison Karlitskaya 1994426f90 NEWS: fix description of CopyFiles==::fsverity=copy
This doesn't enable fs-verity on every file, but preserves the fs-verity
status that was present to start with.
2025-05-29 18:54:05 +09:00
Shubhendra Kushwaha fbad1beae4 docs: add man pages for sd_device_enumerator_add_match_* (#37589)
Add man pages for:
- `sd_device_enumerator_add_all_parents`
- `sd_device_enumerator_add_match_parent`
- `sd_device_enumerator_add_match_property`
- `sd_device_enumerator_add_match_property_required`
- `sd_device_enumerator_add_match_subsystem`
- `sd_device_enumerator_add_match_sysattr`
- `sd_device_enumerator_add_match_sysname`
- `sd_device_enumerator_add_match_tag`
- `sd_device_enumerator_add_nomatch_sysname`
- `sd_device_enumerator_allow_uninitialized`.

Related to #20929
2025-05-29 18:40:18 +09:00
Yu Watanabe 50e518a96a login: add several debugging logs about synthetic events 2025-05-29 11:41:25 +09:00
Yu Watanabe 392b9ab647 login: add device monitor instance to receive events for devices with uaccess tag
With c960ca2be1, logind triggers uevents
for devices with uaccess tag, and waits for the events being processed
by udevd.
However, logind received not all triggered events, and might lose some
events. That causes session and user state file not updated, and many
desktop environment application handled the session and user were inactive.

This introduces one more device monitor instance which monitor events
for devices with 'uaccess' tag. Hence, all triggered events will be
recieved by logind, and session and user state file will be updated.

Follow-up for c960ca2be1.
Fixes #37579.
2025-05-29 11:41:25 +09:00
Mike Yuan 4313aeedf5 ssh-generator: two cleanups (#37649) 2025-05-29 02:26:44 +02:00
Luca Boccassi 60491ceb12 test: fix TEST-84-STORAGETM with nvme-cli < 2.7
The -vv parameter was added in version 2.7, check before using it

Follow-up for ebc0514a65
2025-05-29 01:15:56 +01:00
Zbigniew Jędrzejewski-Szmek 9ce8e3e449 Define helper to call PR_SET_DUMPABLE 2025-05-29 00:19:24 +02:00
Zbigniew Jędrzejewski-Szmek 76e0ab49c4 coredump: introduce an enum to wrap dumpable constants
Two constants are described in the man page, but are not defined by a header.
The third constant is described in the kernel docs. Use explicit values to
show that those are values are defined externally.
2025-05-29 00:12:10 +02:00
Zbigniew Jędrzejewski-Szmek e6a8687b93 coredump: when %F/pidfd is used, again allow forwarding to containers 2025-05-29 00:10:55 +02:00
Luca Boccassi 868d95577e coredump: add support for new %F PIDFD specifier
A new core_pattern specifier was added, %F, to provide a PIDFD
to the usermode helper process referring to the crashed process.
This removes all possible race conditions, ensuring only the
crashed process gets inspected by systemd-coredump.
2025-05-29 00:10:55 +02:00
Zbigniew Jędrzejewski-Szmek 13902e0253 coredump: get rid of a bogus assertion
The check looks plausible, but when I started checking whether it needs
to be lowered for the recent changes, I realized that it doesn't make
much sense.

context_parse_iovw() is called from a few places, e.g.:
- process_socket(), where the other side controls the contents of the
  message. We already do other checks on the correctness of the message
  and this assert is not needed.
- gather_pid_metadata_from_argv(), which is called after
  inserting MESSAGE_ID= and PRIORITY= into the array, so there is no
  direct relation between _META_ARGV_MAX and the number of args in the
  iovw.
- gather_pid_metadata_from_procfs(), where we insert a bazillion fields,
  but without any relation to _META_ARGV_MAX.

Since we already separately check if the required stuff was set, drop this
misleading check.
2025-05-29 00:10:55 +02:00
Zbigniew Jędrzejewski-Szmek 8fc7b2a211 coredump: also stop forwarding non-dumpable processes
See the comment in the patch for details.

Suggested-by: Qualys Security Advisory <qsa@qualys.com>
2025-05-29 00:10:55 +02:00
Zbigniew Jędrzejewski-Szmek 0c49e0049b coredump: use %d in kernel core pattern
The kernel provides %d which is documented as
"dump mode—same as value returned by prctl(2) PR_GET_DUMPABLE".

We already query /proc/pid/auxv for this information, but unfortunately this
check is subject to a race, because the crashed process may be replaced by an
attacker before we read this data, for example replacing a SUID process that
was killed by a signal with another process that is not SUID, tricking us into
making the coredump of the original process readable by the attacker.

With this patch, we effectively add one more check to the list of conditions
that need be satisfied if we are to make the coredump accessible to the user.

Reportedy-by: Qualys Security Advisory <qsa@qualys.com>

In principle, %d might return a value other than 0, 1, or 2 in the future.
Thus, we accept those, but emit a notice.
2025-05-29 00:10:08 +02:00
Lennart Poettering a5b713630f update NEWS 2025-05-28 23:01:21 +02:00