Commit Graph
90486 Commits
Author SHA1 Message Date
Lennart Poettering a84642ed94 update TODO 2026-07-02 21:53:10 +02:00
Lennart Poettering 8aaa8dec59 tpm2: cache NvPCR NV space exhaustion via flag files in /run/
When we run out of NV index space while allocating an NvPCR, the
situation will unlikely improve until (at least) reboot. Retrying the
(doomed) Esys_NV_DefineSpace call on every subsequent allocation attempt
is wasteful (and very slow), so remember the exhaustion in a flag file
under /run/ and fail early next time.

We use two separate flag files, one for orderly and one for non-orderly
NvPCRs, since the two draw on different TPM resources (RAM-backed vs.
NVRAM-backed): exhaustion of one doesn't imply exhaustion of the other.

The files live in /run/, hence are cleared on reboot, which is
potentially is when NV space might become available again.
2026-07-02 21:53:09 +02:00
Lennart Poettering 55be5e1890 tpm2: optionally disable TPMA_NV_ORDERLY for NvPCRs
NVIndexes in TPMs can operate in two modes:

1. Backed by TPM RAM. In this case they are only written to NVRAM on an
   orderly TPM shutdown when the system goes down. (TPMA_NV_ORDERLY flag
   is on)

2. Backed by TPM NVRAM. In this case the nvindex value is written to NVRAM
   on every write, and things are not delayed until orderly shutdown.

Normally mode 1 sounds like the obvious choice for NvPCRs, which reset
to zero anyway at boot. However, things are more complicated since
real-life TPMs tend to have a lot less RAM than NVRAM (both are
constrained but RAM even more than NVRAM). Hence there's value in using
NVRAM right-away. However, writing to NVRAM all the time means wearing
it out (since NVRAM is more vulnerable to that).

So far we unconditionally went for mode 1, but ran into space
constraints of RAM due to that.

Let's improve things a bit, and use orderly mode for NvPCRs we expect to
write many times, and non-orderly mode for those we expect to write only
a small, fixed number of times at boot, and not anymore during runtime.
Right now, this is only the "hardware" NvPCR, which measures hw identity
at boot.

Hopefully, this stretches available resources a bit further.

This also makes sure if the flag was set differently on allocation as
we'd set now, we accept it and won't complain, to make upgrades safe.

Suggested by Andreas Fuchs.
2026-07-02 21:51:54 +02:00
dongshengyuan be8a7b418a pcrextend,tpm2-util,tpm2-setup: gracefully skip NvPCR when TPM NV space is exhausted
Map TPM2_RC_NV_SPACE to -ENOBUFS in tpm2_define_nvpcr_nv_index() rather
than -ENOSPC, giving it a dedicated errno distinct from the -ENOSPC that
write_string_file_at() can return when /run is full — a different failure
that occurs after the NV index is already allocated on the TPM.

In extend_nvpcr_now(), propagate -ENOBUFS as-is so callers can handle it
in a nicer fashion. In vl_method_extend(), map it to the new varlink error
io.systemd.PCRExtend.NvPCRSpaceExhausted. In run(), handle -ENOBUFS
explicitly under --graceful and print an appropriate message. Update
tpm2-setup.c accordingly.

