Commit Graph
100 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek e785d81c1b mkosi: update fedora commit reference to 57cbcf979ce2dd872a871c59e87d2c65dfa996e6
* 57cbcf979c Also enable report-standalone for OBS builds
* d69c17b165 Enable report-standalone for upstream builds
2026-07-07 18:37:12 +02:00
Zbigniew Jędrzejewski-Szmek f731334d84 meson: use modern syntax for dict checks 2026-07-07 13:40:13 +02:00
Zbigniew Jędrzejewski-Szmek 9155c0a5b9 meson: build .standalone versions of the report binaries
The goal is to be allow the use of those binaries on systemd with older
systemd. The report stuff is generally independent of the running systemd
version.

When built with -Dinstall-tests=true -Dstandalone-binaries=true
-Dbuildtype=release -Db_lto=true, gcc-16.1.1-2.fc44.x86_64, the sizes
are quite reasonable:

$ ls -lG build-lto/*.standalone
-rwxr-xr-x 1 zbyszek  713200 Jul  3 13:16 build-lto/systemd-report.standalone
-rwxr-xr-x 1 zbyszek  662936 Jul  3 13:16 build-lto/systemd-report-basic.standalone
-rwxr-xr-x 1 zbyszek  567424 Jul  3 13:16 build-lto/systemd-report-cgroup.standalone
-rwxr-xr-x 1 zbyszek  592856 Jul  3 13:16 build-lto/systemd-report-files.standalone
-rwxr-xr-x 1 zbyszek  589864 Jul  3 13:16 build-lto/systemd-report-sign-plain.standalone
-rwxr-xr-x 1 zbyszek  548624 Jul  3 13:16 build-lto/systemd-report-sign-tsm.standalone
2026-07-07 13:40:13 +02:00
Zbigniew Jędrzejewski-Szmek aad1e61010 meson: adjust naming of '*extract*' variables 2026-07-07 13:40:13 +02:00
Zbigniew Jędrzejewski-Szmek f00ccf93b7 meson: rename extract+objects to export+import
We have two concepts: a list of files that should be extracted from an
intermediate build artifact to be used in a later build artifact, and for a
given artifact, a list "donors". The first list was called "extract", because
it is passed to the .extract_objects() meson function, and the second was
called "objects", because that is the meson parameter to specify pre-built
objects files (6350d2dbd9). But this naming is
confusing: we don't care about the 'extract' step, this is something internal
to the build machinery. And 'objects' is a very generic term.

Let's use 'export' for the stuff that is "exported" for other binaries to use,
and 'import' to say where to import from. Those terms are symmetrical and the
association between them should be intuitive. (If you think the terms are
actually assymetrical, there are precedents for confusing the import with the
import sources. E.g. in modern English, turkeys are called so because they were
imported from the Americas and guineafowls were imported from Africa via
Türkiye and all that foreign stuff is alike.)
2026-07-07 13:40:13 +02:00
Zbigniew Jędrzejewski-Szmek 88b51ff974 meson: move 'conditions' to the end 2026-07-07 13:40:13 +02:00
Zbigniew Jędrzejewski-Szmek 47af1efe40 mkosi: update fedora commit reference to 45c16dd369c961b70664e473552def34d5469664
* 45c16dd369 Use uniform format for %rhel conditionals
* 034fa693f2 Print the build status also in %build
* 3cc7e03365 Restore definitions of helper macros
* 2382c910b7 Disable the standalone report yet again
* 2d6fd95c70 Restore explicit requires for Centos Stream 9 and 10
* 521ab0fb09 test: skip the integration test suite on Fedora ELN (for now)
* 453447b79b rpminspect: ignore test-coredump-stacktrace in annocheck
* 9d4edaa576 test: work around a kernel bug in virtio/vsock
* c53b2fb307 test: cap the number of parallel tests
* 9bd26bb71f Fix ntpvendor for ELN
* de7b685908 Disable reqs for dlopen'ed libraries on CentOS
* 4830641844 Move portabled to systemd-container subpackage
* 893fcd9978 Add missing conditionalization and more debugging
* c783e74791 split-files: improve error message
* ee2dff42d6 Add systemd-report-standalone
* 9c87a3f8ad Load libssl.so.4 rather than libssl.so.3
* 714b0799d2 Version 261.1
* 054158500a Update to load openssl-4 rather than openssl-3
* 5a3e750ef8 Version 261
* 4faee7ab7d Version 261~rc4
* 8ff635a921 Rebuilt for openssl 4.0
* 0064f73d97 Rebuilt for openssl 4.0
* 14a9aac87e Use dlopen notes again
* 720fa8259a Do not check ownership of /var/lib/systemd/timesync/ in rpm -V
* 06bd9926f2 Version 261~rc3
* 6ddbd499e8 Drop unused tree build dependency
* bd81a14bfc Version 261~rc2
2026-07-07 12:33:48 +01:00
Zbigniew Jędrzejewski-Szmek e20ab6642c Assorted libsystemd/network hardening fixes flagged by kres (#42865) 2026-07-07 13:27:57 +02:00
Zbigniew Jędrzejewski-Szmek 977d37f575 tree-wide: add mechanism to detect missing cflags dependencies (#42866) 2026-07-03 17:54:10 +02:00
Zbigniew Jędrzejewski-Szmek 713a2cf79c test-socket-util: convert to new ASSERT macros
Replace assert_se() with the typed ASSERT_* macros throughout, matching
the conversions done across the rest of src/test/.
2026-07-03 15:09:03 +01:00
Zbigniew Jędrzejewski-Szmek 8c4218ab9f core: add all manager timestamps to metrics report (#42842)
These are all very useful for establishing the health of a fleet, so
export them too

Follow-up for 0b0db27050
2026-07-03 10:06:43 +02:00
Zbigniew Jędrzejewski-Szmek 833b8d98e0 NEWS,README: describe embedded files and static linking 2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek 9edf0e839f manager: fall back to direct reboot() if shutdown binary is missing
When PID 1 reaches the shutdown phase, if systemd-shutdown was missing,
it'd complain loudly and freeze. Implement an internal fallback to
handle this case gracefully. The fallback is always in place, since it
makes things generally more robust and is only a little bit of code.

This shutdown is simplified, systemd issues the reboot() matching the
requested objective directly, mirroring what systemd-shutdown would do
as its final step. This skips all the cleanup systemd-shutdown normally
performs (unmounting file systems, detaching storage, killing remaining
processes, switching into the exitrd).

With SYSTEMD_LOG_LEVEL=debug:
...
[  OK  ] Reached target poweroff.target.
Notify message sent to '/run/host/notify': "X_SYSTEMD_UNIT_ACTIVE=poweroff.target"
Shutting down.
OSC sequence for shutdown successfully written: ...
Failed to execute shutdown binary: No such file or directory
Powering off.
Container container has been shut down.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek 83e4074af1 manager: use reboot.target as the default for ctrl-alt-del.target
systemd tries to start ctrl-alt-del.target after receiving a request
to reboot in a container (or when ctrl-alt-del is pressed on a real
machine). If the alias is missing, this will fail. Let's provide a
fallback for this too. I don't think it makes sense to make it
configurable: it seems almost everybody is fine with the default
mapping. If not, people can always just create the symlink in the
filesystem.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek 2e4ef3dca5 core: rename and extend manager_add_job_by_name_and_warn
The "and" in the name was a misnomer. We do one *or* the other.
So rename 's/_and_/_or_/', and extend with the ability to load a second
unit. No functional change.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek 8985fc5e57 manager: try to reexecute as /proc/self/exe too
If we try to reexecute, and the binary was started from a non-standard
path, this would fail:
  src/core/main.c:2396: Reexecuting.
  src/core/main.c:2240: Failed to execute our own binary /usr/lib/systemd/systemd: No such file or directory
Let's make things more robust by trying /proc/self/exe too.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek 7bff0f09fe core: let manager_load_startable_unit_or_warn take a log level
Add a log_level parameter so callers can control the severity of load
failures. During boot, when no unit was explicitly requested on the
kernel command line (arg_default_unit is unset), failing to load the
default unit is not fatal since we fall back to other targets, so log
those attempts at LOG_INFO instead of LOG_ERR. All other callers pass
LOG_ERR to keep their existing behaviour.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek a0146fe807 core: embed essential units as built-in fallbacks
Compile the contents of a few essential target unit files
(graphical.target, multi-user.target, rescue.target, etc.) into the
manager binary, with comments stripped, and fall back to those built-in
copies when no fragment is found on disk. This lets the manager reach a
usable state even on a system that ships none of these unit files, e.g.
in minimal environments or one-off chroots.

On-disk files always take precedence (masks included), as the fallback is
only consulted when nothing is found in the lookup paths. The unit file
list is defined in units/meson.build and embedded via a small generator
script; 'units' is now processed before 'src/core' so the list is
available there.

The set of units and services is selected that should allow for a normal
operation of starting/stopping/restarting, of the machine. The services
all use SuccessAction=…, so they don't require any binaries to be
installed.

sigpwr.target is included, even though it doesn't do anything useful.
The same is true in normal installations. We might want to change it
do something useful there too.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek a809b6e565 core: add fallback-default-target build option
Add a 'fallback-default-target' meson option that configures which unit
to activate when default.target is not installed. This makes things more
resilient in general and is also useful for minimal/statically-linked
installations that may not ship a default.target symlink.

'graphical.target' is used as the default value of the setting, because
that's what we symlink as default.target in units/meson.build.

In the initrd, we had a fallback to start default.target if initrd.target
cannot be started. This fallback is changed to only do that if it is
not found, not on other errors. This seems more correct (and makes
the two fallbacks symmetrical.)
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek fff9c9ba46 meson: allow manager to be linked statically
After stripping, in an unoptimized build with glibc, we get a 8.7 MB binary:
$ file build-static/systemd
build-static/systemd: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=1ec004bf61b775d284d909a818a3c4f63f83f055, for GNU/Linux 3.2.0, stripped
$ ls -lh build-static/systemd
-rwxr-xr-x 1 zbyszek zbyszek 8.7M Jun 30 14:07 build-static/systemd
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek b0dfec9fa4 core: convert exec-invoke to use the new static-friendly functions
The libc API is rather ugly: it requires the caller to pass an
array of the maximum possible size (or to repeatedly query the group
list to discover the actual size). With our "static-friendly" helpers,
we reallocate the array on the fly.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek 50b4f1e3bf shared/creds-util: use getpwuid_malloc()
Static linking, i.e. without dlopen, sometimes fails when getpwuid
is used. I doesn't fail in all cases (glibc version?), so I didn't
do this initially.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek 5c2bd19f40 user-util: add getgrouplist_malloc and initgroups_wrapper 2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek bbeef4b948 various: add -Dbuild-static and alternatives to libc functions
When we try to build with -static, the linker refuses dlopen and
various functions related to nss. This commit adds the basic support
to compile with -static and allow the link to pass.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek b3749de21c user-util: add lookup_groups_in_files 2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek 2c01b4895e user-util: sysconf_ngroups_max
This hides the iffy interface of sysconf(_SC_NGROUPS_MAX) to simplify
the calllers.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek aac88fd8ab user-util: add lookup_pwent_in_files and lookup_grent_in_files
Those functions will be used later. This commits adds the
implementations and tests for them.

glibc functions require ability to open nss modules, which requires
dlopen. Linking will fail if any of the nss-using functions are used.
So the following few commits will provide replacements for all of
them.
2026-07-02 17:19:18 +02:00
Zbigniew Jędrzejewski-Szmek fcb2c6c259 meson: replace -Dbuild-executor-shared=single with -Dsystemd-multicall-binary=true
This effectively reverts the meson config changes introduced in
0c6186695a. I wasn't happy with that form
back when it was commited, and in hindsight, I like it even less. Let's
just add a new option that hopefully is easier to understand and will
work better when new functionality is added in the future.

Now there are two options:
link-executor-shared (boolean, defaults to true)
  — "link (separate) systemd-executor to libsystemd-shared.so and libsystemd-core.so"
systemd-multicall-binary (also boolean, defaults to false)
  — "link systemd+systemd-executor as a single binary"

Build directories will need to be recreated again, sorry!
2026-07-02 16:35:36 +02:00
Zbigniew Jędrzejewski-Szmek 80c92c896a shared/tpm2-util: use a define instead of a const static variable
Let's do the standard thing. The 'static const' variable requires space
and less efficient code (moving from memory instead of a const insertion).
This doesn't matter much, but let's follow the standard pattern.

Follow-up for 93e9c2c974.
2026-06-25 14:43:42 +02:00
Zbigniew Jędrzejewski-Szmek b14acfdab1 Fix: core fixes (#42744)
Some simple code fixes
2026-06-25 14:39:53 +02:00
Zbigniew Jędrzejewski-Szmek 3498b84013 Couple of hardening changes for utils flagged by kres (#42732) 2026-06-25 14:31:35 +02:00
Zbigniew Jędrzejewski-Szmek a0343dabfa core: derive restrict-fsaccess initramfs_s_dev offset from skeleton (#42705)
Fixes #42689.
2026-06-25 11:24:28 +02:00
Zbigniew Jędrzejewski-Szmek 0c6186695a manager: make systemd+executor a multicall binary
Allow systemd-executor to be compiled into a single binary.
The existing -Dlink-executor-shared=true|false is extended to also
allow -Dlink-executor-shared=single (*). The new mode is opt-in,
to allow experimentation and introduce this smoothly.

This saves a little space, but not as much as I expected:
$ ls -l build/{systemd,systemd-executor} build-new/systemd
-rwxr-xr-x 1 zbyszek zbyszek  631520 May 25 22:44 build/systemd
-rwxr-xr-x 1 zbyszek zbyszek  670464 May 25 22:44 build/systemd-executor
-rwxr-xr-x 1 zbyszek zbyszek 1214488 May 25 22:45 build-new/systemd
(This is with -Dbuildtype=debugoptimized -Db_lto=true).
The combined binary is slightly smaller than the sum of the separate
ones, but not much. In both cases, the binaries are linked to
libsystemd-core which is 10MB, so the size of the binaries themselves
doesn't make much of a difference. The executor needs exec-invoke.c
which is huge and not shared with anything else.

Longer term, I want to allow systemd to be linked statically. In
that case, having systemd-executor separate would be very painful.
So the option to use a multicall binary will be necessary.

Previously, we stored the resolved path to systemd-executor and
used it argv[0]. I don't think this was useful. After all, normally
we would use the non-resolved original path as argv[0]. So that
part is dropped, and the resolved path is only logged, but
"systemd-executor" is always used as argv[0]. This makes the
multicall binary work reliably, no matter what the actual file
name is.

(*) This means that compat as the commandline level is maintained:
'meson setup build -Dlink-executor-shared=true …' works as before.
Unfortunately, when using an existing build directory, meson chokes
on the type change and refuses to reconfigure the directory or change
the option or do anything useful. I think meson is DTWT here, but
this is hard to fix. So the build directory probably needs to be
recreated.
2026-06-22 17:19:54 +02:00
Zbigniew Jędrzejewski-Szmek 075036f205 test: drop whitespace after shell redirection operators 2026-06-20 01:41:46 +01:00
Zbigniew Jędrzejewski-Szmek c0da88f8d9 crypto-util: prefer openssl-4
Fedora has switched to openssl 4, and we generate a Requires dependency
on libcrypto for the systemd-udev subpackage, so preferring openssl-3
does the wrong thing. So the order in the dlopen note needs to be switched.
But in general, we want to get rid of openssl-3, so we want to load
openssl-4 in preference. Change the order in both places.

(The "compat" order can stay in 261-stable for other distros.)
2026-06-20 01:39:48 +01:00
Zbigniew Jędrzejewski-Szmek b9f7a76b14 Fix handling of UKI/SBAT and UKI/Firmware config entries. (#42478)
This fixes 2 issues with `ukify`:

`config_list_prepend` needs a list. The 2 more used entries are
specially treated (parsed into a list) and therefore happen to work, but
trying to set `UKI/Firmware` throws a type error, as it is passed as
just a string.

The `UKI/SBAT` config entry is a list but used the default `config_push`
value which sets it if unset (which also failed since its default of
`[]` is not `None`) - change this to `config_list_prepend`.

I did consider adding a `config_list_append`, but as far as I'm aware,
the order of sbat entries should not change the outcome anyway.
2026-06-19 15:16:30 +02:00
Zbigniew Jędrzejewski-Szmek f886dd5ca5 mkosi: update debian/suse commit references (#42628) 2026-06-17 08:44:24 +02:00
Zbigniew Jędrzejewski-Szmek e1c18779bc TODO: add item for btrfs subvolumes in tmpfiles 2026-06-17 00:16:29 +02:00
Zbigniew Jędrzejewski-Szmek bf3d2b03e9 shutdown: do not delay VM shutdown (#42396)
Since this was introduced I constantly find myself waiting for VMs to
shut down at the end of a test. This not only happens with mkosi
integration tests, but with other VM-based tests like for example
autopkgtest. In this example, this dracut test suite runtime is tripled
due to the artificial delay:

```
[    5.813234] systemd-shutdown[1]: Syncing filesystems and block devices.
[    5.814635] systemd-shutdown[1]: Delaying shutdown for 9s, in order to reach minimum uptime of 15s.
[    8.816855] systemd-shutdown[1]: Delaying shutdown for 6s, in order to reach minimum uptime of 15s.
[   11.819747] systemd-shutdown[1]: Delaying shutdown for 3s, in order to reach minimum uptime of 15s.
[   14.822660] systemd-shutdown[1]: Delaying shutdown for 601ms, in order to reach minimum uptime of 15s.
[   15.427777] systemd-shutdown[1]: Powering off.
[   15.429681] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[   15.433620] ACPI: PM: Preparing to enter system sleep state S5
[   15.435148] reboot: Power down
TEST: root filesystem on a ext4 filesystem with systemd and extensions   [OK]
autopkgtest [19:39:12]: test 46-systemd-sysext: -----------------------]
autopkgtest [19:39:13]: test 46-systemd-sysext:  - - - - - - - - - - results - - - - - - - - - -
46-systemd-sysext    PASS
```

Contrary to what the comment claimed, the scrollback of a VM is _not_
cleared, EDK2 just prints many pages, and one can just scroll up (a
lot).

Do not delay by default on VMs. Move the check so that in both
containers and VMs users can override and force a delay with the env
var.

Follow-up for 0874eea302
2026-06-03 16:10:20 +02:00
Zbigniew Jędrzejewski-Szmek fe2b35bd58 repart: when copying files into vfat or similar, do not set ownership
$ mkdir /var/tmp/files
$ touch /var/tmp/files/a
$ mkdir /var/tmp/conf
$ cat >>/var/tmp/conf/esp.conf
[Partition]
Type=esp
Format=vfat
CopyFiles=/var/tmp/files:/
$ truncate /var/tmp/disk -s 300M
$ sudo systemd-repart --dry-run=no --empty=require --definitions=/var/tmp/conf /var/tmp/disk
...
Populating vfat filesystem.
Failed to copy '...' to '/run/systemd/mount-root/': Operation not permitted
(sd-copy) failed with exit status 1.

The issue is that if there's a file owned by non-root and we try to copy
it into a newly-created DOS partition, fchown fails:
  fchown(11</run/systemd/mount-root/...>, 1000, 1000) = -1 EPERM (Operation not permitted)
We want to ignore file ownership in such cases, so pass our own UID/GID
to copy_tree_at(), which turns the fchown into a noop and let's the
operation pass through.

Fixes #38863.
2026-06-03 16:02:58 +02:00
Zbigniew Jędrzejewski-Szmek 230a38ea52 repart: perform an early check for missing mkfs or fs contents
I was running repart in a VM, and if failed because mkfs.vfat was
not available. But if fails quite late in the process, possibly wasting
quite a bit of work. So add a check that catches some obvious cases
where repart would fail.

The condition of whether we have the root directory is complex,
determined in part by partition_target_prepare(). I didn't think it
was worth it to recreate the full logic in the check, so in some cases
it'll not miss cases. But that's still better than having no check ;)
2026-06-03 16:02:58 +02:00
Zbigniew Jędrzejewski-Szmek 112b565756 Add DLOPEN macros that stamp the caller's ELF and use it to ensure executables list their dlopen dependencies (#42398)
Currently almost all the dlopens happen in libbasic or libshared code,
so the ELF dlopen notes all end up in libsystemd-shared. Many
distributions split this library and various binaries in separate
packages, and the library ends up with soft-dependencies, even though
many binaries are either completely useless or do not work at all with
the dlopen dependency. This also makes it impossible to know which
executable uses which dlopen dependency without inspecting the source
code.

If someone only wants to add the soft dependencies from libshared they
can just avoid parsing the executable binaries. By design the code in
libbasic/libshared still does the stamping too, at lower priorities, so
that libsystemd-shared will always list all the optional dependencies,
and if one wants to build a minimal system by default, they can just
parse libsystemd-shared dlopen notes, and ignore the individual
executables. But for many distribution the current setup is insufficient
and requires adding a ton of manual library dependencies, as many
executables become effectively broken or useless without the dlopen
dependencies installed (eg: resolved fails to start without libssl,
repart can do basically nothing without blkid, etc).

Add a new set of DLOPEN_<LIB> macros that wrap the dlopen_lib and also
pull in the ELF note voodoo, so that the callers get their ELF binaries
stamped too. Convert a bunch of callers to use the macro, and use
`required` dependencies for the callers that do not work without the
dlopen library being available.

The one caveat is that, in order to avoid duplicating the exact same
note in a binary due to multiple call sites, some `asm` voodoo is done
instead of the previous bare-C section-creating macro. The drawback of
this approach is that if `--gc-sections` is used to link the binary (as
we do), then binutils >= 2.36 is required for the `SHF_GNU_RETAIN` flag.
This effectively cuts off CentOS 9, so what I did here is adding an
override in meson to detect missing support, and drop `SHF_GNU_RETAIN`.
The build works, but on CentOS 9 there's no dlopen ELF notes anymore.
Given it's just that version, and it goes EOL next year, that seems ok
to me. The alternative is to drop the usage of `--gc-sections` on CentOS
9, or to accept duplicated notes everywhere, and both seem worse.

End result:

```
$ readelf --notes build/systemd-executor

Displaying notes found in: .note.gnu.property
  Owner                Data size 	Description
  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
      Properties: x86 ISA needed: x86-64-baseline

Displaying notes found in: .note.gnu.build-id
  Owner                Data size 	Description
  GNU                  0x00000014	NT_GNU_BUILD_ID (unique build ID bitstring)
    Build ID: 8a0c3db54adb79ae54e1432255011aa4ab583742

Displaying notes found in: .note.ABI-tag
  Owner                Data size 	Description
  GNU                  0x00000010	NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 3.2.0

Displaying notes found in: .note.dlopen
  Owner                Data size 	Description
  FDO                  0x0000006b	FDO_DLOPEN_METADATA
    Dlopen Metadata: [{"feature":"pam","description":"Support for LinuxPAM","priority":"recommended","soname":["libpam.so.0"]}]
  FDO                  0x0000007c	FDO_DLOPEN_METADATA
    Dlopen Metadata: [{"feature":"seccomp","description":"Support for Seccomp Sandboxes","priority":"recommended","soname":["libseccomp.so.2"]}]
  FDO                  0x00000090	FDO_DLOPEN_METADATA
    Dlopen Metadata: [{"feature":"bpf","description":"Support firewalling and sandboxing with BPF","priority":"recommended","soname":["libbpf.so.1","libbpf.so.0"]}]
  FDO                  0x000000a0	FDO_DLOPEN_METADATA
    Dlopen Metadata: [{"feature":"cryptsetup","description":"Support for disk encryption, integrity, and authentication","priority":"recommended","soname":["libcryptsetup.so.12"]}]
  FDO                  0x00000078	FDO_DLOPEN_METADATA
    Dlopen Metadata: [{"feature":"mount","description":"Support for mount enumeration","priority":"recommended","soname":["libmount.so.1"]}]

$ readelf --notes build/systemd

Displaying notes found in: .note.gnu.property
  Owner                Data size 	Description
  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
      Properties: x86 ISA needed: x86-64-baseline

Displaying notes found in: .note.gnu.build-id
  Owner                Data size 	Description
  GNU                  0x00000014	NT_GNU_BUILD_ID (unique build ID bitstring)
    Build ID: dcd4568842e32da3e71be27db3def51c6b459994

Displaying notes found in: .note.ABI-tag
  Owner                Data size 	Description
  GNU                  0x00000010	NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 3.2.0

Displaying notes found in: .note.dlopen
  Owner                Data size 	Description
  FDO                  0x00000075	FDO_DLOPEN_METADATA
    Dlopen Metadata: [{"feature":"mount","description":"Support for mount enumeration","priority":"required","soname":["libmount.so.1"]}]
  FDO                  0x00000072	FDO_DLOPEN_METADATA
    Dlopen Metadata: [{"feature":"selinux","description":"Support for SELinux","priority":"recommended","soname":["libselinux.so.1"]}]
```
2026-06-02 18:05:34 +02:00
Zbigniew Jędrzejewski-Szmek 84389ff656 docs: say that the github form is preferred for security vulnerabilities 2026-06-01 15:06:20 +01:00
Zbigniew Jędrzejewski-Szmek 0f990a8ab9 man: drop -b/s/S/2/4 from the docs
We retain 1/3/5.
2026-06-01 12:21:12 +02:00
Zbigniew Jędrzejewski-Szmek b1410258f8 manager: if called with compat telinit interface, tell users to update
In https://bugzilla.redhat.com/show_bug.cgi?id=2479961 a user
reported that they are confused that 'init 6' and such commands
do not work anymore. We removed support for the whole interface,
but it's likely that such commands persist in various scripts
and finger memories. Let's give a helpful hint that this inteface
is gone and what to use instead.
2026-06-01 12:19:03 +02:00
Zbigniew Jędrzejewski-Szmek ff1721325d man/systemd: reword description of 2/3/4/5
We shouldn't say that that they boot into "a … legacy target", because
they boot into the standard targets. Those names are just aliases now.
(And also the user is not required to know what SysV even is, so it
shouldn't be used in the main explanation.)
2026-06-01 12:19:03 +02:00
Zbigniew Jędrzejewski-Szmek 06eeb83d3e tmpfiles: exclude x11 lock files from time-based cleanup
We need a removal rule for systems where /tmp is not on tmpfs,
so that if they crash, stale sockets will be removed during boot.
OTOH, at runtime, those lock files must never be removed.
But since the 'r!' rule uses '!', it only applies during boot. With
the rule inactive, the usual time-based cleanup for /tmp/ was also
applied to those files, causing them to be removed after 10 days.

Fixes #35182.
2026-05-31 11:44:38 +02:00
Zbigniew Jędrzejewski-SzmekandJarl Gullberg 5474cadc8d tmpfiles: remove boot-only restriction from x11 directory rules
4a1f92c704 added '!' through confusion:
the goal was probably to exclude those directories from cleanup at
runtime. But as discussed below, that exclusion is not needed. In fact,
we want the rule to be active during runtime, so that if the directory
were removed or wasn't created earlier for whatever reason, it'd be
created during one of those later runs too. This just makes the system
more robust.

Those directories are used for sockets, and tmpfiles will not remove
live sockets. So it is fine to run the cleanup on those directories,
it doesn't have any effect in normal circumstances. The only case where
the cleanup would matter would be if the service was running, crashed
without removing the socket, and the system would remain up for more
than 10 days after that. This is not a particularly likely scenario, but
OTOH, we can imaging that somebody tried to run Xorg, it didn't work,
and they switched to Wayland. Or their DE crashes every once in a while,
leaving some state behind. Keeping the cleanup in place seems OK, it
makes the system slightly more robust in fringe scenarios.

In fact, this cleanup will work better if we reduce the delay from
10 days to something small. systemd-tmpfiles-clean.timer runs once
per day, so the cleanup will not be very fast anyway. So use '1h' as
an arbitrary small value. (I think '0' would be risky, because it's
possible for the socket to be set up through a script where it's
created first and the service is connected to it, so it is momentarily
"not live". I think people used to do this. Not sure if that happens
anymore, but let's be safe.)

Co-authored-by: Jarl Gullberg <jarl.gullberg@visar-systems.com>
2026-05-31 11:44:21 +02:00
Zbigniew Jędrzejewski-Szmek 97a0ec135b Downgrade warning about missing libseccomp
We currently log at warning level:
/usr/lib/systemd/system/systemd-udevd.service:56: System call bpf cannot be
  resolved as libseccomp is not available, ignoring: Operation not supported

In the initrd, or in minimal installations, not installing libseccomp is
reasonable, depending on various other choices. We shouldn't make fuss
about this.

C.f. https://bugzilla.redhat.com/show_bug.cgi?id=2463540.
2026-05-29 01:09:19 +09:00
Zbigniew Jędrzejewski-Szmek 5991f0b861 profile.d: add instructions how to deactivate 80-systemd-osc-context.sh
This was requested in https://github.com/systemd/systemd/issues/42333.
Indeed, this integration is using three levels of systemd magick, so
doing this correctly is not obvious. Let's include specific instructions
to help people for whom this integration is causing problems.
2026-05-29 01:08:07 +09:00
Zbigniew Jędrzejewski-Szmek bf4388ab31 repart: constify Context* params 2026-05-28 12:06:12 +02:00
Zbigniew Jędrzejewski-Szmek fa2a6b6d88 shared/mkfs-util: split out mkfs_find_or_warn() 2026-05-28 12:06:10 +02:00
Zbigniew Jędrzejewski-Szmek cd79e5620b dhcp: update test and header cleanup (#42256) 2026-05-27 14:23:34 +02:00
Zbigniew Jędrzejewski-Szmek b130084a2d shared/bus-polkit: fix punctuation 2026-05-27 14:05:08 +02:00
Zbigniew Jędrzejewski-Szmek 7d6a3d9f3c imds: suppress or downgrade log messages
Other places that read credentials filer out ENXIO:
$ journalctl -b -u systemd-imds-early-network.service -o short-monotonic --no-hostname --no-pager -p warning
[    5.477675] systemd-imdsd[473]: Failed to read credential 'imds.vendor', ignoring: No such device or address
[    5.477687] systemd-imdsd[473]: Failed to read credential 'imds.vendor_token', ignoring: No such device or address
[    5.477693] systemd-imdsd[473]: Failed to read credential 'imds.refresh_header_name', ignoring: No such device or address
[    5.477699] systemd-imdsd[473]: Failed to read credential 'imds.data_url', ignoring: No such device or address
[    5.477704] systemd-imdsd[473]: Failed to read credential 'imds.data_url_suffix', ignoring: No such device or address
[    5.477710] systemd-imdsd[473]: Failed to read credential 'imds.token_header_name', ignoring: No such device or address
[    5.477714] systemd-imdsd[473]: Failed to read credential 'imds.extra_header', ignoring: No such device or address
[    5.477720] systemd-imdsd[473]: Failed to read credential 'imds.extra_header2', ignoring: No such device or address
[    5.477730] systemd-imdsd[473]: Failed to read credential 'imds.extra_header3', ignoring: No such device or address
[    5.477736] systemd-imdsd[473]: Failed to read credential 'imds.extra_header4', ignoring: No such device or address
[    5.477742] systemd-imdsd[473]: Failed to read credential 'imds.extra_header5', ignoring: No such device or address
[    5.477747] systemd-imdsd[473]: Failed to read credential 'imds.extra_header6', ignoring: No such device or address
[    5.477751] systemd-imdsd[473]: Failed to read credential 'imds.extra_header7', ignoring: No such device or address
[    5.477757] systemd-imdsd[473]: Failed to read credential 'imds.extra_header8', ignoring: No such device or address
[    5.477763] systemd-imdsd[473]: Failed to read credential 'imds.extra_header9', ignoring: No such device or address
[    5.477768] systemd-imdsd[473]: Failed to read credential 'imds.extra_header10', ignoring: No such device or address
[    5.477774] systemd-imdsd[473]: Failed to read credential 'imds.extra_header11', ignoring: No such device or address
[    5.477779] systemd-imdsd[473]: Failed to read credential 'imds.extra_header12', ignoring: No such device or address
[    5.477784] systemd-imdsd[473]: Failed to read credential 'imds.extra_header13', ignoring: No such device or address
[    5.477789] systemd-imdsd[473]: Failed to read credential 'imds.extra_header14', ignoring: No such device or address
[    5.477799] systemd-imdsd[473]: Failed to read credential 'imds.extra_header15', ignoring: No such device or address
[    5.477804] systemd-imdsd[473]: Failed to read credential 'imds.extra_header16', ignoring: No such device or address
[    5.477810] systemd-imdsd[473]: Failed to read credential 'imds.extra_header17', ignoring: No such device or address
[    5.477815] systemd-imdsd[473]: Failed to read credential 'imds.extra_header18', ignoring: No such device or address
[    5.477820] systemd-imdsd[473]: Failed to read credential 'imds.extra_header19', ignoring: No such device or address
[    5.477825] systemd-imdsd[473]: Failed to read credential 'imds.extra_header20', ignoring: No such device or address
[    5.477830] systemd-imdsd[473]: Failed to read credential 'imds.extra_header21', ignoring: No such device or address
[    5.477835] systemd-imdsd[473]: Failed to read credential 'imds.extra_header22', ignoring: No such device or address
[    5.477840] systemd-imdsd[473]: Failed to read credential 'imds.extra_header23', ignoring: No such device or address
[    5.477845] systemd-imdsd[473]: Failed to read credential 'imds.extra_header24', ignoring: No such device or address
[    5.477851] systemd-imdsd[473]: Failed to read credential 'imds.extra_header25', ignoring: No such device or address
[    5.477856] systemd-imdsd[473]: Failed to read credential 'imds.extra_header26', ignoring: No such device or address
[    5.477865] systemd-imdsd[473]: Failed to read credential 'imds.extra_header27', ignoring: No such device or address
[    5.477869] systemd-imdsd[473]: Failed to read credential 'imds.extra_header28', ignoring: No such device or address
[    5.477874] systemd-imdsd[473]: Failed to read credential 'imds.extra_header29', ignoring: No such device or address
[    5.477881] systemd-imdsd[473]: Failed to read credential 'imds.extra_header30', ignoring: No such device or address
[    5.477885] systemd-imdsd[473]: Failed to read credential 'imds.extra_header31', ignoring: No such device or address
[    5.477890] systemd-imdsd[473]: Failed to read credential 'imds.extra_header32', ignoring: No such device or address
[    5.477896] systemd-imdsd[473]: Failed to read credential 'imds.extra_header33', ignoring: No such device or address
[    5.477901] systemd-imdsd[473]: Failed to read credential 'imds.extra_header34', ignoring: No such device or address
[    5.477906] systemd-imdsd[473]: Failed to read credential 'imds.extra_header35', ignoring: No such device or address
[    5.477913] systemd-imdsd[473]: Failed to read credential 'imds.extra_header36', ignoring: No such device or address
[    5.477917] systemd-imdsd[473]: Failed to read credential 'imds.extra_header37', ignoring: No such device or address
[    5.477922] systemd-imdsd[473]: Failed to read credential 'imds.extra_header38', ignoring: No such device or address
[    5.477931] systemd-imdsd[473]: Failed to read credential 'imds.extra_header39', ignoring: No such device or address
[    5.477935] systemd-imdsd[473]: Failed to read credential 'imds.extra_header40', ignoring: No such device or address
[    5.477940] systemd-imdsd[473]: Failed to read credential 'imds.extra_header41', ignoring: No such device or address
[    5.477945] systemd-imdsd[473]: Failed to read credential 'imds.extra_header42', ignoring: No such device or address
[    5.477951] systemd-imdsd[473]: Failed to read credential 'imds.extra_header43', ignoring: No such device or address
[    5.477956] systemd-imdsd[473]: Failed to read credential 'imds.extra_header44', ignoring: No such device or address
[    5.477962] systemd-imdsd[473]: Failed to read credential 'imds.extra_header45', ignoring: No such device or address
[    5.477967] systemd-imdsd[473]: Failed to read credential 'imds.extra_header46', ignoring: No such device or address
[    5.477972] systemd-imdsd[473]: Failed to read credential 'imds.extra_header47', ignoring: No such device or address
[    5.477978] systemd-imdsd[473]: Failed to read credential 'imds.extra_header48', ignoring: No such device or address
[    5.477982] systemd-imdsd[473]: Failed to read credential 'imds.extra_header49', ignoring: No such device or address
[    5.477988] systemd-imdsd[473]: Failed to read credential 'imds.extra_header50', ignoring: No such device or address
[    5.477995] systemd-imdsd[473]: Failed to read credential 'imds.extra_header51', ignoring: No such device or address
[    5.477999] systemd-imdsd[473]: Failed to read credential 'imds.extra_header52', ignoring: No such device or address
[    5.478022] systemd-imdsd[473]: Failed to read credential 'imds.extra_header53', ignoring: No such device or address
[    5.478028] systemd-imdsd[473]: Failed to read credential 'imds.extra_header54', ignoring: No such device or address
[    5.478033] systemd-imdsd[473]: Failed to read credential 'imds.extra_header55', ignoring: No such device or address
[    5.478039] systemd-imdsd[473]: Failed to read credential 'imds.extra_header56', ignoring: No such device or address
[    5.478044] systemd-imdsd[473]: Failed to read credential 'imds.extra_header57', ignoring: No such device or address
[    5.478050] systemd-imdsd[473]: Failed to read credential 'imds.extra_header58', ignoring: No such device or address
[    5.478055] systemd-imdsd[473]: Failed to read credential 'imds.extra_header59', ignoring: No such device or address
[    5.478060] systemd-imdsd[473]: Failed to read credential 'imds.extra_header60', ignoring: No such device or address
[    5.478066] systemd-imdsd[473]: Failed to read credential 'imds.extra_header61', ignoring: No such device or address
[    5.478071] systemd-imdsd[473]: Failed to read credential 'imds.extra_header62', ignoring: No such device or address
[    5.478079] systemd-imdsd[473]: Failed to read credential 'imds.extra_header63', ignoring: No such device or address
[    5.478086] systemd-imdsd[473]: Failed read IPv4 address from credential 'imds.address_ipv4', ignoring: No such device or address
[    5.478091] systemd-imdsd[473]: Failed read IPv6 address from credential 'imds.address_ipv6', ignoring: No such device or address
[    5.478097] systemd-imdsd[473]: Failed to read credential 'imds.key_hostname', ignoring: No such device or address
[    5.478102] systemd-imdsd[473]: Failed to read credential 'imds.key_region', ignoring: No such device or address
[    5.478107] systemd-imdsd[473]: Failed to read credential 'imds.key_zone', ignoring: No such device or address
[    5.478113] systemd-imdsd[473]: Failed to read credential 'imds.key_ipv4_public', ignoring: No such device or address
[    5.478119] systemd-imdsd[473]: Failed to read credential 'imds.key_ipv6_public', ignoring: No such device or address
[    5.478123] systemd-imdsd[473]: Failed to read credential 'imds.key_ssh_key', ignoring: No such device or address
[    5.478128] systemd-imdsd[473]: Failed to read credential 'imds.key_userdata', ignoring: No such device or address
[    5.478134] systemd-imdsd[473]: Failed to read credential 'imds.key_userdata_base', ignoring: No such device or address
[    5.478137] systemd-imdsd[473]: Failed to read credential 'imds.key_userdata_base64', ignoring: No such device or address
2026-05-27 04:36:05 +09:00
Zbigniew Jędrzejewski-Szmek 0dc188e006 units: do not fail if imds is not configured
In https://bugzilla.redhat.com/show_bug.cgi?id=2481466, it is reported
that systemd-imds-early-network.service fails on AWS EC2 instance with:

> No IMDS endpoint information provided or detected, cannot operate.

The service will be started on various systems where it doesn't have
enough configuration to run. The systemd-imds-generator only does some
superficial checks, so the tool should not mark the boot as failed
it turns out that IMDS is not supported.
2026-05-27 04:36:05 +09:00
Zbigniew Jędrzejewski-Szmek a273ebdebe mkosi: update fedora commit reference to 9cb09470c9c5a437f8e9c1e0e449b87de83733eb
* 9cb09470c9 Version 261~rc1
* 7d16ad00bd Fix compilation with openssl 4.0
* 3770fa7c92 Revert "Use dlopen-notes to automatically generate library Recommends/Requires/Suggests"
* 8b3d1726f5 Add back various explit Requires
* d8abb91805 Drop scriptlet workarounds for upgrades from versions < 247
* ee6d0b9d27 Use dlopen-notes to automatically generate library Recommends/Requires/Suggests
* 32a2038627 spec: drop duplicated line
* ab743db0fe Downgrade kbd dependency to Recommends
* 400494ada4 Update conditionals for RHEL 11
2026-05-26 16:55:17 +02:00
Zbigniew Jędrzejewski-Szmek 2052315247 man: fedora 44 is the latest stable 2026-05-26 16:55:00 +02:00
Zbigniew Jędrzejewski-Szmek 21b0699f5e Allow systemd-imds-import to be ordered early and update enablement (#42308)
It seems that the enablement of this unit was somewhat confused…
2026-05-26 16:49:23 +02:00
Zbigniew Jędrzejewski-Szmek c621879e35 imds-generator: replace static Condition=initrd by a check in the generator
After looking at the unit, I'm not sure if systemd-imds-import.service
is supposed to run in the host system or not. But if it is supposed to
only run in the initrd, then the static condition in the unit file gives
as the worst behaviour: the generator does not do any checks if we are
in the initrd or not, and if it enabled the unit, it'll influence the
transaction ordering (possibly causing loops or additional work) and
then the unit will be unconditionally skipped. So replace the static
condition by a check in the generator. If the user specifies
systemd.imds.import on the commandline, it'll be honoured also in the
host.
2026-05-26 13:58:53 +01:00
Zbigniew Jędrzejewski-Szmek 3f33f4d057 units: drop After=network-online.target from imds services
The imds services are (very-) early boot services, ordered before
sysinit.target. OTOH, network-online.target is something that is often
established very late [1]. In fact, we always recommended to _not_
depend on it for things that are ordered before the usual targets that
allow user logins (e.g. graphical.target). So we certainly cannot add
early-boot ordering for it. Currently systemd-imds-imports.service
is conditionalized to only run in the initrd. But if the unit is enabled
in the host system, it would affect the transaction there, so we should
drop this bogus ordering everywhere.

(I think this might have been added by mistake. After all,
systemd-imds-import.service itself shouldn't care about the network.)

This fixes boot ordering issues reported upstream and in Fedora [2, 3].

[1] https://systemd.io/NETWORK_ONLINE/#network-connectivity-has-been-established-network-onlinetarget
[2] https://github.com/systemd/systemd/pull/40980#discussion_r2949473028
[3] https://bugzilla.redhat.com/show_bug.cgi?id=2481304
2026-05-26 13:58:53 +01:00
Zbigniew Jędrzejewski-Szmek d8344fbf14 tools/test-crash-trace: do not use fixed signal numbers
The numbers of signals vary by arch. On the common arches the signals
listed here all use the same numbers, but people are likely to use
this on more fringe architectures too, so let's use symbolic names
instead.

Also the comment about gdb "hitting the same kill" didn't make sense.

The syntax is a bit baroque, but using a helper variable does not work.
Also shellcheck complains about $[ ] which would have made this more
legible.
2026-05-25 12:51:52 +01:00
Zbigniew Jędrzejewski-Szmek 94a1312cca TEST-75-RESOLVED: use SYSTEMD_INVOKED_AS=resolvconf 2026-05-25 12:37:36 +02:00
Zbigniew Jędrzejewski-Szmek 58e7959988 Add $SYSTEMD_INVOKED_AS
This allows multi-call binaries to be easily invoked with a different
name. After installation, the name is set by creating a symlink. But in
build directories, we don't create the symlinks. (There are also other
ways to achieve the same thing, e.g. zsh supports $ARGV0, and exec -a
can be used, but those are either non-portable or are more complicated
to use.)  The primary use-case for me is to test --help output for
multicall binaries.

Also reorder the help for env vars to group the more generic ones near
the top.

This was initially proposed in https://github.com/systemd/systemd/pull/24054,
but there were some comments about the implementation. I had a branch
with the patch, but I don't think I ever actually submitted it as a
pull request.
2026-05-25 12:37:36 +02:00
Zbigniew Jędrzejewski-Szmek 997ce3a3c0 po: "detect" msgmerge-nofuzzy using file()
With find_program, meson verbosely reports the detection of the file,
which we don't need since it's part of the repo and always present.
2026-05-24 13:26:56 +01:00
Zbigniew Jędrzejewski-Szmek 269fd06246 NEWS: drop imagined --print-profiles option
In dc91cb82da --print-profiles is
passed to swtpm_setup, that's it.
2026-05-22 18:37:56 +02:00
Zbigniew Jędrzejewski-Szmek c83ff0e58d user-util: return malloc'ed strings in get_user_creds
get_user_creds would use getpwnam() and then returns strings pointing
into the static buffer. This seems very iffy. Let's duplicate the
strings properly
2026-05-21 18:02:05 +02:00
Zbigniew Jędrzejewski-Szmek 3ecd6b69cf user-util: stop mangling groupname in get_group_creds
The param was input/output, which is unexpected and confusing and
actually made most callers much more complicated than they needed to be.
The function was playing fast and loose with the return value. In some
cases it was returning a static string, which would be completely fine.
But in other case it was returning a pointer into the getgrgid static
buffer, i.e. that return value could be overwritten. AFAICT, this didn't
matter in any of the callers, but we shouldn't do that anyway.

So use a separate output param with an allocated string that the caller
is responsible for.

It turns out that all callers pass NULL (outside of tests) and zero for
flags. So the function _could_ be simplified. But get_user_creds is
called with all the params actually used, and I think having the the
functions so different wouldn't be nice. I first wrote a commit to
drop the unused params, but then I discarded it.

The error message in exec-invoke.c is fixed.
2026-05-21 18:02:05 +02:00
Zbigniew Jędrzejewski-Szmek 3d0a05dcc3 core/exec-invoke: fix bogus error code
r was bogus here. getusername_malloc() can only fail on oom,
so we can simplify this.
2026-05-21 18:02:05 +02:00
Zbigniew Jędrzejewski-Szmek 705a705e85 include/uapi: add linux/openat2.h (#42220)
We include the header through src/include/override/fcntl.h, hence we should
have the latest copy of the header.

(E.g. compilation fails with musl-libc-1.2.5-6.fc44.x86_64 and older kernel
headers.)
2026-05-21 13:29:28 +02:00
Zbigniew Jędrzejewski-Szmek be8b41eafa Fixes for claude review report (#42152) 2026-05-18 15:13:24 +02:00
Zbigniew Jędrzejewski-Szmek 901179e3c7 sysupdate: fix noop assert
Reported by qarmin (Rafał Mikrut).
2026-05-18 12:45:56 +02:00
Zbigniew Jędrzejewski-Szmek 3a333585fe repart: fix bogus errno in error message and returned value
Reported by qarmin (Rafał Mikrut).
2026-05-18 12:45:56 +02:00
Zbigniew Jędrzejewski-Szmek f0405bfdff nsresourced: fix typo
Reported by qarmin (Rafał Mikrut).
2026-05-18 12:44:45 +02:00
Zbigniew Jędrzejewski-Szmek 4f688e61c9 coredump: use a fixed string instead a scope-delimited compound literal
The compound literal (const char[]){'.','.','.'} has block scope
(C99 6.5.2.5p6). Once we leave the if and loop back, copy[1].iov_base
formally points into a destroyed object. Works on GCC/Clang in practice,
but is UB.

Let's do the easy thing and use a string.

Reported by qarmin (Rafał Mikrut).
2026-05-18 12:44:45 +02:00
Zbigniew Jędrzejewski-Szmek dd2d04179b tree-wide: stop using lambda assignment in Python code (#42145)
Follow-up for #40758.
2026-05-18 12:42:02 +02:00
Zbigniew Jędrzejewski-Szmek fd12cc9a52 core/manager: fix (theoretical) fd leak on invalid messages
We'd leak fds on early return. We are sending a message to ourself,
so it's unlikely to fail. But let's keep the logic correct.

Reported by qarmin (Rafał Mikrut).
2026-05-18 12:33:37 +02:00
Zbigniew Jędrzejewski-Szmek e305f552ec core/dbus-execute: propagate oom in property_get_cpu_affinity
The function already returns errors, so I'm not sure why we ignored
the error in the second call, potentially leaving variables unitialized.
It seems easiest to propagate the error.

Reported by qarmin (Rafał Mikrut).
2026-05-18 12:29:12 +02:00
Zbigniew Jędrzejewski-Szmek 92e0c920c7 basic/path-util: fix executable_is_good
Reported by qarmin (Rafał Mikrut).
2026-05-18 12:28:08 +02:00
Zbigniew Jędrzejewski-Szmek d512d3c6d3 treewide: get rid of remaing getopt/getopt_long stuff 2026-05-16 18:37:12 +02:00
Zbigniew Jędrzejewski-Szmek 39a3647539 tree-wide: get rid of old dispatch_verb
Also rename dispatch_verb_with_args to dispatch_verb.
2026-05-16 18:37:10 +02:00
Zbigniew Jędrzejewski-Szmek 40fed88f8e test-verbs: dispatch via _dispatch_verb_with_args() directly
Drops the global-optind dependency from the test helper. Verb fixtures
stay inline as static const Verb[] — the section-based VERB() macro
would force unique verb names across the three test cases, which they
deliberately share to exercise overlap.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 18:36:08 +02:00
Zbigniew Jędrzejewski-Szmek e934c6209a veritysetup: convert verbs to VERB macros
Place VERB() declarations above each dispatch function and use
verbs_get_help_table() in help(). run() switches to
dispatch_verb_with_args(); the argv_looks_like_help() shortcut is
preserved since this is an internal tool with no proper option parsing.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 18:36:08 +02:00
Zbigniew Jędrzejewski-Szmek 65f83b0352 update-utmp: convert verbs to VERB macros
There is no --help implemented, so both verbs don't get help strings.
We should probably add --help + --version, and a proper description
of the program, but I'm leaving that for later.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 18:36:08 +02:00
Zbigniew Jędrzejewski-Szmek 062f6892b3 integritysetup: convert verbs to VERB macros
Place VERB() declarations above each dispatch function and use
verbs_get_help_table() in help() so the command listing stays in sync.
run() switches to dispatch_verb_with_args(); the argv_looks_like_help()
shortcut is preserved since this is an internal tool with no proper
option parsing.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 18:36:08 +02:00
Zbigniew Jędrzejewski-Szmek 1bf6be01c0 backlight: convert verbs to VERB macros
Place VERB() declarations directly above each dispatch function and use
verbs_get_help_table() in help() so the command listing stays in sync.
run() switches to dispatch_verb_with_args(); the argv_looks_like_help()
shortcut is preserved since this is an internal tool with no proper
option parsing.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 18:36:08 +02:00
Zbigniew Jędrzejewski-Szmek 59db1f482a dissect: convert the other parser to option macros 2026-05-16 18:36:08 +02:00
Zbigniew Jędrzejewski-Szmek 59ce15c406 storagectl: convert run_as_mount_helper to OPTION macros
This is the util-linux mount-helper interface (mount.storage), so all
options stay hidden via help=NULL — they are not user-facing. The
namespace "mount.storage" is distinct from the storagectl namespace
used for the user-facing CLI.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 18:36:08 +02:00
Zbigniew Jędrzejewski-Szmek 8bc7cf64d1 udev: drop leftover includes of getopt.h
Not sure why those were left and why clang-tidy didn't complain.
2026-05-16 18:36:08 +02:00
Zbigniew Jędrzejewski-Szmek cf88903637 tree-wide: get rid of most uses of ALIGN_PTR
This bothered me for a while, but I didn't think too much about it and just
copied the existing usage pattern. But it really doesn't make sense. We expect
the compiler to align the section properly. But if it didn't align it, applying
alignment after the fact would just cause our pointer to point to the middle
of the structure. That'd be even worse than a misaligned pointer.

Similarly, when doing pointer arithmetic, p++ should really result in a value
with the appropriate alignment. This is the basic principle of C pointer
addition. So we really shouldn't try to adjust the pointer ourselves. At most,
we can assert that it is indeed aligned in tests.
2026-05-16 18:32:14 +02:00
Zbigniew Jędrzejewski-Szmek d71c1e7d89 Convert machinectl to option and verb macros (#42117) 2026-05-16 17:18:10 +02:00
Zbigniew Jędrzejewski-Szmek 3b37439afb machinectl: convert to OPTION and VERB macros
For the shell verb we want switches specified after the program name to
be passed to the program to execute, not processed by us. Mirror the
approach in 'userdbctl ssh-authorized-keys': start with
OPTION_PARSER_RETURN_POSITIONAL_ARGS, then lates switch to
STOP_AT_FIRST_NONOPTION for "shell" or NORMAL otherwise.

VERB declarations are placed directly above each function; functions
that dispatch multiple verb names get stacked VERB() declarations.
chainload_importctl() now takes the args strv instead of relying on the
global optind.

--help output is mostly the same.
--no-pager/--no-legend/--no-ask-password/-q/--quiet are now at the end.
bind-volume/unbind-volume are documented.

Fixes c9f461a806.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 15:59:15 +02:00
Zbigniew Jędrzejewski-Szmek cab5c5ef81 shared/verbs: add VERB_DEFAULT_NOARG 2026-05-16 15:54:18 +02:00
Zbigniew Jędrzejewski-Szmek 6b8c3af359 machinectl: reorder cases in parse_argv() to match order in --help
--no-pager, --no-legend, --no-ask-password, --quiet are shifted to
the end.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 21:49:05 +02:00
Zbigniew Jędrzejewski-Szmek 3f96c89a52 machinectl: reorder verb functions to match --help
The net diff is negative because some spurious whitespace and forward
declarations were dropped. One new forward declaration was added. (For
verb_poweroff_machine. The func could be moved, but I think it's better
to keep it adjacent to verb_reboot_machine which is very similar.)
2026-05-15 21:49:05 +02:00
Zbigniew Jędrzejewski-Szmek 3b5495c041 homectl: fix unlocking of multiple homes
Fixes 4aa0a8ac3e.
2026-05-15 18:52:01 +02:00
Zbigniew Jędrzejewski-Szmek 6cadf7b108 homectl: convert verbs to VERB macros
--help looks pretty much the same. "[list]" is shown in parentheses
because it's the default.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 18:51:58 +02:00
Zbigniew Jędrzejewski-Szmek 9a7b2d0d87 homectl: convert parse_argv to OPTION macros
Rewrite help() with help-util.h primitives + option_parser_get_help_table_group
for each User Record Properties section. The verbs[] table stays
unchanged for now; run() switches from dispatch_verb() (which depended
on the global optind) to _dispatch_verb_with_args() fed by
option_parser_get_args().

Explanations are improved for --birth-date[=DATE] (correct placement of
'['), --skel=, --shell= (short options listed). Some minor rewordings
for other options. The explanation for -E and -EE is split.
(OPTION_HELP_ENTRY_VERBATIM is used for -EE.)

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 18:51:56 +02:00
Zbigniew Jędrzejewski-Szmek 82b87471ad shared/options: fix display of OPTION_HELP_ENTRY_VERBATIM
So far it was used only once, in bootctl. It should not be indented:
  -R --print-root-device
  -RR
  ^
2026-05-15 18:47:17 +02:00
Zbigniew Jędrzejewski-Szmek feb1078462 homectl: reorder cases in parse_argv() to match order in --help
Display options --no-pager, --no-legend, --no-ask-password are placed at
the end, after --mute-console=yes, rather than near the top.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 18:47:11 +02:00