Commit Graph
81574 Commits
Author SHA1 Message Date
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
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.andLuca Boccassi 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
Yu Watanabe d766c75acd units: kill only udev services and keep udev sockets on switching root
This also makes initrd-cleanup.service explicitly start
initrd-switch-root.service with replace-irreversibly mode, to avoid
systemd-udevd.service being triggered by kernel events and the start
job of initrd-switch-root.service being cancelled.

Follow-ups for 676fb42aae.
Addresses https://github.com/systemd/systemd/pull/37374#issuecomment-2875990471.
2025-05-17 12:47:52 +01:00
Mike Yuan 13cb664181 terminal-util: restore terminal settings if fd_reopen() fails
Follow-up for a0c314d6b0
2025-05-17 12:33:26 +01:00
Lennart Poettering e7ce9e0954 sd-bus: drop a bunch of 'else'
With the new US taxes on bits and bytes let's reduce our footprint a
bit.
2025-05-17 00:18:24 +02:00
Yu Watanabe 7c087d802f Remove overzealous checks (#37493) 2025-05-17 01:37:18 +09:00
Zbigniew Jędrzejewski-Szmek f4bdf373c5 basic/terminal-util: simplify output param handling
Those static functions were written to support optional output params, but they
are only ever called with the output param set, and it doesn't make sense to
ever call them without the output param. Since those are internal functions,
drop this unused complexity.
2025-05-16 15:33:50 +02:00
Zbigniew Jędrzejewski-Szmek 5b5545f112 basic/terminal-util: drop 'U' suffix
C automatically casts a signed int to unsigned in binary operation with an
unsigned int. Thus that suffix is not useful. Also surrounding code doesn't use
it.
2025-05-16 15:33:10 +02:00
Zbigniew Jędrzejewski-Szmek 5ecd641ac8 src/boot: assume that intmax_t is the biggest integer
Same as in 81d7934882, intmax_t by definition is
the widest int. Strictly speaking, the check whether
  sizeof(intmax_t) == sizeof(long long)
in the code below is redundant, but I think it's nicer to keep it for symmetry
with the other cases.

Requested in
https://github.com/systemd/systemd/pull/37442#pullrequestreview-2840906908.
2025-05-16 15:31:58 +02:00
Yu Watanabe a31edb4e71 TEST-07-PID1: drop journal message flood test
This partially reverts f9b186c21a.

The test case is unstable, and fills debugging logs after journald
is restarted.
2025-05-16 22:24:54 +09:00
Lennart Poettering fbf43297dd man: reword recommendations around Accept=
Accept=yes has very valid usecases (i.e. for sporadically invoked
services) and strong benefits (i.e. better security because connections
can be sandboxed nicely, isolating them). Let's hence reword things and
stop claiming that Accept=yes was a legacy thing, because it really
isn't.

Some other man fixes, too
2025-05-16 21:47:46 +09:00
Lennart Poettering 59276b86dc catalog: add more entries
While message IDs are about more than catalog entries (they make
messages recognizable), I think it makes sense to document at least all
those messages that indicate problems with catalog entries, in an
attempt to be helpful to users.

Fixes: #36201
2025-05-16 21:45:25 +09:00
Lennart Poettering b177095bfa terminal-util: explicitly reset cursor
Apparently there are terminals where our usual reset is not enough to
turn the cursor back on. Hence do so explicitly.

Fixes: #22168
2025-05-16 21:42:32 +09:00
Daan De Meyer 96b9d4162f bpf-link: Add HAVE_LIBBPF check
Fixes compilation error in userns-restrict.c where we try to include
libbpf.h when it is not available.
2025-05-16 21:36:15 +09:00
AsciiWolf b2ef1818e6 hwdb: add missing PLUTO SDR vendor name 2025-05-16 19:46:11 +09:00
Yu Watanabe 8e958263d0 man/systemctl: fix typo
Follow-up for 652e4dd743.
2025-05-16 17:49:14 +09:00
Yu Watanabe ed3dce108d varlink: fix typo
Follow-up for 736349958e.
2025-05-16 17:47:54 +09:00
Yu Watanabe bfc8941098 journalctl: fix typo
Follow-up for d2f45c7681.
2025-05-16 17:46:20 +09:00
Lennart Poettering 645e35633f Clean up includes (#37467)
Split out of #37344 

More small components that shouldn't be all too controversial.
2025-05-16 10:07:19 +02:00
Lennart Poettering 22b5ddb90f tree-wide: fix use of flink_tmpfile()
Let's always make sure the temporary file returned by fopen_tmpfile()
and friends is removed on failure (via _cleanup_). Conversely, make sure
that once the file is renamed into its final place, we no longer try to
remove the temporary file (since it's not going to exist anymore).
2025-05-16 08:28:42 +02:00
Eisuke Kawashima b9df3d6447 shell-completion: improve completion of systemd-tmpfiles 2025-05-16 14:04:09 +09:00
Lennart Poettering edecb56216 man: document how to hook stuff into system wakeup
Fixes: #6364
2025-05-15 22:01:12 +01:00
Daan De Meyer ef10d4b526 Bugprone argument comment - round 5 (#37481) 2025-05-15 20:33:50 +02:00