Fixes #42725
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
2026-07-02 21:49:18 +02:00
Lennart Poettering 231176d25b import: Trust subkeys included in signature (#41860)
- import: Trust subkeys included in signature
    
    With gpg sub keys one can rotate signing keys while having a stable
trust anchor. So far one still had to ship the sub key out of band but
a newer gpg has the option to include the sub key in the signature and
import it automatically. This is safe if we only allow importing a sub
    key signed by the top key we already have in the key ring.
    Add the --auto-key-import argument to gpg to import subkeys but also
set --import-options=merge-only,import-clean to restrict what we import
    to only be sub keys signed by the top key we have in the keyring and
    discard any irrelevant parts.
- import: Support env var to override gpg keyring
    
By default there is a fixed keyring in /usr or /etc. But when running
systemd-pull unprivileged in the user context or with a custom transfer
definition as in systemd-sysupdate --definitions=./... (e.g., for local
ParticleOS updates) it is limiting to require that all keys have to be
part of the OS keyring or otherwise no verification can be used. Also,
    for testing it is valuable to point it at a different keyring.
    Add a SYSTEMD_OPENPGP_KEYRING env var where the omission or empty
assignment sticks to the current behavior of the global OS keyrings but
    a keyring path given will take precedence. While an env var can leak
    down the process tree and is more difficult to secure for being the
trust anchor the advantage is that one can directly specify it in the
    service unit as drop-in instead of having to patch the command
invocation. Anyway it's a niche use case and thus not part of the man
    page.
2026-07-02 21:38:03 +02:00
Shihao Ren 4fb350a46a run: default run0 to root explicitly
When neither --user=, --area= nor --empower is given, run0 already
behaves as if root was requested, but only implicitly. That can be
misleading downstream.

Set arg_exec_user to "root" up front in parse_argv_sudo_mode(), so the
intent is visible and the rest of the code can rely on it.

Fixes #40468

Signed-off-by: Shihao Ren <renshihao.rsh@bytedance.com>
2026-07-02 21:34:15 +02:00
Lennart Poettering 977dc1784b Fix: tmpfiles clean device node (#42791)
Two minor issues regarding the tmpfile.c file
2026-07-02 21:33:34 +02:00
Chris Coulson 2348941b5d measure: Support binding signed policies to individual phases
systemd-measure can produce multiple signed policies for different
phases. However, a policy for a TPM resource that includes these signed
policies can currently be satisfied by any policy that is signed
with the same key.

It can be desirable to bind a resource's policy to one or more
specific phases. One way to do this could be to sign policies for
different phases or phase combinations with different keys. Another
approach is to limit the scope of signed policies using a policy
reference.

Using a policy reference works because:
- The reference is included along with the approved policy digest in the
  digest that is signed.
- The reference argument is included in the authorization policy for a
  resource via the TPM2_PolicyAuthorize assertion.
- During execution of the TPM2_PolicyAuthorize assertion, the TPM checks
  that the session's current policy digest is the approved policy digest,
  computes a digest from the approved policy digest and the supplied policy
  reference, and checks that the resulting digest is the one that was
  verified by TPM2_VerifySignature (via the returned ticket).

This adds a new --policyref argument to systemd-measure which binds all
of the signed policies to the specified policy reference. I did consider
making this more intelligent by auto-generating policy references for each
phase, but this approach provides the most flexibility for now. By making
use of the existing --append argument, a signer can produce multiple
signed policies with the same key that are bound to any individual phases
or combinations of phases.

The policy reference is a string without the NULL terminator. It is
supplied to the TPM via the TPM2B_NONCE type, which has a maximum size
equivalent to the size of the largest digest supported by the TPM. As
the signer doesn't know the capabilities of the target TPM,
systemd-measure limits the size of the policy reference to 32 bytes, to
fit within the size of a SHA256 digest.

This also includes the corresponding changes to systemd-cryptenroll and
systemd-repart (to add an equivalent --tpm2-public-key-policyref argument
so that the policy can be bound to the desired corresponding phase, and to
ensure that the policy reference is included in the LUKS2 token metadata),
and systemd-cryptsetup (to handle the policy reference stored in the LUKS2
token metadata).

This doesn't include policy reference support for credentials yet
because it requires a change to the credential headers.
2026-07-02 21:28:42 +02:00
Yu Watanabe d04423c870 bless-boot: avoid false maybe-uninitialized warning
Obserbed with GCC-11 on Ubuntu.
```
In file included from ../src/shared/format-table.h:7,
                 from ../src/bless-boot/bless-boot.c:11:
../src/bless-boot/bless-boot.c: In function ‘verb_set’:
../src/basic/log.h:187:27: error: ‘source2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  187 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                           ^~~~~~~~~~~~
../src/bless-boot/bless-boot.c:458:40: note: ‘source2’ was declared here
  458 |         const char *target, *source1, *source2;
      |                                        ^~~~~~~
In file included from ../src/shared/format-table.h:7,
                 from ../src/bless-boot/bless-boot.c:11:
../src/basic/log.h:187:27: error: ‘source1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  187 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                           ^~~~~~~~~~~~
../src/bless-boot/bless-boot.c:458:30: note: ‘source1’ was declared here
  458 |         const char *target, *source1, *source2;
      |                              ^~~~~~~
In file included from ../src/shared/format-table.h:7,
                 from ../src/bless-boot/bless-boot.c:11:
../src/basic/log.h:187:27: error: ‘target’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  187 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                           ^~~~~~~~~~~~
../src/bless-boot/bless-boot.c:458:21: note: ‘target’ was declared here
  458 |         const char *target, *source1, *source2;
      |                     ^~~~~~
cc1: all warnings being treated as errors
```
2026-07-03 03:02:57 +09:00
Yu Watanabe 4bf6e75198 ci/build-test: try to build with OPENSSL_NO_DEPRECATED 2026-07-03 03:02:57 +09:00
Yu Watanabe 71a94be08c crypto-util: drop unused symbol 2026-07-03 03:02:57 +09:00
Yu Watanabe d26da0a705 crypto-util: make OpenSSL UI API symbols optional during dlopen
Previously, if systemd was built with OpenSSL UI support, it would fail
to load libcrypto at runtime if the library lacked UI support, requiring
a recompilation of systemd to fix.

Let's relax this strict requirement by making the UI methods optional
during dlopen(). openssl_ui_supported() is added to dynamically check
if all required UI symbols were successfully loaded.
2026-07-03 03:02:57 +09:00
Yu Watanabe 805f8c6503 crypto-util: allow loading private keys from engine/provider without UI support
OpenSSL UI is not a mandatory feature to load private keys from an engine
or a provider. Let's allow loading private keys even if OpenSSL UI is not
supported.

Note that even if OPENSSL_NO_UI_CONSOLE is set, the type UI_METHOD is
always defined. Hence, the `#ifndef` condition in the definition of
struct OpenSSLAskPasswordUI is unnecessary and can be dropped.
2026-07-03 03:02:57 +09:00
Yu Watanabe f63cc9af18 crypto-util: drop redundant logs
The called functions already log errors internally.
2026-07-03 03:02:56 +09:00
Yu Watanabe 7301e2602d crypto-util: move functions
Implementations for loading private/public keys and X.509 certificates
were scattered. Group them together to improve readability.
2026-07-03 03:02:56 +09:00
Yu Watanabe 7c21061f09 crypto-util: make OpenSSL ENGINE API symbols optional during dlopen
If systemd is compiled with OpenSSL 3 headers but executed in an environment
where OpenSSL 4 (libcrypto.so.4) is loaded, dlopen_many_sym_or_warn() will
fail because OpenSSL 4 completely removes the deprecated ENGINE API. This
breaks the ability to dynamically fallback and seamlessly upgrade OpenSSL
without recompiling systemd.

To fix this, drop the ENGINE API symbols from the mandatory DLSYM_ARG() list.
Instead, try to load them via DLSYM_OPTIONAL() after the library is opened.
load_key_from_engine() is updated to check for their presence and return
-EOPNOTSUPP if the loaded OpenSSL version does not provide them.
2026-07-03 03:02:56 +09:00
Yu Watanabe 3aaffa43f0 crypto-util: drop dlopen_libcrypto() from static functions 2026-07-03 03:02:56 +09:00
Yu Watanabe 75bc106095 memory-util: drop unused memdup_reverse()
With the previous commit, now the function is unused anymore.
Let's drop it.
2026-07-03 03:02:56 +09:00
Yu Watanabe b5e75134f3 crypto-util: drop manual endianness handling in rsa_pkey_from_n_e()
Currently, rsa_pkey_from_n_e() uses architecture-specific `#if` branches
and memdup_reverse() to handle big-endian RSA components (n and e)
before passing them directly to OSSL_PARAM_construct_BN().

We can simplify this by parsing the raw big-endian bytes into BIGNUMs
first using BN_bin2bn(), which natively expects big-endian data. We
can then push these BIGNUMs into OSSL_PARAM_BLD. This delegates the
data format handling entirely to OpenSSL and successfully removes the
platform-specific code.
2026-07-03 03:02:56 +09:00
Yu Watanabe fc54be2f66 crypto-util: simplify openssl_extract_public_key()
Drop memstream and i2d_PUBKEY_fp(). We can simply use i2d_PUBKEY()
which automatically allocates the necessary buffer for us.

Note that dropping the secure erase (erase_and_freep()) in favor of
OPENSSL_free() is intentional and safe, as the buffer only holds
public key material which does not need to be securely wiped.
2026-07-03 03:02:56 +09:00
Yu Watanabe 94e8d7209e crypto-util: use correct cleanup function for OpenSSL buffers
Buffers allocated by OpenSSL must be freed with OPENSSL_free().
Fortunately, we do not enable the secure heap, so OPENSSL_free()
is currently equivalent to free(), but let's fix this for correctness.
2026-07-03 03:02:56 +09:00
Yu Watanabe c0c6a9e8e4 crypto-util: simplify pubkey_fingerprint()
There is no need to call i2d_PublicKey() twice. Passing a pointer
to NULL allows OpenSSL to automatically allocate the necessary buffer.
2026-07-03 03:02:56 +09:00
Yu Watanabe ec35f207b6 crypto-util: drop unused deprecated symbols 2026-07-03 03:02:56 +09:00
Yu Watanabe c18ee628a5 resolved: migrate ECDSA verification to OpenSSL 3 EVP API
OpenSSL 3.0 deprecated low-level Elliptic Curve (EC) key manipulation
functions (EC_KEY, EC_POINT, EC_GROUP) and direct signature verification
functions like ECDSA_do_verify().

This commit modernizes dnssec_ecdsa_verify_raw() by transitioning to the
provider-aware EVP API:
* Uses OSSL_PARAM arrays and EVP_PKEY_fromdata() to construct the EC
  public key directly from the raw octet string and curve name, avoiding
  deprecated EC_POINT parsing.
* Converts the raw R and S signature components into a DER-encoded ASN.1
  signature using i2d_ECDSA_SIG(), as required by the modern EVP API.
* Uses EVP_PKEY_verify() for the actual signature validation.

Additionally, this drops an outdated TODO comment waiting for raw ECDSA
support in the EVP API, as well as the deprecated warning suppression
macros and fallback code blocks. Unit tests for ECDSA are now run
unconditionally.
2026-07-03 03:02:56 +09:00
Yu Watanabe 13be553507 resolve: make dnssec_ecdsa_verify_raw() take struct iovec
This also
- adds missing assertions,
- moves variable declarations,
- rename variables.

No functional change, just refactoring.
2026-07-03 03:02:56 +09:00
Yu Watanabe 59fa4dd142 resolve: add unit test for dnssec_ecdsa_verify_raw() 2026-07-03 03:02:56 +09:00
Yu Watanabe cd3c0859b2 resolved: migrate RSA key construction to OpenSSL 3 EVP API
OpenSSL 3.0 deprecated low-level key manipulation functions and direct
access to RSA structures (such as RSA_new(), RSA_set0_key(), and
RSA_size()).

This commit modernizes dnssec_rsa_verify_raw() by replacing these
deprecated functions with the provider-aware EVP API:
* Uses OSSL_PARAM_BLD and EVP_PKEY_fromdata() to construct the RSA
  public key directly from the modulus and exponent BIGNUMs.
* Replaces RSA_size() with EVP_PKEY_get_size().

Consequently, the workaround macros suppressing deprecated warnings
(DISABLE_WARNING_DEPRECATED_DECLARATIONS) and the conditional fallback
blocks (#if !defined(OPENSSL_NO_DEPRECATED_3_0)) are no longer needed
and have been dropped. Unit tests are also updated to run unconditionally.
2026-07-03 03:02:56 +09:00
Yu Watanabe 918193b438 resolve: make dnssec_rsa_verify_raw() take struct iovec
This also
- adds missing assertions,
- moves variable declarations.

No functional change, just refactoring.
2026-07-03 03:02:56 +09:00
Yu Watanabe 6bf0540e93 resolve: add unit test for dnssec_rsa_verify_raw() 2026-07-03 03:02:56 +09:00
Yu Watanabe 5fec7096cf crypto-util: load several more symbols
They will be used in later commits.

Note, ECDSA_SIG_new() and ECDSA_SIG_set0() are not deprecated.
They are moved to the section for non-deprecated symbols.
2026-07-03 03:02:56 +09:00
Yu Watanabe 6268b094eb resolve: fix segfault when built with OPENSSL_NO_DEPRECATED_3_0
In that case, deprecated funcdions are not loaded from libcrypto.so,
and calling them causes segfault.
2026-07-03 03:02:56 +09:00
dongshengyuan bd1bb49ffa coredumpctl: use break instead of continue for time bound checks
When iterating journal entries with --until (forward scan) or --since
(reverse scan), the code used continue instead of break after crossing
the time boundary.

Since sd_journal_seek_realtime_usec() is called before the loop to
position at the start of the range, sd_journal_next()/previous()
returns entries in monotonically increasing/decreasing time order.
Once an entry's timestamp exceeds arg_until (or falls below arg_since
in reverse), all subsequent entries will also be out of range.

Using continue caused the entire remaining journal to be scanned
unnecessarily. journalctl uses break for the identical pattern in
src/journal/journalctl-show.c.

Fixes: #42808
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
2026-07-02 18:46:39 +02:00
Tim Schumacher e0ec80d63c udev: Tag debug appliance nodes as xaccess-debug-appliance
This is especially helpful for people who are running headless (i.e.
SSH-only) Android platform development setups with testing devices
attached.
2026-07-02 18:14:21 +02:00
Luca Boccassi 964f0607e4 man: add thread-awareness note to sd_bus/sd_event manpages
This question comes up every now and then, and it is not clearly documented,
so include the thread-aware tag in all bus/event manpages.
2026-07-02 17:04:07 +01:00
Luca Boccassi 243fcc6200 man: note that sd-tmpfiles/sysusers --root is not a sandboxing feature
This seems to be causing enough confusion that it is worth explicitly
mentioning in the docs
2026-07-02 17:02:40 +01:00
Luca Boccassi cb615e64ed report: drop redundant .generate = NULL metric initializers
The .generate field of MetricFamily defaults to NULL when omitted from a
designated initializer, so spelling it out explicitly on the metric-family
entries (and the field-generating macros) that have no generator of their
own is just noise. Drop it.
2026-07-02 17:01:02 +01:00
Luca Boccassi c32bd8b0dc core: add all manager timestamps to metrics report
These are all very useful for establishing the health of a fleet,
so export them too

Follow-up for 0b0db27050
2026-07-02 17:01:02 +01:00
r-vdp e2cda710c1 bootctl: accept makeEntryDirectory in Install Varlink method
The CLI defaults --make-entry-directory to off and lets callers opt in
or request auto mode. The Varlink Install method always ran in auto
mode with no way to override it. Expose the tri-state so IPC callers
can match the CLI behaviour.
2026-07-02 17:34:26 +02:00
r-vdp ca7fd21cf3 bootctl: accept espPath/xbootldrPath in Varlink methods
The CLI verbs have --esp-path/--boot-path but the Varlink methods
always auto-discover the partitions, so callers that mount the ESP
or XBOOTLDR at a non-standard location have to fall back to the
SYSTEMD_ESP_PATH/SYSTEMD_XBOOTLDR_PATH environment variables.
Allow to specify the paths when calling Install/Unlink/Link/LinkAuto
so the Varlink API is on par with the CLI.
2026-07-02 17:34:03 +02:00
Kai Lüke ff30101e81 vmspawn/nspawn: Always use a per-machine runtime subdirectory
Some state files were prefixed with the machine name which protected
against collisions when running concurrent machines in a systemd unit
with RuntimeDirectory= set. However, the socket files tpm.sock and
control were not, which caused a race. Prefixing these socket files
does not work because the path gets too long when both the subdirectory
and the socket file within it get unique identifiers.

Instead of prefixing all files, we can rather always create a
subdirectory and use simple names within in. This makes paths shorter
in the normal case and protects against races with RuntimeDirectory=
were instead of directly reusing RUNTIME_DIRECTORY we also create the
normal per-machine subdirectory. Since this here is about runtime state
it should not impact any running VMs/containers. The ssh-proxy looks
only at the normal case and does not support RUNTIME_DIRECTORY, so no
impact there as well.
2026-07-02 17:24:18 +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