Commit Graph

84116 Commits

Author SHA1 Message Date
Daan De Meyer
f102bc3e5f tree-wide: Introduce sd-forward.h and shared-forward.h headers
Let's not leak details from src/shared and src/libsystemd into
src/basic, even though you can't actually do anything useful with
just forward declarations from src/shared.

The sd-forward.h header is put in src/libsystemd/sd-common as we
don't have a directory for shared internal headers for libsystemd
yet.

Let's also rename forward.h to basic-forward.h to keep things
self-explanatory.
2025-10-16 17:00:29 +02:00
Luca Boccassi
ac9391c552 Support ExtensionImages=/MountImages= in user services via mountfsd and PrivateUsers=yes (#39341) 2025-10-16 15:49:46 +01:00
Luca Boccassi
68b476a298 core: also enable PrivateUsers= for user services when using images via mountfsd
RootDirectory= and other options already implicitly enable PrivateUsers=
since 6ef721cbc7 if they are set in user
units, so that they can work out of the box.
Now with mountfsd support we can do the same for the images settings,
so enable them and document them.
2025-10-16 12:58:59 +01:00
Luca Boccassi
29e97643e7 Support ExtensionImages=/MountImages= in user services via mountfsd
Support for RootImage= was added by 046a1487db
but it was not wired in for ExtensionImages=/MountImages=
2025-10-16 12:58:59 +01:00
Luca Boccassi
1ebbb0b0f4 test: add coverage for RootImage= in user units
Follow-up for 046a1487db
2025-10-16 12:58:55 +01:00
Daan De Meyer
f875a8026e core: Don't use TTYPath= for PAM unless StandardInput=tty
Fixes #39334
2025-10-16 13:46:19 +02:00
Zbigniew Jędrzejewski-Szmek
6c80ab85f5 core/cgroup: two follow-ups for recent OOMKills PR (#39215)
Follow-ups for #38906.
2025-10-16 13:38:01 +02:00
Frantisek Sumsal
92631f1962 test: wait for signed.test's zone DS records to get pushed to the parent zone
It looks like the 4 second sleep might not be enough on some slower
machines (like the ARM GH Actions nodes) which can lead to the DS RRs
propagation to clash with the manual test zone edit, and the
signed.test zone then might end up not properly signed:

TEST-75-RESOLVED.sh[749]: + : '--- ZONE: signed.test (static DNSSEC) ---'
TEST-75-RESOLVED.sh[749]: + run_delv @ns1.unsigned.test signed.test
TEST-75-RESOLVED.sh[749]: + run delv -a /etc/bind.keys @ns1.unsigned.test signed.test
TEST-75-RESOLVED.sh[778]: + delv -a /etc/bind.keys @ns1.unsigned.test signed.test
TEST-75-RESOLVED.sh[779]: + tee /tmp/tmp.2KOIiyrgth
TEST-75-RESOLVED.sh[779]: ;; /etc/bind.keys:1: option 'managed-keys' is deprecated
TEST-75-RESOLVED.sh[779]: ;; validating signed.test/DS: no valid signature found
TEST-75-RESOLVED.sh[779]: ;; validating signed.test/A: no valid signature found
TEST-75-RESOLVED.sh[779]: ; unsigned answer
TEST-75-RESOLVED.sh[779]: signed.test.		86400	IN	A	10.0.0.10
TEST-75-RESOLVED.sh[779]: signed.test.		86400	IN	RRSIG	A 13 2 86400 20251028114356 20251014101356 39330 signed.test. oo3ca8WPusbBPRhzsEKw3bsBBqFtI8i4bckoMVNzt7lY+udGW6PlaSYj OjpQGgY9oglowVM9bteNtwJKHUbvtw==
TEST-75-RESOLVED.sh[749]: + grep -qF '; fully validated' /tmp/tmp.2KOIiyrgth
[FAILED] Failed to start TEST-75-RESOLVED.service - TEST-75-RESOLVED.

Let's explicitly wait for the DS records propagation to finish before we
start editing the test zone to avoid this.

I'm still not completely sure if this is the root cause, but it's the
best shot I currently have, so I'll let the CIs decide.
2025-10-16 11:51:03 +01:00
Antonio Alvarez Feijoo
b8ad88a407 meson: fix HAVE_LIBARCHIVE_* conditions
Follow-up for a7c8f92d1f
2025-10-16 11:48:53 +01:00
Zbigniew Jędrzejewski-Szmek
f0562fc819 test: minor fixlets for TEST-50-DISSECT (#39328) 2025-10-16 12:25:41 +02:00
Daan De Meyer
73623f1984 core: Make sure we don't clobber return argument on failure
As documented in the coding style, let's make sure we follow it.
2025-10-16 11:06:43 +01:00
Daan De Meyer
e8a0463c16 test: fixes for debian unstable and TEST-50-DISSECT (#39331)
Test failed in a weird way, turns out we don't use pipefail and an
intermediate command was moved to a different package so it wasn't in
the minimal image anymore. Add it, and use pipefail so in the future
it's easier to spot.
2025-10-16 08:45:46 +02:00
Zbigniew Jędrzejewski-Szmek
1929f43199 test-tar-extract: add a binary wrapping tar_x() for manual testing
We'll probably want to turn this into a test in the integration tests.
2025-10-16 08:22:33 +02:00
Luca Boccassi
0ce88a9132 test: call bash with -o pipefail when piping commands in TEST-50-DISSECT
We want the tests to fail if one of the intermediate commands fails,
otherwise it is hard to spot failures
2025-10-15 22:58:19 +01:00
Luca Boccassi
2a5e68e27d test: install bsdextrautils in debian minimal img
'rev' moved to bsdextrautils and TEST-50-DISSECT uses it, so it now
fails:

[   83.534905] bash[3581]: +++ grep '^now' /proc/timer_list
[   83.535479] bash[3582]: +++ cut '-d ' -f3
[   83.535774] bash[3583]: +++ rev
[   83.535774] bash[3583]: bash: line 1: rev: command not found
2025-10-15 22:54:51 +01:00
Luca Boccassi
c581bc8ad8 test: sign extension images used by TEST-50-DISSECT 2025-10-15 19:39:21 +01:00
Luca Boccassi
dc88805d16 test: also test verity signatures on debian testing/unstable
debian testing/unstable do not set VERSION_ID, so if missing, assume
it's testing/unstable which are new enough
2025-10-15 19:39:21 +01:00
Zbigniew Jędrzejewski-Szmek
53ff5b361f core: Delete redundant log_parse_environment(), v2 (#39278)
Reworked version of #39175.
2025-10-15 17:50:59 +02:00
Luca Boccassi
e8d1a26d9c test: move checks around in TEST-50-DISSECT so that they can be used from multiple subtests
Also set it up so that unprivileged tests can be done
2025-10-15 15:29:14 +01:00
huyubiao
8f2c5dea63 core: delete redundant log_parse_environment()
Fixes https://github.com/systemd/systemd/issues/38895.

Fix the confusing behavior where when an incorrect configuration item such as
'ManagerEnvironment=SYSTEMD_LOG_LEVEL=' is set, the first daemon-reload uses
old environment variables while the second daemon-reload uses LogLevel=.

Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>

The difference in behaviour is that the operations that were done between the
first log_parse_environment() and the second one might not be logged now, e.g.
if the environment enabled debug logging. That is unfortunate, but parsing the
environment twice and not having the explicit configuration take effect until a
second daemon-reload is confusing. We will always have some window where the
configuration for logging does not apply, in particular this must be true when
parsing the logging configuration. To make that window smaller, move operations
that could log after the call to log_parse_environment() as far as possible.
2025-10-15 14:00:45 +02:00
Zbigniew Jędrzejewski-Szmek
938f7fea7c man/systemd-systemd.conf: describe DefaultEnvironment= and ManagerEnvironment= better
The description of ME= said "see above", but it was actually above the other
one. So change the order. But while reading this, I found it very hard to
understand. So reword things, hopefully in a way that is easier to understand.
The current behaviour is rather complex and unintuitive, but this description
just tries to describe it truthfully.
2025-10-15 14:00:40 +02:00
Luca Boccassi
de2276cdcd Revert "machine: restrict register-machine action again"
Now that we have landed several fixes, this should be safe to do
again, so allow logged in users to register machines without
authentication prompts

This reverts commit 65badde82e.
2025-10-15 12:02:34 +02:00
Luca Boccassi
9dd61cfbe7 Use verity sharing for user services and nspawn too (#39313)
https://github.com/systemd/systemd/pull/39168 made verity sharing
opt-in, and enabled it for system services.
Also enable it for user services for RootImage/etc, and for nspawn, for
the same reasons.
2025-10-15 11:01:57 +01:00
Govind Venugopal
3eb7b881bd network: add DHCP server domain name option support (#39260)
Implements DHCP option 15 (Domain Name) for systemd-networkd's DHCP
server, allowing administrators to configure the DNS default domain that
clients should use.

This addresses the feature request in issue #37077, where users needed
to manually configure domain names using
SendOption=15:string:example.com as a workaround.

This adds two new configuration options to the [DHCPServer] section:
- EmitDomain= (boolean): whether to send domain name to clients
- Domain= (string): the domain name to send (e.g., "example.com")

Example configuration:
  [DHCPServer] EmitDomain=yes Domain=example.com

This eliminates the need for manual workarounds using
SendOption=15:string:...

Fixes #37077
2025-10-15 11:20:41 +02:00
Lennart Poettering
4cae0e9a78 importd: change untar logic to be based on libarchive rather than shelling out to gnu tar (#39143)
Let's use libarchive consistently everywhere, both for tarring and
untarring.

Note that there's an existing test case that validates untarring. Now,
it will validate libarchive rather than gnu tar.

Split out of #38728
2025-10-15 11:12:23 +02:00
Lennart Poettering
9f69ff69f7 mountfsd: make MountDirectory() work with systemd-homed
systemd-homed already applies an idmap to its mounts, hence we need to
undo it before we can create our own.
2025-10-15 10:21:59 +02:00
Yu Watanabe
0d87de0b8e nsresource: fix varlink method dispatch table
Follow-up for 716bf93c4b (v258).
2025-10-15 10:16:06 +02:00
Lennart Poettering
aad0d11e7c dissect-image: when autoprobing insist on vfat for XBOOTLDR
Let's reduce our attack surface by insisting that XBOOTLDR is vfat when
auto-probing, just like we do for the ESP. Given neither can
realistically be integrity protected (because firmware needs to access
them) let's insist on a vfat which has a much smaller attack surface,
and one we have to accept (for now) anyway, given that the ESP must be
VFAT.

This only applies to auto-probing of course. If people mount things
explicitly via fstab none of this matters. But we really shouldn't
automount a btrfs/xfs/ext4 partition as XBOOTLDR just because it looks
like one, as that would really defeat our otherwise possibly very strict
image policies.

This also introduces a new env var $SYSTEMD_DISSECT_FSTYPE_<DESIGNATOR>
environment variable that may override this hardcoding. This is in
particular useful in our testcases, since various actually do use ext4
as XBOOTLDR case. The tests are updated to make use of the new env var,
both as a mechanism to test this and to keep the tests working.
2025-10-15 08:32:37 +02:00
Luca Boccassi
566a4bbbbf nspawn: enable verity sharing
Just like RootImage=, ExtensionImages= etc, nspawn can make use of
this to save a lot of time when starting containers that use an already
open image, since the default was changed to disabled.

Follow-up for 57d1ceffb3
2025-10-14 20:49:12 +01:00
Luca Boccassi
ce7a5d6026 dissect-image: pass through DISSECT_IMAGE_VERITY_SHARE to mountfsd via varlink if set
This ensures user services using RootImage=, ExtensionImages= etc. also
try to reuse existing verity devices, like system services.

Follow-up for 57d1ceffb3
2025-10-14 20:49:12 +01:00
Luca Boccassi
a9b1e35a32 mountfsd: add boolean parameter to let callers enable verity sharing 2025-10-14 20:49:11 +01:00
Luca Boccassi
d29a2cd2d4 mountfsd: json format unsigned types as unsigned
sizes/offsets are unsigned ints, so use the appropriate macros
to build the json messages, otherwise UINT64T_MAX is sent as -1
2025-10-14 20:49:11 +01:00
Antonio Alvarez Feijoo
2fbfbfc5fa test: enable TEST-06-SELINUX in openSUSE
openSUSE switched to SELinux by default for quite some time now, so this test is
also successful.
2025-10-14 17:56:39 +01:00
Miroslav Lichvar
4db925d7da udev: create symlinks for s390 PTP devices
Similarly to the udev rules handling KVM and Hyper-V PTP devices, create
symlinks for the s390-specific STCKE and Physical clocks (supported
since Linux 6.13) to have some stable names that can be specified in
default configurations of PTP/NTP applications.
2025-10-14 18:31:17 +02:00
Lennart Poettering
1170cc4253 timer: rebase the next elapse timestamp only if timer didn't already run (#39296) 2025-10-14 18:30:23 +02:00
Zbigniew Jędrzejewski-Szmek
e63917abe1 core: allow split /usr/local/s?sbin with merged /usr/s?bin
Previously, we used either the fully split path or the fully merged path,
treating "split sbin" as a boolean condition. The idea was that conversion to
to merged bin would be a single event, so we don't need to care about the
details of the transition. But it turns out that some systems may be converted
in disparate steps. In https://bugzilla.redhat.com/show_bug.cgi?id=2400220,
there was a lengthy discussion about a coreos system where
/usr/local/{bin,sbin} were created as separate directories. Since /usr/local is
not part of the packaged system, it might remain split for a longer time. So
check /usr/local/s?bin separately and stop adding /usr/sbin to $PATH if only
/usr/local/s?bin is split. (I don't think it makes sense to handle the reverse
case, i.e. only /usr/s?bin being split, since that should be much rarer.)

Inspired by https://bugzilla.redhat.com/show_bug.cgi?id=2400220.
2025-10-14 18:30:06 +02:00
Frantisek Sumsal
f50e6fd897 mkosi: explicitly pull in libz1 on OpenSUSE
Otherwise it pulls in libz-ng-compat1 which isn't 100% compatible with
libz1, and more importantly it requires an ldconfig drop-in in /etc/
(/etc/ld.so.conf.d/zlib-ng-compat-x86_64.conf) which breaks hermetic-usr
and TEST-07-PID1:

systemd[5582]: /usr/lib/systemd/systemd: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
2025-10-14 17:29:58 +01:00
Frantisek Sumsal
bdb8e584f4 timer: rebase the next elapse timestamp only if timer didn't already run
The test added in f4c3c107d9 uncovered a
corner case while recalculating the next elapse timestamp of a timer unit
that uses RandomizedDelaySec= during deserialization.

If the scheduled time (without RandomizedDelaySec=) already elapsed,
systemd "rebases" the next elapse timestamp to the time when systemd
first started, to make the RandomizedDelaySec= feature work even at
boot. However, since it was done unconditionally, it always overrode the
next elapse timestamp, which could then cause the final next elapse
timestamp to fall out of the expected window.

With a couple of additional debug logs one of the test fail looks like
this:

[  132.129815] TEST-53-TIMER.sh[384]: + : 'Next elapse timestamp after daemon-reload, try #328'
[  132.129815] TEST-53-TIMER.sh[384]: + systemctl daemon-reload
[  132.136352] systemd[1]: Reload requested from client PID 16399 ('systemctl') (unit TEST-53-TIMER.service)...
[  132.136636] systemd[1]: Reloading...
[  132.446160] systemd[1]: Rebasing next elapse timestamp
[  132.446168] systemd[1]: v->next_elapse: Tue 2025-10-14 00:10:00 CEST
[  132.446170] systemd[1]: rebased: Tue 2025-10-14 00:10:56 CEST
[  132.446172] systemd[1]: v->next_elapse after rebase: Tue 2025-10-14 00:10:56 CEST
[  132.447361] systemd[1]: Reloading finished in 310 ms.
[  132.484041] TEST-53-TIMER.sh[384]: + check_elapse_timestamp
[  132.484041] TEST-53-TIMER.sh[384]: + systemctl status timer-RandomizedDelaySec-16377.timer
[  132.533657] TEST-53-TIMER.sh[16440]: ● timer-RandomizedDelaySec-16377.timer
[  132.533657] TEST-53-TIMER.sh[16440]:      Loaded: loaded (/run/systemd/system/timer-RandomizedDelaySec-16377.timer; static)
[  132.533657] TEST-53-TIMER.sh[16440]:      Active: active (waiting) since Mon 2025-10-13 23:00:00 CEST; 1h 13min ago
[  132.533657] TEST-53-TIMER.sh[16440]:  Invocation: 5555d4f060114a5493ff228013830d17
[  132.533657] TEST-53-TIMER.sh[16440]:     Trigger: Tue 2025-10-14 22:10:04 CEST; 21h left
[  132.533657] TEST-53-TIMER.sh[16440]:    Triggers: ● timer-RandomizedDelaySec-16377.service
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:07 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Changed dead -> waiting
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:07 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Adding 15h 35min 1.230173s random time.
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:07 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Realtime timer elapses at Tue 2025-10-14 15:45:58 CEST.
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:07 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Changed dead -> waiting
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Adding 16h 29min 44.084409s random time.
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Realtime timer elapses at Tue 2025-10-14 16:40:41 CEST.
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Changed dead -> waiting
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Adding 21h 59min 7.955828s random time.
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Realtime timer elapses at Tue 2025-10-14 22:10:04 CEST.
[  132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Changed dead -> waiting
[  132.535386] TEST-53-TIMER.sh[384]: + systemctl show -p InactiveExitTimestamp timer-RandomizedDelaySec-16377.timer
[  132.537727] TEST-53-TIMER.sh[16442]: InactiveExitTimestamp=Mon 2025-10-13 23:00:00 CEST
[  132.540317] TEST-53-TIMER.sh[16444]: ++ systemctl show -P NextElapseUSecRealtime timer-RandomizedDelaySec-16377.timer
[  132.547745] TEST-53-TIMER.sh[384]: + NEXT_ELAPSE_REALTIME='Tue 2025-10-14 22:10:04 CEST'
[  132.548020] TEST-53-TIMER.sh[16445]: ++ date '--date=Tue 2025-10-14 22:10:04 CEST' +%s
[  132.550218] TEST-53-TIMER.sh[384]: + NEXT_ELAPSE_REALTIME_S=1760472604
[  132.550218] TEST-53-TIMER.sh[384]: + : 'Next elapse timestamp should be Tue 2025-10-14 00:10:00 CEST <= Tue 2025-10-14 22:10:04 CEST <= Tue 2025-10-14 22:10:00 CEST'
[  132.550218] TEST-53-TIMER.sh[384]: + assert_ge 1760472604 1760393400
[  132.550555] TEST-53-TIMER.sh[16446]: + set +ex
[  132.550702] TEST-53-TIMER.sh[384]: + assert_le 1760472604 1760472600
[  132.550832] TEST-53-TIMER.sh[16447]: + set +ex
[  132.551091] TEST-53-TIMER.sh[16447]: FAIL: '1760472604' > '1760472600'

Here the original next elapse timestamp was Tue 2025-10-14 00:10:00 CEST
as expected, but it was overridden by the rebased timestamp:
Tue 2025-10-14 00:10:56 CEST. And when a new randomized delay was added
to it (21h 59min 7.955828s) the final next elapse timestamp fell out of
the expected window, i.e. Tue 2025-10-14 00:10:00 (scheduled time) <
Tue 2025-10-14 22:10:04 CEST (rebased elapse timestamp + randomized
delay) < Tue 2025-10-14 22:10:00 CEST (scheduled time + maximum from
RandomizedDelaySec=, i.e. 22h).

By limiting the timestamp rebase only the case where the unit hasn't
already run should prevent this from happening during daemon-reload.
2025-10-14 16:12:10 +02:00
Nick Labich
1df624422a vmspawn: Use virtio-blk-pci for extra drives
Fixes #39262
2025-10-14 16:09:51 +02:00
Zbigniew Jędrzejewski-Szmek
770170fa62 Revert "meson: fail build when encountering unused variables"
This reverts commit e1e1ef09f9.

This change was misguided. The warning is enough during development and will
get fixed, but turning this into a hard failure just makes WIP harder. Also, a
hard error increases the likelyhood of a build failure in scenarios where
somebody is disabling components (as seen e.g. in
ba8801a076). We already are not very good at
keeping our codebase compile correctly as it ages, because of changes in
compilers and dependencies, and we should not go out of our way to increase the
probability of failure. Such scenarios are painful for downstream builds.
2025-10-14 14:40:09 +02:00
Zbigniew Jędrzejewski-Szmek
c3f32b941b meson: stop probing for paths of programs in /usr/sbin
We dropped support for split-usr a while ago, which means that the programs
will be in /usr/sbin, which actually may be the same as /usr/bin on merged-bin
systems. So the whole checking is mostly pointless in the usual case. OTOH, on
Nix the paths will be totally different and need to be set through the option
anyway. So save time during builds by using the "fallback" path unless the
option is specified.

This avoid some busywork during the slow serial build phase.
2025-10-14 14:39:45 +02:00
Daan De Meyer
a2890ce3e0 varlink: Always link to documentation for current version 2025-10-14 13:14:23 +02:00
Lennart Poettering
86d9498c8c libsystemd: drop "const" decorators on public inline functions
The point of the "const" attribute is to give the compiler hints about
behaviour of functions if it only has the function prototype but no body
around. But inline functions are the ones where the compiler *always*
has the body around, hence the "const" decorator is really just noise:
the compuler can determine the constness on its own, just by looking at
the code.

Hence, drop the decorators, it's just noise. And a source of errors, as
675fa49f69 has shown.

Follow-up for: #39289
2025-10-14 13:08:57 +02:00
Lennart Poettering
e5dc514277 nspawn: register containers in both user and system machined if applicable (#39145) 2025-10-14 11:58:29 +02:00
Lennart Poettering
a7c8f92d1f importd: port untarring logic over to libarchive
This way we have can expose identical behaviour everywhere, can make use
of our atomic replacement calls, and openat() logic, and later apply
additional tracks while unpacking, such as putting limits on UID ranges
and similar.
2025-10-14 11:56:45 +02:00
Lennart Poettering
8be204df2b stat-util: add fd_verify_symlink() helper 2025-10-14 11:21:46 +02:00
Lennart Poettering
90fae0b46c stat-util: add helper inode_type_can_hardlink() 2025-10-14 11:21:46 +02:00
Lennart Poettering
b2fa6d0945 xattr: add helper that detect special purpose xattrs 2025-10-14 11:21:46 +02:00
Lennart Poettering
fec0f699a2 dissect image policy tweaks (#39168) 2025-10-14 10:25:34 +02:00
Mike Yuan
cb1c039fbc core/service: properly handle freezer action -> watchdog propagation (#39222) 2025-10-14 00:49:12 +02:00