Commit Graph
56114 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 4abf3694dd Several fixlets for Varlink IDL (#38809) 2025-09-04 14:41:29 +02:00
Yu Watanabe d8af104fb0 ethtool-util: fix setting advertising link modes
Fixes a regression caused by d307410327.

The link_mode_masks flex array in struct ethtool_link_settings contains
three packed arrays, and the length of each array is given by
link_mode_masks_nwords field:
```
        __u32   link_mode_masks[];
        /* layout of link_mode_masks fields:
         * __u32 map_supported[link_mode_masks_nwords];
         * __u32 map_advertising[link_mode_masks_nwords];
         * __u32 map_lp_advertising[link_mode_masks_nwords];
         */
```
Hence, we cannot use the received data as is through the union, but need
to shift the array to make each map accessible through the union.
2025-09-04 12:57:10 +02:00
Yu Watanabe 13852e1914 network: remove unnecessary fd saved in fd-store
Fixes the following warning:
```
[  130.968170] H systemd-networkd[4288]: Restart operation initiated.
[  130.968265] H systemd-networkd[4288]: Serializing...
[  130.968274] H systemd-networkd[4288]: There is nothing to serialize.
(snip)
[  130.978756] H systemd[1]: Stopped systemd-networkd.service.
(snip)
[  130.991407] H systemd[1]: Starting systemd-networkd.service...
(snip)
[  131.077440] H systemd-networkd[4318]: Enumeration completed.
[  131.077471] H systemd-networkd[4318]: Deserializing...
[  131.077491] H systemd-networkd[4318]: Failed to parse json (line=0, column=0): No data available
[  131.077524] H systemd-networkd[4318]: Failed to deserialize the previous invocation, ignoring: No data available
```
2025-09-04 19:50:28 +09:00
Yu Watanabe 2ce397125f core/varlink: do not call io.systemd.oom.ReportManagedOOMCGroups() with empty "cgroups" parameter
Fixes the following varlink IDL validation error:
```
systemd-oomd[1687]: varlink-11-11: Parameters for method io.systemd.oom.ReportManagedOOMCGroups()
  didn't pass validation on field 'cgroups': No anode
```
2025-09-04 19:50:28 +09:00
Yu Watanabe f36f374447 core/varlink: do not send unrealized cgroups to oomd
Follow-ups for 23ac08115a.

Since the commit, the cgroup path is set only when it is realized.

Fixes the following varlink IDL validation failure:
```
systemd-oomd[1687]: Varlink-IDL: Mandatory field 'path' is null or missing on object, refusing.
```
2025-09-04 19:50:12 +09:00
Yu Watanabe 83cfc45dfb hostname: add missing varlink IDL fields
Follow-up for bc60034f43.
2025-09-04 18:15:33 +09:00
Yu Watanabe ce631ae3d9 bootctl: add missing varlink IDL entries
Follow-up for f2751d757f.
2025-09-04 18:15:33 +09:00
Yu Watanabe b10619484d Cleanups for test/units directory (#38807) 2025-09-04 18:11:27 +09:00
Yu Watanabe 2ddeb2adfd install: follow-up for initrd presets (#38790)
Follow up for 4a8c395167.
2025-09-04 18:03:21 +09:00
Daan De Meyer 67573e8b8b repart: add test case for btrfs specific options and MountPoint=, and update man page (#38756)
Closes #38749.
2025-09-04 09:00:09 +02:00
Daan De Meyer af5dde2097 core/transaction: fix issue in dropping unmergeable jobs (#38776)
Fixes #38765.
2025-09-04 08:57:59 +02:00
Daan De Meyer 41ae31a9ac install: Fall back to system presets if there are no initrd presets
We might be operating with a newer systemctl on an image with older
systemd and thus without an initrd-preset directory. Before
4a8c395167, we would use the system
presets, let's make sure we keep doing that if we're operating on an
image without initrd presets.

Follow up for 4a8c395167.
2025-09-04 08:55:40 +02:00
Daan De Meyer c8e1e5814f install: Coding style fixlet 2025-09-04 08:42:32 +02:00
Yu Watanabe 642744b492 test: move test units to their own directories
This also add test cases for verifying loopy.service and friends,
which was added by e66047ff62 but never
used in integration tests.
2025-09-04 14:36:46 +09:00
Yu Watanabe 2ba0eacc6c core/unit: do not load drop-in configs for masked unit files
Otherwise, ExecXYZ= given by drop-ins may be added to a masked unit,
then commands may be unexpectedly executed. For example, if an ExecStop=
is set in a drop-in for a running unit, then 'systemctl mask --now' for
the unit try to invoke the command specified in ExecStop=.

Fixes #38802.
2025-09-04 10:58:33 +09:00
Yu Watanabe 975f27a2b5 repart: fix memleak
Fixes a bug in 1a0541d44c (v256).
2025-09-04 06:52:17 +09:00
Yu Watanabe 5b89cc2a5a test: add test case for issue #38765 2025-09-04 02:05:09 +09:00
Yu Watanabe 811af8d534 core/transaction: first drop unmergable jobs for anchor jobs
As you can see, something spurious happens in the logs below.
```
initrd-switch-root.target: Trying to enqueue job initrd-switch-root.target/start/isolate
systemd-repart.service: Looking at job systemd-repart.service/stop conflicted_by=no
systemd-repart.service: Looking at job systemd-repart.service/start conflicted_by=no
systemd-repart.service: Fixing conflicting jobs systemd-repart.service/stop,systemd-repart.service/start by deleting job systemd-repart.service/stop
initrd-switch-root.target: Fixing conflicting jobs initrd-switch-root.target/stop,initrd-switch-root.target/start by deleting job initrd-switch-root.target/stop
systemd-repart.service: Deleting job systemd-repart.service/start as dependency of job initrd-switch-root.target/stop
```

The two conflicting jobs for systemd-repart.service are initially queued
as the following:
- initrd-switch-root.target has Wants=initrd-root-fs.target, and
  initrd-root-fs.target has Wants=systemd-repart.service (through symlink),
  hence starting initrd-switch-root.target tries to start
  systemd-repart.service,
- systemd-repart.service has Conflicts=initrd-switch-root.target, hence
  starting initrd-switch-root.target tries to stop
  systemd-repart.service.

As similar, interestingly(?) starting initrd-switch-root.target tries to
stop initrd-switch-root.target.

So, now there are at least two pairs of conflicting jobs:
- systemd-repart.service: start vs stop,
- initrd-switch-root.target: start vs stop.

As these jobs are induced by starting initrd-switch-root.target, of course
the most important one is the start job for initrd-switch-root.target.

Previously, as you can see in the logs at the beginning, even if
the start job for initrd-switch-root.target is important, we may first
try to resolve the conflict in systemd-repart.service, and may drop the
stop job for systemd-repart.service even if it is relevant to the start
job of initrd-switch-root.target.

This makes first we solve the pair of conflicting jobs for anchor task.
So the stop job for initrd-switch-root.target is dropped first, and the
induced start job for systemd-repart.service is automatically removed,
thus it is not necessary to solve the conflict in systemd-repart.service
anymore.

This is especially important for services that are enabled both in initrd
and after switching root. If a stop job for one of the service is
unexpectedly dropped during switching root, then the service is not stopped
before switching root, and will never start after that.

Fixes #38765.
2025-09-04 02:04:56 +09:00
Yu Watanabe 9507e118e9 pcrlock: use WRITE_STRING_FILE_LABEL
Fixes #38727.
2025-09-03 11:14:04 +02:00
Matthias Gerstner 1158545ef7 homed: AddSigningKey: only feed data to OpenSSL _after_ Polkit auth
As a hardening measure it makes sense not to process potentially crafted
data in `openssl_pubkey_to_pem()` before we know that the caller is
authorized to perform the action.
2025-08-29 14:49:12 +09:00
Antonio Alvarez Feijoo 3eb590f2b0 tree-wide: avoid logging 2 error messages if table_print_with_pager() fails
`table_print_with_pager()` already calls `table_log_print_error()` internally if
there is an error.
2025-08-28 14:09:50 +02:00
Antonio Alvarez Feijoo 134fde8666 resolvectl: add missing error check
Follow-up for 45817e9245
2025-08-28 14:09:14 +02:00
Luca Boccassi e91bfad241 analyze: fix unit-shell/unit-gdb when target unit has exited
Follow-up for 9a08000d18
Follow-up for ad6e02e7b4
2025-08-28 12:11:45 +01:00
Nick Rosbrook 6d22472089 resolve: re-create link unicast scopes on reload
On reload, resolved does not apply new DNSSEC= (or DNSOverTLS=) settings
on links, because the link unicast scopes are not re-created. However,
the servers and link states are updated correctly, so resolvectl and link
state files do show the new setting, leading users to believe the change
took effect immediately, the same way `resolvectl dnssec` does.

Fix this by freeing all of the link unicast scopes during reload, so
that they are re-created with the new settings in link_allocate_scopes().
2025-08-27 22:33:38 +09:00
Nick Rosbrook 71da422058 resolve: include DNSSEC and DNSOverTLS modes in dumps
This is useful for testing and debugging. E.g., one can examine the
active DNSSEC mode of the scope using:

$ resolvectl show-cache
2025-08-27 22:33:38 +09:00
Yu Watanabe 37d1f1573b bootctl: do not fail on removing unfied kernel image
A boot loader entry for a unified kernel image has
BootEntry.kernel : path to the image relative to ESP or XBOOTLDR,
BootEntry.path   : path to the image.
Hence, these two effectively point to the same file.

Hence, by unlink command, the image is removed by
```
deref_unlink_file(&known_files, e->kernel, e->root);
```
then later tried again by
```
r = chase_and_unlink(e->path, root, ...);
```
and of course it fails with -ENOENT.

Let's ignore the failure there. We already ignore ENOENT on removal
at various places, especially in deref_unlink_file().

Fixes #38706.
Follow-ups for 8702496bfb.
2025-08-26 15:45:44 +02:00
Lennart Poettering 3ef74e44b8 nsresourced: use a hashed rather than a mangled name as fallback
If we are asked to come up with our own name for the namespace to
allocate (because client enabled "mangle"), then we so far created a
randomized name if shortening what was proposed didn't work. This broke
polkit authorization however, because when polkit is in the mix, we
process method calls twice, submitting the polkit request on the first
and then assuming a response is known on the second invocation. But if
we generate a randomized name for the two checks we'll not be ablet to
match up the requests because it's going to be different. Let's fix that
by not using a randomized name, but one hashed from the socket
connection we are processing mixed with the client provided name. This
will ensure that for the same method call we'll generate the same name,
but different calls (i.e. calls with different names on the same socket,
or with any name on any socket) we'll end up with different names,
minimizing chance of collision.

This ensures PK starts to work with nsresourced userns registration when
a bad or no name is specified, which previously would end up in a PK
query loop.
2025-08-26 15:30:39 +02:00
Lennart Poettering 06de39b3bd import-generator: disable timeout for downloaded images
Downloading images can take arbitrary amounts of time, hence disable the
timeout for it.

Inspired by https://github.com/systemd/particleos/issues/80
2025-08-26 15:23:41 +02:00
Yu Watanabe ef72263f06 udev: fix grammar
Follow-up for 7e50402aa3.
2025-08-26 06:00:03 +09:00
Yu Watanabe dac478c44c core: fix typo
Follow-up for b3415f5dae.
2025-08-26 04:54:19 +09:00
Yu Watanabe f78a482393 udev: fix typo
Follow-up for 32333754ae.
2025-08-26 04:49:03 +09:00
Jan Fooken 7bb8e9e82f tmpfiles: don't relabel files in dry run mode
tmpfiles attempts to correct the label of a file during various actions
via the function fd_set_perms().  Currently, said function generally
respects the dry-run mode.  However, it attempts to fix the label of a
given file regardless of the state of said dry-run mode.

This causes problems, because a user could attempt to run tmpfiles with
elevated permissions and dry run enabled, expecting the tool to not
modify their system.  Instead, tmpfiles would falsely relabel a file,
modifying their system.

This commit explicitly checks for when dry-run is enabled and skips the
file relabelling process.  Furthermore, I added logging for both cases.
I found helpful during debugging.  That said, I don't think it's
necessary to use the level LOG_INFO on the dry-run path, as it would
always produce an info log.
2025-08-26 04:07:24 +09:00
Luca Boccassi 9ce6d08196 import-generator: fix crash with no remote string in systemd.pull=
SYSTEMD_PROC_CMDLINE=rd.systemd.pull=raw,machine,blockdev,bootorigin:rootdisk systemd-import-generator

Follow-up for 0c892214f7
2025-08-25 19:08:25 +01:00
Lennart Poettering ce3b12713b nspawn: the second time on_orderly_shutdown() is called userdata is NULL (#38709)
We know that it is, because we set it to NULL in the very same
on_orderly_shutdown() call.
2025-08-25 19:08:01 +01:00
Luca Boccassi 8f6236164c boot: also remember auto-generated entries
Windows/OSX/shell/etc entries are autogenerated, and should be remembered too
as the previous choice, together with Linux ones.

Follow-up for d870ae47b7

Fixes https://github.com/systemd/systemd/issues/38694
2025-08-25 23:45:12 +09:00
Yu Watanabe 64fc4917b9 core/unit: use UNIT_FOREACH_DEPENDENCY_SAFE() at several more places
manager_add_job() -> transaction_add_job_and_dependencies() may update
dependencies when a unit is not loaded yet. Hence, we need to restart
dependency loop in that case.

Follow-up for b7777d0884 (#37465).
Fixes #38676.
2025-08-25 13:41:23 +01:00
Felix Pehla ddc9d2a836 systemd-boot: don't always log NX_COMPAT info
Commit 70b7e03 introduced 3 calls to log_debug() about the presence or
absence of NX_COMPAT support. Since sd-boot does not yet have the
ability to only print messages above a certain loglevel, these will
always be printed, even on top of the configured splash screen. This
commit removes the log_debug() call after a success and only prints
those for missing firmware support if the UEFI should support them in
the first place (i.e. starting with version 2.10).
2025-08-25 13:40:54 +01:00
Yu Watanabe dd712ba9c4 homed: do not print sensitive data when debug logging is enabled 2025-08-21 18:15:44 +09:00
Luca Boccassi 27a1e162a1 Update syscalls tables
ninja -C build update-syscall-tables update-syscall-header
2025-08-20 13:19:51 +01:00
Luca Boccassi e9caf17f63 Revert "resolved: don't wait for TLS close_notify replies unnecessarily"
This change introduced a regression that stops DNSOverTLS from working
after some time. Revert it for now, as there's no fixup available at
the moment.

Fixes https://github.com/systemd/systemd/issues/38509

This reverts commit 4b6dbd4ea5.
2025-08-20 14:04:27 +02:00
Zbigniew Jędrzejewski-Szmek 39a8eb9e32 chase: trigger autofs only when explicitly requested (#38641)
Replaces #38569.
Fixes #38565.
2025-08-20 14:02:45 +02:00
Yu Watanabe 88fce09026 nspawn: fix --link-journal=host with --private-users=pick and friends
Fixes #38611.
2025-08-20 16:17:59 +09:00
Yu Watanabe 045227426e test: fix typo 2025-08-20 16:17:11 +09:00
Yu WatanabeandLuca Boccassi 4279336618 chase: trigger automount only when explicitly requested
Since c5de7b14ae
file searching implies a new mount api syscall by default,
to trigger automounts.

But, this is not necessary in most cases, e.g. when chasing
syspath in sd-device (actually this causes regression in umockdev,
see https://github.com/martinpitt/umockdev/issues/271).
Another example is reading unit files, especially .network files,
as automount may trigger mounting network filesystems...

Also, when this is used in NSS plugins, programs that load the
plugins may fail because of spuriously configured seccomp. See #38565.

Let's not trigger automount by default, and do only when explicitly
requested.

This introduces CHASE_TRIGGER_AUTOFS, and use it in
- service manager,
- bootctl and finding ESP/xbootldr,
- sysupdate,
- mountfsd,
- systemd-mount.

There may be several more places we should trigger automount, but let's
do that later.

Follow-up for c5de7b14ae.
Fixes #38565.
Replaces #38569.

Co-authored-by: Luca Boccassi <luca.boccassi@gmail.com>
2025-08-20 02:32:02 +09:00
Yu Watanabe 9dcd034085 chase: introduce CHASE_NO_SHORTCUT_MASK 2025-08-20 02:24:39 +09:00
Yu Watanabe 2e7d7e929e Revert "chase: invert CHASE_NO_AUTOFS and only set it where needed"
This reverts commit 490aa05ca1.

As commented https://github.com/systemd/systemd/pull/38569#discussion_r2284978273,
the commit makes autofs check bypassed. Before the commit, when
CHASE_NO_AUTOFS is set, we did not shortcut chasing paths, and refused
any autofs mount points in the path. However, with the commit, the flag
was swapped but even when CHASE_AUTOFS is unset, the autofs check may be
skipped.

To fix the issue, rather than swapping the flag, we should introduce
another flag, say CHASE_TRIGGER_AUTOFS. This revert the commit, and in a
later commit, the new flag will be introduced.
2025-08-20 02:15:36 +09:00
Luca Boccassi 1441f2e992 Add padding to sbat section (#38621) 2025-08-19 17:49:07 +01:00
Luca Boccassi 70b7e03ebb sd-stub: use memory proto if available and set kernel memory to RX with NX_COMPAT
When NX_COMPAT gets enabled, firmwares will enforce that executable
memory is either writable or executable.
This needs kernel compatibility, when it will happen the kernel will
have the NX_COMPAT bit set. If it is, set the memory buffer to RO.

Note that this must be undone on failure, as EDK2 in some configurations
overwrites memory ranges that are returned with FreePages() with a
fixed pattern, so if the pages are RO it will crash.

This is only an issue with the new custom PE loader, as LoadImage()
and StartImage() will always do the right thing automatically.

https://microsoft.github.io/mu/WhatAndWhy/enhancedmemoryprotection/
https://www.kraxel.org/blog/2023/12/uefi-nx-linux-boot/

Follow-up for cab9c7b5a4

Fixes https://github.com/systemd/systemd/issues/38545
2025-08-19 17:16:57 +02:00
Luca Boccassi 490aa05ca1 chase: invert CHASE_NO_AUTOFS and only set it where needed
Since https://github.com/systemd/systemd/commit/c5de7b14ae2e08d267d8d75bc88934ac6aa7dcd6
file searching implies a new mount api syscall by default,
to trigger automounts.

This is problematic in NSS plugins, as they are dlopen'ed inside
processes by glibc, for two reasons.

First of all, potentially searching on a networked filesystem
automount could lead to nasty surprises, such as the process
responsible for setting up the network filesystem trying to
search on that same filesystem.

More importantly, the new mount api syscall was never part of
the filesystem seccomp filter that we provide by default, and
given mounting/remounting/bind mounting is one of the possible
ways to bypass sandboxing it is very likely not allowed when
custom filters are used in sandboxed processes, if they don't
need to do these operations otherwise.
The filesystem seccomp mask we provide has been updated, however
this only takes effect on the next restart of a service. When
systemd is upgraded via a package upgrade, the new nss plugin is
installed and will be immediately dlopen'ed by glibc when needed,
without waiting for the process to restart, which means the existing
seccomp filter applies, causing the filter to trigger.
Given it's not really possible for any arbitrary program to
predict which NSS modules glibc will load, given programs do not
configure that and instead nsswitch is set up by the sysadmin,
it's impossible to handle at each process level. It's also not
possible to know when it will be triggered, given the plugin
is not linked in each binary tools like need-restart cannot
even pre-emptively restart services that may be affected.

This means in practice, upgrading from systemd << v258 to >= v258
requires a reboot to avoid either subtle or catastrophic system
failures.

By avoiding to trigger automounts in nss-systemd we can avoid
both issues.

userdb drop-ins are searched for in:

/etc/userdb/
/run/userdb/
/run/host/userdb/
/usr/local/lib/userdb/
/usr/lib/userdb/

none of which are supported as automounts anyway.

Note that this happens only when the userdbd service is not running,
as otherwise nss-systemd will go through the varlink IPC, rather than
doing the searches in-process.

So invert CHASE_NO_AUTOFS to CHASE_AUTOFS and set it in the places where
we do want to trigger automounts, like looking for the ESP.

Follow-up for https://github.com/systemd/systemd/commit/c5de7b14ae2e08d267d8d75bc88934ac6aa7dcd6
Fixes https://github.com/systemd/systemd/issues/38565
2025-08-19 16:48:13 +02:00
Lennart Poettering 265386ba35 importd: accept a single space as SHA256SUMS separator
The SHA256SUMS files provided by https://images.linuxcontainers.org/
are slightly non-conforming, insted of using " *" or "  " as separator
between hash and file name they use " ". Let's accept that too, in the
interest of maximizing compatibility.
2025-08-19 11:49:19 +01:00