Commit Graph
81109 Commits
Author SHA1 Message Date
Arian van Putten 10819eb0d5 vmspawn: fix grow_image: Assertion `path' failed.
arg_image might be NULL (e.g. when booting a USI, or when passing -D)
2025-05-02 11:05:06 +02:00
Arian van Putten f17247c701 vmspawn: don't use vmgenid on aarch64 as it's not supported
fixes:

```
qemu-kvm: -device vmgenid,guid=5f303a47-6fae-4dd7-969c-6c1ea61e816e: 'vmgenid' is not a valid device model name
```
2025-05-02 11:05:06 +02:00
dependabot[bot] 776f8112dc build(deps): bump softprops/action-gh-release from 2.2.1 to 2.2.2
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.2.1 to 2.2.2.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda...da05d552573ad5aba039eaac05058a918a7bf631)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.2.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-01 19:34:28 +09:00
dependabot[bot] 4f0d2d2f9a build(deps): bump redhat-plumbers-in-action/gather-pull-request-metadata
Bumps [redhat-plumbers-in-action/gather-pull-request-metadata](https://github.com/redhat-plumbers-in-action/gather-pull-request-metadata) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/redhat-plumbers-in-action/gather-pull-request-metadata/releases)
- [Commits](https://github.com/redhat-plumbers-in-action/gather-pull-request-metadata/compare/17821d3bc27c1efed339595898c2e622accc5a1b...5da2967931dd7c4b9ccd22f49b045e2c1f05165b)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/gather-pull-request-metadata
  dependency-version: 1.8.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-01 19:34:12 +09:00
Yu Watanabe 58096d7338 various: convert more readers of /proc/ to plain read_full_file() (#37299)
Continuation of #36734

Apparently I was wrong about everything under `/proc/` being seq_file,
but at least there're some more to convert and we can leverage our
helper func while doing so.
2025-05-01 15:28:34 +09:00
Mike Yuan e0c4b80fb0 audit-util: use read_full_virtual_file()
Conversely this one is "raw" file, but let's switch to
static inline helper for it.
2025-05-01 13:10:26 +09:00
Mike Yuan 42dbe9d6b9 rlimit-util: use read_full_file() for /proc/PID/limits
This one uses "seq_file", i.e. normal FILE stream just works.
2025-05-01 13:10:26 +09:00
Mike Yuan 36b159ab3f sd-bus/bus-creds: use plain read_full_file() for process cmdline
This one uses "seq_file", i.e. normal FILE stream just works.
2025-05-01 13:10:26 +09:00
Mike Yuan d6c8e0ce95 process-util: use procfs_file_get_field() where appropriate 2025-05-01 13:10:26 +09:00
Mike Yuan 5fd63a5a5e process-util: introduce procfs_file_get_field() wrapper
which combines procfs_file_alloca() and get_proc_field()
2025-05-01 13:10:26 +09:00
Mike Yuan 3589d6c01f process-util: assert on pid in procfs_file_alloca(), use strjoina() 2025-05-01 13:10:26 +09:00
Mike Yuan d1313fea9b mountpoint-util: use get_proc_field() 2025-05-01 13:10:26 +09:00
Mike Yuan d2c4df9e48 pidfd-util: use get_proc_field() for pidfd_get_pid_fdinfo() 2025-05-01 13:10:26 +09:00
Mike Yuan 15036f8555 fileio: modernize get_proc_field()
- Drop effectively unused "terminator" param, imply whitespace
- Make ret param optional
- Return ENODATA if the requested key is not found, rather than
  ENOENT
- Turn ENOENT -> ENOSYS if /proc/ is not mounted
- Don't skip whitespaces before ':', nothing needs this handling
  anyways
- Remove the special treatment for all "0"s. We don't actually
  use this for capabilities given pidref_get_capability() exists
- Switch away from read_full_virtual_file() - files using "field"
  scheme under /proc/ seem all to be "seq_file"s (refer to
  da65941c3e for details on file types)
2025-05-01 13:10:26 +09:00
Mike Yuan 2a2531b6c7 socket-activate: drop unused accept param for open_sockets() 2025-05-01 13:10:26 +09:00
Luca Boccassi 2044454548 sd-stub: fix assertion failure when cleaning up initrd pages
When linux_exec() fails, the initrd pages cleanup attempts to run,
and an assertion is triggered:

../src/boot/linux.c:125@linux_exec: Error loading kernel image: Security violation
../src/boot/util.h:81@cleanup_pages: Error freeing pages: Not found
../src/boot/log.c:30@efi_assert: systemd-boot: Assertion 'r == EFI_SUCCESS' failed at ../src/boot/util.h:82@cleanup_pages, halting.

(log message is new)

This was introduced by https://github.com/systemd/systemd/pull/36715

Before that change, given the argument to xmalloc_pages() was passed as EFI_SIZE_TO_PAGES(n_pages), that's
what ended up in Pages.n_pages. After this change, n_pages gets assigned without being transformed by
EFI_SIZE_TO_PAGES, so the cleanup can find them again. That change causes the assertion failure to trigger.
Changing this to .n_pages = EFI_SIZE_TO_PAGES(n_pages) fixes the assertion.

Follow-up for c5a5046792
2025-05-01 13:09:21 +09:00
Daan De Meyer 40e0342e60 resolve: Simplify and optimize meson file
We were compiling the same resolved sources over and over again (up to
10 times) which had a substantial effect on build times. Let's make sure
we only compile the resolved sources once by having one static library
containing the objects for all the resolved sources.

While we're at it, get rid of unnecessary variables and includes in the
resolve meson file and generally clean things up a bit.

Before (recorded with ClangBuildAnalyzer):

**** Time summary:
Compilation (1823 times):
  Parsing (frontend):          675.5 s
  Codegen & opts (backend):     81.6 s

After:

**** Time summary:
Compilation (1585 times):
  Parsing (frontend):          553.6 s
  Codegen & opts (backend):     70.7 s
2025-05-01 12:23:43 +09:00
Luca Boccassi df48013586 mkosi: update debian commit reference to 9c54c974f07038bf6737fa02d78f20d340107f5c
* 9c54c974f0 d/systemd-resolved.install: install new socket units for upstream profile
2025-05-01 12:22:50 +09:00
Nick Rosbrook 0e0d3ed93a networkd-test: stop resolved socket units in setUpModule()
Avoid warnings about the socket units when stopping systemd-resolved.
2025-05-01 01:52:28 +01:00
Yu Watanabe 366dd4a662 wait-online: handle varlink connection errors while waiting for DNS (#37283)
Currently, if systemd-networkd-wait-online is started with --dns, and
systemd-resolved is not running, it will exit with an error right away.
Similarly, if systemd-resolved is restarted while waiting for DNS
configuration, systemd-networkd-wait-online will not attempt to
re-connect, and will potentially never see subsequent DNS
configurations.

Improve this by adding socket units for the systemd-resolved varlink
servers, and re-establish the connection in systemd-networkd-wait-online
when we receive `SD_VARLINK_ERROR_DISCONNECTED`.
2025-05-01 01:55:04 +09:00
Luca Boccassi b16e6fd767 busctl: validate argvs on get-property/set-property too
Otherwise passing invalid data means asserts get hit instead of
handling it gracefully. Other verbs already do the same checks.

busctl get-property org.freedesktop.systemd1 '*' org.freedesktop.systemd1.Manager Version
Assertion 'object_path_is_valid(path)' failed at src/libsystemd/sd-bus/bus-message.c:562, function sd_bus_message_new_method_call(). Aborting.
Aborted (core dumped)
2025-05-01 01:53:08 +09:00
Yu Watanabe da9d75e0c6 TEST-17: drop unnecessary $PATH setting
My local setting was unintentionally inserted by the commit
7cb4508c5a.
2025-05-01 00:27:51 +09:00
Nick Rosbrook 3ea04a9432 test: add a test for resolved and wait-online interactions
Specifically, add a test case that ensures systemd-networkd-wait-online --dns
is robust against (a) systemd-resolved absence, and (b) systemd-resolved
restarts.
2025-04-30 11:12:15 -04:00
Nick Rosbrook 5e67cb3bed wait-online: attempt to re-connect after varlink disconnects
Now that systemd-resolved has socket activation for it's varlink
sockets, this should should be enough to make the DNS configuration
logic robust against systemd-resolved stops and restarts.
2025-04-30 11:12:15 -04:00
Nick Rosbrook 0fa188307b resolved: support socket activation via varlink sockets
Add two new socket units, one for each of systemd-resolved's varlink
servers:

 systemd-resolved-varlink.socket
 systemd-resolved-monitor.socket

Add logic to grab socket fds via sd_varlink_server_listen_name(), but
fallback to the existing sd_varlink_server_listen_address() calls if no
fds were given.

This will be used to make systemd-networkd-wait-online --dns more robust
against systemd-resolved restarts etc.
2025-04-30 11:12:15 -04:00
Yu Watanabe 9142bd5a8e network/ndisc: drop only default gateway via the host when a neighbor announcement without router flag is received
A host can send Router Advertisements (RAs) without acting as a router.
In such cases, the lifetime of the RA header should be zero, but may
contain several options, and clients can configure addresses, routes,
and so on with the message. The host may (should?) send Neighbor
Announcements (NAs) without the router flag in that case.

So, when a NA without the router flag is received, let's not drop
configurations based on the previous RA options, but only drop the
default gateway configured based on the RA header.

See RFC 4861 Neighbor Discovery in IPv6, section 6.3.4:
https://www.rfc-editor.org/rfc/rfc4861#section-6.3.4:~:text=%2D%20The%20IsRouter%20flag,as%20a%20host.
> - The IsRouter flag in the cache entry MUST be set based on the Router
>   flag in the received advertisement. In those cases where the IsRouter
>   flag changes from TRUE to FALSE as a result of this update, the node
>   MUST remove that router from the Default Router List and update the
>   Destination Cache entries for all destinations using that neighbor as
>   a router as specified in Section 7.3.3. This is needed to detect when
>   a node that is used as a router stops forwarding packets due to being
>   configured as a host.

Fixes a regression caused by 87a33c0740 (v256).
Fixes #37198.
2025-04-30 22:17:03 +09:00
Yu Watanabe ad6563c766 sd-bus,busctl: introduce sd_bus_message_dump_json() and use it (#37266) 2025-04-30 22:16:14 +09:00
Yu Watanabe e95aebef1f network,udev: several fixlets for setting up SR-IOV VFs (#37269)
Closes #37257 and #37275.
2025-04-30 22:14:41 +09:00
Yu Watanabe 8305cd5640 network/tuntap: verify User=/Group= earlier and refuse non-system users/groups (#37294)
Similar to #36123.
Closes #37279.
2025-04-30 22:12:56 +09:00
Yu Watanabe 940441b44c network/tuntap: deny non-system users/groups from owning Tun/Tap interfaces
This is analogous to #36123, but for Tun/Tap interfaces created by
systemd-networkd.

If a regular user account want to control a Tun/Tap interface, then
assign the interface to a system group, e.g., vpn, and add the user
to the group.

Closes #37279.
2025-04-30 20:31:00 +09:00
Yu Watanabe 1fae13fbec network/tuntap: verify User=/Group= settings earlier
and ignore the settings if we cannot find the specified user/group.

This also replaces get_user_creds()/get_group_creds() with
userdb_by_name()/groupdb_by_name().
2025-04-30 20:30:34 +09:00
Nick Labich 52e2a24216 sysext: Include index=off in overlay mount options
Enable reuse of upper/work dirs with different lower layer paths.

Fixes https://github.com/systemd/systemd/issues/37245
2025-04-30 13:14:42 +02:00
Yu Watanabe 7aef80e0bd sd-bus/bus-dump,busctl: downgrade log level in sd_bus_message_dump(), and log in the caller side 2025-04-30 19:40:39 +09:00
Yu Watanabe 46fcdc3d73 sd-bus/bus-dump: several coding style cleanups 2025-04-30 19:40:39 +09:00
Yu Watanabe 3e45c68aba busctl: split out bus_message_dump()
No functional change, just refactoring.
2025-04-30 19:40:39 +09:00
Yu Watanabe 0c111392fd sd-bus: introduce sd_bus_message_dump_json()
We have already expose sd_bus_message_dump(). Let's also expose how
we convert dbus message into json format in busctl.
2025-04-30 19:40:37 +09:00
Lennart Poettering 71c4b42efc sd-varlink: enforce some queuing limits + document associated api functions (#37289) 2025-04-30 12:19:21 +02:00
Daan De Meyer d62017b5a1 Add our own <netinet/in.h> and <net/if.h> headers and sort includes tree-wide with clang-format (#37278) 2025-04-30 10:42:57 +02:00
Lennart Poettering 82da05e7ef TODO 2025-04-30 10:34:44 +02:00
Lennart Poettering 034c5ac01f man: fix include line in sd_varlink_set_description() man page 2025-04-30 10:34:44 +02:00
Lennart Poettering 5b5c6826ba man: document sd_varlink_send() 2025-04-30 10:34:44 +02:00
Lennart Poettering 667fd5a9ec sd-varlink: put a limit on queued outgoing messages
This is only a safety net for runaway programs: it puts a limit on
outgoing messages, i.e. not on resources accessible directly from
outside, but only on resources taken by trusted local code.
2025-04-30 10:34:44 +02:00
Lennart Poettering b302a6bae5 man: document sd_varlink_push_fd() 2025-04-30 10:34:44 +02:00
Lennart Poettering 92c52a9ba6 sd-varlink: refuse accepting more than 253 fds to send along with a Varlink message
253 is the max number of fds one can send at once on a Linux AF_UNIX
socket. Hence refuse to send more early.
2025-04-30 10:34:44 +02:00
Lennart Poettering a4c81a6509 docs: add more markdown markup to UIDS_GIDS.md 2025-04-30 10:33:53 +02:00
Daan De Meyer 1cf40697e3 tree-wide: Sort includes
This was done by running a locally built clang-format with
https://github.com/llvm/llvm-project/pull/137617 and
https://github.com/llvm/llvm-project/pull/137840 applied on all .c
and .h files.
2025-04-30 09:30:51 +02:00
Daan De Meyer b773143708 clang-format: Disable for src/basic/include/linux
We shouldn't try to format these headers, so add a custom .clang-format
that disables formatting for the directory.
2025-04-30 09:30:33 +02:00
Daan De Meyer 5eaf4c1006 clang-format: Add include sorting directives
Let's make sure clang-format sorts includes according to our style
guide.
2025-04-30 09:30:33 +02:00
Daan De Meyer becc0256d8 resolve: Remove unnecessary ENABLE_DNS_OVER_TLS check 2025-04-30 09:30:14 +02:00
Yu Watanabe 371005ac98 network,udev: configure SR-IOV VF attribute one-by-one
When a [SR-IOV] section has no setting, e.g.
```ini
[SR-IOV]
VirtualFunction=0
```
then the kernel previously replied -EINVAL, as we send a rtnl message
with an empty IFLA_VF_INFO container.
See See do_setvfinfo() in net/core/rtnetlink.c of the kernel.

When a [SR-IOV] section that has an unsupported settings by the
interface driver, then previously the kernel partially applied
settings and returned -EOPNOTSUPP. E.f.
```ini
[SR-IOV]
VirtualFunction=0
LinkState=auto
Trust=true
MACAddress=02:01:00:3e:61:34
```
and the interface does not support configuring the link state, then
the MAC address is assigned, but the trust is not applied:
```
enp3s0f0: Failed to configure SR-IOV virtual function 0, ignoring: Operation not supported
    vf 0     link/ether 02:01:00:3e:61:34 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off
```

To fix such issues, this makes networkd/udevd send each attribute
for VF one-by-one.

Fixes #37257 and #37275.
2025-04-30 15:47:19 +09:00