Commit Graph

81595 Commits

Author SHA1 Message Date
Jelle van der Waa
dfd496b02e efivars: rename ret -> ret_data
Follow the used argument comment naming.
2025-05-21 10:50:25 +02:00
Jelle van der Waa
26208dd49f dbus-manager: correct argument comment 2025-05-21 10:50:25 +02:00
Jelle van der Waa
d0ae0e4f07 pretty-print: correct argument comment 2025-05-21 10:50:25 +02:00
Jelle van der Waa
d8b9f67e67 treewide: fix header file definitions 2025-05-21 10:50:25 +02:00
Jelle van der Waa
6333b3b88d core: rename p -> parameters 2025-05-21 10:50:25 +02:00
Zbigniew Jędrzejewski-Szmek
138e9f7afb kernel-install/90-loaderentry.install: print message if quiting (#37522)
60-ukify.install prints a message like this, and it is quite useful when
trying to figure out what is going on.
2025-05-21 09:55:27 +02:00
Lennart Poettering
8193066c0f update TODO 2025-05-21 07:13:19 +02:00
Lennart Poettering
18fa37a62c Prettify bootctl status (#37524) 2025-05-21 07:10:07 +02:00
Lennart Poettering
81a1f8eeba resolved: add new "DNS Delegate" concepts (#34368)
Various long standing issues (at least: #5573 #14159 #20485 #21260
#24532 #32022 #18056) have been asking for a way to delegate DNS
resolution of specific domains to very specific DNS servers.

This PR goes a major step towards that goal by adding a new concept "DNS
Delegate" which allows to configure just that. Basically, this adds a
third kind of DNS scope to resolved's logic: besides the per-link and
global DNS scopes there are now also "delegate" scopes, which can be
created by dropping in a new file /etc/systemd/dns-delegate/*.conf. They
carry DNS= and Domains= lines just like the global setting or what the
per-link configuration can carry.

And they are consulted the same way as link DNS scopes are considered,
following the same routing rules.

This allows to configure these DNS delegates statically via drop-in
files as mentioned, and only adds the most basic functionality. Later on
we might want to extend this:

1. Allow dynamic creation of DNS delegates via IPC with lifecycle bound
to IPC client (usecase: installing a DNS delegate that routes traffic to
some DNS-over-TLS server once basic setup is complete).
2. Allow configuration of protocol details per delegate the same way
this is currently allowed per-link.
3. Instead of strictly using DNS as delegation protocol, support an
alternative varlink based protocol (without retransmission problems and
so on) that systemd-machined and similar can implement.

This PR is not complete yet. Lacks docs and tests. Seems to work fine in
my local tests however.

Fixes: #5573
Fixes: #18056
Fixes: #20485
2025-05-21 00:32:07 +02:00
Lennart Poettering
88d2cb3668 test: add simple integration test for delegation feature 2025-05-20 23:00:53 +02:00
Lennart Poettering
89768b601b man: document dns-delegate files 2025-05-20 23:00:53 +02:00
Lennart Poettering
45817e9245 resolvectl: show delegate information, too 2025-05-20 23:00:53 +02:00
Lennart Poettering
5c45b341d3 resolvectl: rework parsing of dns server + search domain bus properties
Let's handle the per-link and the global dns server/search domain
property parsing the same. Let's use a flags field for three separate
booleans, and unify more code.
2025-05-20 23:00:53 +02:00
Lennart Poettering
7928c0e0a1 resolved: add concept of delegating lookups below certain domains to specific DNS servers
This permits configuration of additional "delegates" which ensure that
lookups for certain DNS zones are routed to specific sets of DNS
servers, in addition to the routes we create for each network interface.

For now, this allows only static configuration, but eventually we should
open this up to IPC.

Fixes: #5573 #14159 #20485 #21260 #24532 #32022

(Fixes #32022, because now redundant)
2025-05-20 23:00:03 +02:00
Lennart Poettering
6a198b4382 resolved: add a new DnsScopeOrigin enum, to delcare the "origin" of a DnsScope explicitly
This new enum field is supposed to indicate why a DnsScope came to be.
For now it distinguishes two origins: the "global" one (which is what is
configured in resolved.conf) and "link" ones (which are synthesized for
each link).

The field as is is pretty redundant, the same information can be
determined from whether the .link field is set or not.

This is pretty much just preparation for later commits that add
statically configured additional DnsScopes whose origin shall be encoded
with this.
2025-05-20 22:58:44 +02:00
Lennart Poettering
18bd6a4d11 update TODO 2025-05-20 22:58:17 +02:00
Zbigniew Jędrzejewski-Szmek
5270c085d4 bootctl: prefix all paths with the mountpoint prefix
Continuation of 7851732262 and
5a65d2e535. Absolute paths are always
nicer for the user because it's much easier to figure out where the
file is located. And printing some paths with the prefix and some
without was quite confusing.
2025-05-20 18:20:36 +02:00
Zbigniew Jędrzejewski-Szmek
e187450648 bootctl: rework Boot Loader Entries section in status
Kernels are loaded from two partitions (XBOOTLDR and ESP). In the past this
wasn't always so, but a while ago the docs and the code were updated to load
from both locations. The $BOOT location specifies where to install only. So
rework the status output to print both locations and indicate which one is
$BOOT by appending ", $BOOT".

Also change the section title to "… Locations". We don't show *entries* here,
so the old title could be a bit confusing.

Example:
Boot Loader Entry Locations:
          ESP: /efi (/dev/disk/by-partuuid/31659406-5a17-46ec-8195-0dea1667db58)
     XBOOTLDR: /boot (/dev/disk/by-partuuid/4f8a8fe9-4b45-4070-9e9b-a681be51c902, $BOOT)
        token: fedora
2025-05-20 18:20:28 +02:00
Yu Watanabe
caecff5fa2 meson: fix executable name in comment
Follow-up for e4b4a9b677.
2025-05-20 23:11:12 +09:00
Luca Boccassi
27ffdb6d9e {pidfd,cgroup}-util: avoid alignment warning when accessing f_handle (#37520)
NetworkManager imports some systemd code, which we then build with
`-Wcast-align=strict`. This results in this warning:

```
../src/libnm-systemd-shared/src/basic/pidfd-util.c: In function 'pidfd_get_inode_id':
../src/libnm-systemd-shared/src/basic/pidfd-util.c:255:41: warning: cast increases required alignment of target type [-Wcast-align]
  255 |                                 *ret = *(uint64_t*) fh.file_handle.f_handle;
      |                                         ^
```

Since the address of `f_handle` should always be aligned at the word
boundary (it is preceded by 2 int`s` in `file_handle`), this patch uses
`CAST_ALIGN_PTR()` to avoid this warning.
2025-05-20 14:50:22 +01:00
Luca Boccassi
82d3551fbf repart: add --append-fstab parameter (#37238)
If --generate-fstab=PATH is used, there is the possibility that the
fstab file already exists, making systemd-repart fail.

This commit will add a new --append-fstab= parameter, that will read
the file and merge it with the new generated content.  Using the
comments, the command can separate the automatic-generated section from
the user-provided section, allowing for the next append the replacement
only of the automatic-generated section, keeping the user one.
2025-05-20 14:49:43 +01:00
Zbigniew Jędrzejewski-Szmek
4092f72274 kernel-install: print entry-token path that was not found 2025-05-20 14:41:33 +02:00
Zbigniew Jędrzejewski-Szmek
15ff783013 kernel-install/90-loaderentry.install: print message if quiting because of KERNEL_INSTALL_LAYOUT
60-ukify.install prints a message like this, and it is quite useful when
trying to figure out what is going on.
2025-05-20 14:32:05 +02:00
Matteo Croce
6479204e56 networkd: add test to ensure that untracked addresses are kept
Users can alter the network configuration manually, but networkd should
not interfere with manually set addresses and routes.
2025-05-20 14:14:53 +02:00
Daan De Meyer
1fda0f4cae Various meson improvements (#37510) 2025-05-20 13:44:33 +02:00
Luca Boccassi
6946eed3fa core: Also refresh confext extensions when reloading notify-reload service (#33995)
`ExtensionImages=` and `ExtensionDirectories=` now let you specify
vpick-named extensions; however, since they just get set up once when
the service is started, you can't see newer versions without restarting
the service entirely. Here, also reload confext extensions when you
reload a service. This allows you to deploy a new version of some
configuration and have it picked up at reload time without interruption
to your workload.

Right now, we would only reload confext extensions and leave the sysext
ones behind, since it didn't seem prudent to swap out what is likely
program code at reload. This is made possible by only going for the
`SYSTEMD_CONFEXT_HIERARCHIES` overlays (which only contains `/etc`).

This PR:
- Adjusts `service.c` to also refresh extensions when needed. 
- Adds integration tests to check that a confext reload actually
occurred.
- Adds to the `systemd.exec` man pages to document this behavior.

This is a follow up to #24864 and #31364. Thank you to @bluca and
@goenkam for help in getting this up.
2025-05-20 11:27:34 +01:00
Luca Boccassi
bcbf96a805 mkosi: update debian commit reference to b0bbe045f41789845ecf591fd29f50c564034104
* b0bbe045f4 systemd-boot: fix manpages installation
* db46ebd2ec Install new files for upstream build
* 648bfbad0b systemd-homed: add dependency on polkitd
* 5a5f1bd5a3 document requirement to sync *.link files with initrd
* 1f2b663871 d/README.Debian: update some outdated paragraphs
* 03e6ab9c93 Add version to systemd-boot-efi-signed virtual package
* 5d7a08916c d/control: bump Standards-Version to 4.7.2, no changes
* ace9e4beaf d/signing-template/copyright: use GPL URL instead of old FSF postal address
2025-05-20 12:27:10 +02:00
Jan Vaclav
4d2e61211d cgroup-util: avoid alignment warning when accessing f_handle 2025-05-20 12:16:31 +02:00
Jan Vaclav
b900a8d827 pidfd-util: avoid alignment warning when accessing f_handle 2025-05-20 12:07:43 +02:00
Mike Yuan
58f36cfd29 core/cgroup: also assume cgroup.events frozen attr is available (#37518) 2025-05-20 10:58:53 +02:00
Daan De Meyer
5fff57362e meson: Use hyphens everywhere in gperf.c filenames 2025-05-20 10:46:28 +02:00
Alberto Planas
fc0cc3065c repart: add --append-fstab parameter
If --generate-fstab=PATH is used, there is the possibility that the
fstab file already exists, making systemd-repart fail.

This commit will add a new --append-fstab= parameter, that will read
the file and merge it with the new generated content.  Using the
comments, the command can separate the automatic-generated section from
the user-provided section, allowing for the next append the replacement
only of the automatic-generated section, keeping the user one.

Signed-off-by: Alberto Planas <aplanas@suse.com>
2025-05-20 10:32:14 +02:00
Daan De Meyer
d86fead481 meson: Rework clang-tidy integration to be done via unit tests
Instead of using run-clang-tidy.py with its own scheduling, let's
just gather a list of source files ourselves and then use that to
add a unit test for each source file that runs clang-tidy on the
source file.

We also add a bit of logic to run clang-tidy on most header files
as well for extra coverage. This uncovered various header files that
were not standalone so this commit also includes fixes to make sure
the clang-tidy tests are all green.

We can also use this in a later commit to run clang-include-cleaner
on each source file in the same way.
2025-05-20 10:29:59 +02:00
Daan De Meyer
6196e414a5 tree-wide: Ensure source file names are unique
Let's ensure all of our source file names are unique without having
to take the directory into account.

This allows us to create meson targets or unit tests identified by the
the name of the source file they operate on without having to include
the full path of the source file in the target or test name to avoid
conflicts.
2025-05-20 10:29:59 +02:00
Daan De Meyer
b7400b14ed meson: Build fuzz executables by default if fuzz-tests option is enabled
fuzz-tests is enabled by default now but we still don't build the fuzz
executables by default. Let's change that so that we always make sure these
still compile when we make changes.
2025-05-20 10:29:59 +02:00
Daan De Meyer
1fa170b9d2 oss-fuzz: Add comment on why we build with --auto-features=disabled 2025-05-20 10:29:59 +02:00
Daan De Meyer
e4b4a9b677 meson: Make sure fuzz-journal-remote is built in oss-fuzz
oss-fuzz builds with --auto-features=disabled, yet we have to make
sure all fuzzers are still built when --auto-features=disabled, so
let's always build systemd-journal-remote even if it is disabled so
that we can use its objects to build fuzz-journal-remote. Instead,
when remote=disabled, we make sure we don't installed
systemd-journal-remote.
2025-05-20 10:29:58 +02:00
Daan De Meyer
a583b34416 meson: Extract more objects instead of compiling multiple times
Also, let's deflatten the lists of sources in preparation for the
next commit at the same time.

In systemctl, we split out systemctl-main.c to make sure the definition
of main() is in a separate object which allows us to extract the systemctl.c
object and link it in the fuzzer target without getting a multiple definition
error when linking.
2025-05-20 10:29:58 +02:00
Daan De Meyer
691abc5ea8 journal-remote: Allow building without microhttpd support
systemd-journal-remote is useful even if the microhttpd related features
are not enabled so let's not skip it entirely if microhttpd is not available.
2025-05-20 10:29:58 +02:00
Alberto Planas
ba2d8107e2 string-util: add find_line[_after] functions
As a wrapper for `find_line_startswith`, `find_line_after` search for
the exact line and return the pointer for the next line, or NULL if
missing.

`find_line` with search for the exact line and return the pointer to the
beginning of the line.

Signed-off-by: Alberto Planas <aplanas@suse.com>
2025-05-20 10:29:33 +02:00
Mike Yuan
dbe592a067 cgroup-util: modernize cg_get_keyed_attribute()
- assert on supplied keys being unique
- Reject duplicate attributes with -EBADMSG
- Rename 'ret_values' to just 'values', given we don't
  allocate the array
- Remove now unused cg_get_keyed_attribute_graceful()
2025-05-19 21:24:18 +02:00
Mike Yuan
88f4bf8a8b core/cgroup: also assume cgroup.events frozen attr is available
Follow-up for 3c86a935ad
2025-05-19 21:01:39 +02:00
Zbigniew Jędrzejewski-Szmek
791847ea64 boot: fix ia32 build with clang
After 668d915a4b, the build fails:
[7/14] Linking target src/boot/systemd-bootia32.elf
FAILED: src/boot/systemd-bootia32.elf
clang  -o src/boot/systemd-bootia32.elf src/boot/systemd-bootia32.elf.p/boot.c.o src/boot/systemd-bootia32.elf.p/line-edit.c.o src/boot/systemd-bootia32.elf.p/bcd.c.o -Wl,--as-needed -Wl,--no-undefined -pie -fstack-protector src/boot/libefiia32.a -nostdlib -static-pie -Wl,--entry=efi_main -Wl,--fatal-warnings -Wl,-static,-pie,--no-dynamic-linker,-z,text -z common-page-size=4096 -z max-page-size=4096 -z noexecstack -z relro -z separate-code -Wl,-z,nopack-relative-relocs -fcf-protection=none -fno-asynchronous-unwind-tables -fno-exceptions -fno-unwind-tables -fno-sanitize=all -Wno-unused-command-line-argument -m32
/usr/sbin/ld: src/boot/libefiia32.a.p/console.c.o: in function `console_set_mode':
/home/zbyszek/src/systemd-work/build-clang/../src/boot/console.c:267:(.text+0xb8f): undefined reference to `__moddi3'
/usr/sbin/ld: src/boot/libefiia32.a.p/console.c.o: in function `get_auto_mode':
/home/zbyszek/src/systemd-work/build-clang/../src/boot/console.c:228:(.text+0xf18): undefined reference to `__udivdi3'
/usr/sbin/ld: src/boot/libefiia32.a.p/efi-string.c.o: in function `push_num':
/home/zbyszek/src/systemd-work/build-clang/../src/boot/efi-string.c:695:(.text+0x3c1a): undefined reference to `__moddi3'
/usr/sbin/ld: /home/zbyszek/src/systemd-work/build-clang/../src/boot/efi-string.c:696:(.text+0x3c54): undefined reference to `__divdi3'
/usr/sbin/ld: /home/zbyszek/src/systemd-work/build-clang/../src/boot/efi-string.c:702:(.text+0x3cda): undefined reference to `__umoddi3'
/usr/sbin/ld: /home/zbyszek/src/systemd-work/build-clang/../src/boot/efi-string.c:703:(.text+0x3d0a): undefined reference to `__udivdi3'
/usr/sbin/ld: src/boot/libefiia32.a.p/ticks.c.o: in function `time_usec':
/home/zbyszek/src/systemd-work/build-clang/../src/boot/ticks.c:110:(.text+0x9d): undefined reference to `__udivdi3'
/usr/sbin/ld: src/boot/libefiia32.a.p/ticks.c.o: in function `ticks_freq_arch':
/home/zbyszek/src/systemd-work/build-clang/../src/boot/ticks.c:46:(.text+0x394): undefined reference to `__udivdi3'
/usr/sbin/ld: /home/zbyszek/src/systemd-work/build-clang/../src/boot/ticks.c:49:(.text+0x3ce): undefined reference to `__udivdi3'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Restore the use of -lgcc for 32-bit builds.

(FWIW, neither --rtlib=compiler-rt nor --rtlib=libgcc help.)
2025-05-19 16:00:28 +01:00
Daan De Meyer
e53a3f4b40 sd-varlink: Expose sd_varlink_idl_parse() (#37513) 2025-05-19 16:13:44 +02:00
Daan De Meyer
d94c24e9cc sd-varlink: Expose sd_varlink_idl_parse()
We're planning to do code generation based on the systemd varlink
APIs. To simplify this, let's expose the IDL parser, so we can use
it to do code generation instead of having to write our own IDL
parser.
2025-05-19 15:19:24 +02:00
Daan De Meyer
34f714349b sd-varlink: Fix argument names of sd_varlink_idl_parse() 2025-05-19 15:08:16 +02:00
maia x.
67ecc2c7fe man: document confext reload behavior for ExtensionDirectories/Images 2025-05-19 13:36:21 +01:00
maia x.
3998b30a04 test: check reloading notify-reload service refreshes vpick extensions
In TEST-50-DISSECT.dissect, this adds the following cases:
- testservice-50g: vpick extension in ExtensionDirectories
- testservice-50h: vpick extension in ExtensionImages
- testservice-50i: ExtensionDirectories + RootImage
- testservice-50j: ExtensionDirectories + RootDirectory
2025-05-19 13:36:21 +01:00
maia x.
dfdeb0b1cb core: reload confexts when reloading notify-reload services
`ExtensionImages=` and `ExtensionDirectories=` now let you specify
vpick-named extensions; however, since they just get set up once when
the service is started, you can't see newer versions without restarting
the service entirely.  Here, also reload confext extensions when you
reload a service. This allows you to deploy a new version of some
configuration and have it picked up at reload time without interruption
to your workload.

Right now, we would only reload confext extensions and leave the sysext
ones behind, since it didn't seem prudent to swap out what is likely
program code at reload. This is made possible by only going for the
`SYSTEMD_CONFEXT_HIERARCHIES` overlays (which only contains `/etc`).

Implementation wise, this uses the new kernel API and two collaborating
child processes under the host & child namespaces in order to gather the
right FDs needed:

  - (1) In child, set up the extension images and directories in a slave
	mountns, and obtain their FDs.
  - (2) Fork into a grandchild under target process namespace, and do a
        "fake" unmount to obtain the FD of the underlying target folder
	say /etc).
  - (3) In the child again, set up new overlay under host NS rights.

We do not want to do I/O heavy jobs inline in PID1 blocking the state
machine, so add separate async states to handle this case.

Co-authored-by: Luca Boccassi <luca.boccassi@gmail.com>
2025-05-19 13:36:21 +01:00
Mike Yuan
741a184a31 core/manager: do not pop gc_unit_queue before unit_gc_sweep()
Follow-up for 52e3671bf7

unit_gc_sweep() might try to add the unit to gc queue again.
While that becomes no-op as Unit.in_gc_queue is not cleared
yet, it induces minor inconsistency of states.
2025-05-18 05:33:09 +09:00