Commit Graph

10330 Commits

Author SHA1 Message Date
Nick Rosbrook
34be1fadde resolve: add delegate info to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:58 -05:00
Chris Down
8ab6925c5e systemctl: Support --timestamp for otherwise named properties
`systemctl show`'s `--timestamp` flag is supposed to reformat all
timestamp-based properties. However, the logic for detecting these
properties was incomplete and only checked if the name ended in
Timestamp.

Expand the check to explicitly include some non-"timestamp" named
properties that really are timestamps.

Fixes: https://github.com/systemd/systemd/issues/39282
2025-11-06 07:45:06 +09:00
Yu Watanabe
f91fd8d5a1 tar-util: fix typo
Follow-up for 4ded7f7a43.
2025-11-05 18:17:23 +09:00
Yu Watanabe
5963cdf498 tree-wide: add missing '#pragma once' 2025-11-05 05:16:34 +09:00
Yu Watanabe
71d64f0527 core/service: reload fixlets (#39376)
Fixes https://github.com/systemd/systemd/issues/37515
2025-11-05 02:54:38 +09:00
Yu Watanabe
cfc7fd426d sysext: Check for /etc/initrd-release in given --root= tree (#39473) 2025-11-05 02:51:25 +09:00
Lennart Poettering
78a738f4cf tar-util: squash high UIDs in user mode 2025-11-04 14:12:39 +01:00
Lennart Poettering
4ded7f7a43 tar-util: add support for acls 2025-11-04 14:12:39 +01:00
Lennart Poettering
e1e170feca tar-util: add support for file flags 2025-11-04 14:12:39 +01:00
Lennart Poettering
a54f4520f3 tar-util: properly deal with sparse files
The extractor already deals with sparse files properly (because
archive_read_data_into_fd() does).

Let's also make sure the archiver also does this, and attaches the
necessary sparse file metadata to each file.
2025-11-04 14:12:39 +01:00
Lennart Poettering
63bf3ca8b0 tar-util: recognize hardlinks when generating tarballs 2025-11-04 14:12:39 +01:00
Lennart Poettering
d4d94fceba tar-util: include xattrs in generated tarballs
We can already unpack them, let's pack them up to.
2025-11-04 14:12:39 +01:00
Lennart Poettering
f89c914968 acl-util: add new acl_set_perm() helper 2025-11-04 14:12:39 +01:00
Kai Lueke
570eae5007 sysext: Check for /etc/initrd-release in given --root= tree
Both sysext and confext used the host's /etc/initrd-release file even
when --root=/somewhere was specified. A workaround was the
SYSTEMD_IN_INITRD= env var but without knowing this it was quite
confusing. Aside from users validating their extensions, the primary
use case for this to matter is when the extensions are set up from the
initrd where the initrd-release file is present when running but we want
to prepare the extensions for the final system and thus should match
for the right scope.
Make systemd-sysext check for /etc/initrd-release inside the given
--root= tree. An alternative would be to always ignore the
initrd-release check when --root= is passed but this way it is more
consistent. The image policy logic for EFI-loader-passed extensions
won't take effect when --root= is used, though.
2025-11-04 22:10:50 +09:00
Lennart Poettering
030f239a19 varlink-idl: add infra to test our enum parsers against varlink IDL enums
In many cases we want to expose enums for which we have the usual
xyz_to_string()/xyz_from_string() via Varlink as enums. Let's add some
infra to test the tables against each other, to automatically detect
when they deviate.

In order to implement this properly, let's export/introduce clean
json_underscorefy()/json_dashify(), for dealing with the fact that our
enums usually use dash separates ames, but Varlink doesn't allow that.

(This does not add the test cases for all enum types we expose right
now, but only adds the general infra).
2025-11-04 11:46:17 +00:00
Mike Yuan
b03e1b09af core/service: rework ExecReload= + Type=notify-reload interaction, add ExecReloadPost=
When Type=notify-reload got introduced, it wasn't intended to be
mutually exclusive with ExecReload=. However, currently ExecReload=
is immediately forked off after the service main process is signaled,
leaving states in between essentially undefined. Given so broken
it is I doubt any sane user is using this setup, hence I took a stab
to rework everything:

1.  Extensions are refreshed (unchanged)
2.  ExecReload= is forked off without signaling the process
3a. If RELOADING=1 is sent during the ExecReload= invocation,
    we'd refrain from signaling the process again, instead
    just transition to SERVICE_RELOAD_NOTIFY directly and
    wait for READY=1
3b. If not, signal the process after ExecReload= finishes
    (from now on the same as Type=notify-reload w/o ExecReload=)
4.  To accomodate the use case of performing post-reload tasks,
    ExecReloadPost= is introduced which executes after READY=1

The new model greatly simplifies things, as no control processes
will be around in SERVICE_RELOAD_SIGNAL and SERVICE_RELOAD_NOTIFY
states.

See also: https://github.com/systemd/systemd/issues/37515#issuecomment-2891229652
2025-11-04 12:18:33 +01:00
Quentin Deslandes
79dd24cf14 core: Add UserNamespacePath=
This allows a service to reuse the user namespace created for an
existing service, similarly to NetworkNamespacePath=. The configuration
is the initial user namespace (e.g. ID mapping) is preserved.
2025-11-04 10:55:04 +01:00
Lennart Poettering
e5a2e78665 cryptsetup: automatically measure used keyslot and mechanism (i.e. fido2, tpm2, pkcs11) to an NvPCR
Fixes: #29877
2025-11-02 21:14:35 +01:00
Lennart Poettering
0196abbd10 pcrextend: automatically measure SMBIOS product ID at boot
Now that PCRs are not that expensive anymore, let's use them to measure
the SMBIOS product ID to one.
2025-11-02 21:14:35 +01:00
Lennart Poettering
2b90bf1730 pcrextend: make use new nvindex-based PCRs 2025-11-02 21:14:35 +01:00
Lennart Poettering
b0c5c6aad8 tpm2-util: add infra for allocating nvindex-based PCRs (aka "NvPCRs")
We'd like to measure various additional things into PCRs, but all
available ones to the OS are already used for various purposes. Hence,
let's introduce a new concept of "NV Index based PCRs", i.e. let's use
TPM2 nv indexes of type TPM2_NT_EXTEND that mostly behave like real
PCRs, but which we can allocate relatively freely from the nv index
space. Let's call these "fake" PCRs "NvPCRs".

My original intention was to get a fixed NV index range assigned from
the TCG, either for Linux or for systemd as a project, but this stalled
with no further updates from the TCG for more than a year and a half
now. I was told an NV index range to use though, even if it never was
officially assigned, hence this PR uses this by default. But the range
is configurable at build time, on purpose, so that downstreams have some
flexibility to change this if they want. To abstract the actual nvindex
number away we introduce a naming concept, so that nvindexes are
referenced by name string rather than number.

NvPCRs are defined in little JSON snippets in /usr/lib/nvpcr/*.nvpcr,
that match up index number and name, as well as pick a hash algorithm.

There's one complication: these nvindex (like any nvindex) can be
deleted by anyone with access to the TPM, and then be recreated. This
could be used to reset the NvPCRs to zero during runtime, which defeats
the whole point of them. Our way out: we measure a secret as first thing
after creation into the NvPCRs. (Or actually, we measure a per-NvPCR
secret we derive from a system secret via an HMAC of the NvPCR name) and
the nvindex handle). This "anchoring" secret is stored in /run/ +
/var/lib/ + ESP/XBOOTLDR (the latter encrypted as credential, locked to
the TPM), to make it available at the whole runtime of the OS.
2025-11-02 21:14:35 +01:00
Lennart Poettering
b7e072f3fa tpm2-util: move parse for tpm2 hash algorithms up 2025-11-02 21:14:35 +01:00
Lennart Poettering
260b9e8489 tpm2-util: make tpm2_undefine_policy_nv_index() generic
We can use this to remove any kind of nvindex, hence give it a generic
name.

Also instead of passing "NONE" as session if none is specified, pass
PASSWORD instead, so that the function actually becomes useful if no
session is specified (the only user so far, pcrlock always provides a
session, hence this is no change in behaviour).
2025-11-02 21:14:35 +01:00
Lennart Poettering
d412b1629c tpm2-util: rename tpm2_extend_bytes()→tpm2_pcr_extend_bytes() and make it take struct iovec
We soon want to add the ability to extend into nvindexes in addition to
PCRs, hence rename the function to make clear it is about pcr extension.

While we are at it, switch things over to "struct iovec" as we generally
try to do it now in tpm2-util.[ch] these days.
2025-11-02 21:14:35 +01:00
Lennart Poettering
3e9ff7c0d8 creds-util: initialize default PCR mask in encrypt_credential_and_warn()
If UINT32_MAX is passed in the PCR masks pick some reasonable defaults
in encrypt_credential_and_warn().

These defaults copy what "systemd-creds encrypt" uses. By adding these
defaults to the internal functions any user of them can take benefit of
them.
2025-11-02 21:14:35 +01:00
Lennart Poettering
ffe958b98f creds-util: add helper for querying system credential dirs
The dirs are constant string, but let's make them overridable via env
vars for debugging purposes.
2025-11-02 21:14:35 +01:00
Lennart Poettering
c30e3d7290 creds-util: add automatic mode for tpm2 based creds
This reworkds TPM2 based creds a bit. Instead of mapping the key type
"tpm2" directly to a TPM2 key without PK, let's map it to an "automatic"
key type that either picks PK or doesn't, depending on what's available.
That should make things easier to grok for people, as the nitty gritty
details of PK or not PK are made autmatic. Moreover it gives us more
leverage to change the TPM2 enrollment types later (for example, we
definitely want to start pinning SRK, and hook up pcrlock too, for
creds, which we currently don't).

This hence adds a new _CRED_AUTO_TPM2
pseudo-type we automatically maps to CRED_AES256_GCM_BY_TPM2_HMAC_WITH_PK
or CRED_AES256_GCM_BY_TPM2_HMAC depending if PK as available. Similar,
_CRED_AUTO_HOST_AND_TPM2 is added, which does the same for the
host/nonhost cred type.

This does not introduce any new type on the wire, it just changes how we
select the right key type.

To make the code more readable this also adds some categorization macros
for the keys, instead of repeating the list of key types at multiple
places.
2025-11-02 21:14:35 +01:00
Lennart Poettering
86279dc970 format-table: add field type that outputs hex values prefixed with 0x 2025-11-02 21:14:35 +01:00
Yu Watanabe
c29e304562 Several OpenSSL related cleanups (#39455) 2025-11-02 17:21:51 +09:00
Alberto Planas
ab1f4e506f repart: support "nodatacow" in btrfs subvolumes
In btrfs-progs 6.15 it is planned to add a new parameter in mkfs.btrfs
--inode-flags, that can set attributes for subvolumes, directories, and
files.

The current supported attributes are "nodatacow", to disable CoW, and
"nodatasum", to disable the checksum.

This commit extend the "Subvolunes=" option to understand the
"nodatacow" flag for subvolums only.

If RepartOffline is enabled it will build the image without loopback
devices, using the correct --inode-flags parameters.

If RepartOffline is disabled it will use loopback devices and set the
btrfs attributes accordingly.

Signed-off-by: Alberto Planas <aplanas@suse.com>
2025-11-02 17:13:31 +09:00
Yu Watanabe
eeedea94da repart: fix typo
Follow-up for 15734190c7.
2025-11-02 17:03:03 +09:00
Yu Watanabe
b7d752a67e openssl-util: drop unnecessary functions when OpenSSL support is disabled 2025-11-02 16:07:46 +09:00
Yu Watanabe
84946f12b5 openssl-util: sort cleanup functions 2025-11-02 16:07:46 +09:00
Yu Watanabe
61d1f394cc openssl-util: drop unused fake type definitions when OpenSSL is disabled 2025-11-02 16:07:46 +09:00
Yu Watanabe
09ae1c8ade pe-binary: drop pe_hash() and friends when OpenSSL support is disabled
These three functions are currently only used by sbsign, which requires
OpenSSL. Moreover, pe_hash() and uki_hash() anyway do not work if
OpenSSL is disabled. Let's only declare them when OpenSSL support is
enabled.
2025-11-02 16:07:46 +09:00
Yu Watanabe
ab9b3bec6a openssl-util: drop unused string_hashsum() and friends when OpenSSL is disabled 2025-11-02 16:07:46 +09:00
Yu Watanabe
ee3cd7890d Several cleanups for libcryptsetup dependency (#39452) 2025-11-02 08:07:15 +09:00
Lennart Poettering
5f076e44fe repart: report vendor/model/subsystem fields in ListCandidateDevices
Prompted by: #39435
2025-11-01 22:01:35 +01:00
Lennart Poettering
ea94a05f8a blockdev-list: switch to log_device_xyz() style logging 2025-11-01 22:01:35 +01:00
Lennart Poettering
63b9c8611d repart: sort input before output parameters in varlink IDL 2025-11-01 22:01:35 +01:00
Lennart Poettering
0f9d58cc36 repart: add knobs for automatically deferring all partitions marked as empty or for factory reset 2025-11-01 22:01:35 +01:00
Lennart Poettering
1c76e204d3 repart: send out progress information via varlink (if more flag is given)
And while we are at it, also send it out via sd_notify()
2025-11-01 22:01:35 +01:00
Lennart Poettering
15734190c7 repart: add Varlink call that runs repart's engine 2025-11-01 22:01:34 +01:00
Yu Watanabe
db1f63463a cryptsetup-util: sym_crypt_free() and friends are unused when libcryptsetup is disabled 2025-11-02 05:50:31 +09:00
Yu Watanabe
6afaa7fb3a cryptsetup-util: sort loaded function prototypes 2025-11-02 05:50:31 +09:00
Yu Watanabe
f8c33b1274 libcryptsetup: drop several unnecessary checks for existences of functions by libcryptsetyp
The functions crypt_set_metadata_size() and friends are supported since
libcryptsetup-2.0.

This also merges checks for functions used for supporting libcryptsetup
plugins with others.
Moreover, check existence of one more function (crypt_logf) that is used in
libcryptsetup plugins.
2025-11-02 05:49:29 +09:00
Daan De Meyer
10e82fde7b parse-util: Add parse_capability_set()
Let's extract common capability parsing code into a generic function
parse_capability_set() with a comprehensive set of unit tests.

We also replace usages of UINT64_MAX with CAP_MASK_UNSET where
applicable and replace the default value of CapabilityBoundingSet
with CAP_MASK_ALL which more clearly identifies that it is initialized
to all capabilities.

AI (copilot) was used to extract the generic function and write the
unit tests, with manual review and fixing afterwards to make sure
everything was correct.
2025-11-02 04:47:21 +09:00
Daan De Meyer
1a3b3c57c6 test: migrate test-load-fragment to use ASSERT_* macros
Replace all assert_se() calls with appropriate ASSERT_* macros from tests.h:
- assert_se(r >= 0) → ASSERT_OK(r)
- assert_se(r == 0) → ASSERT_OK_ZERO(r)
- assert_se(r == -ERR) → ASSERT_ERROR(r, ERR)
- assert_se(expr == value) → ASSERT_EQ(expr, value)
- assert_se(str1, str2) → ASSERT_STREQ(str1, str2)
- assert_se(ptr) → ASSERT_NOT_NULL(ptr)
- assert_se(!ptr) → ASSERT_NULL(ptr)
- assert_se(expr) → ASSERT_TRUE(expr)
- assert_se(!expr) → ASSERT_FALSE(expr)

Also added unsigned suffixes (U) to numeric literals in comparisons with
unsigned types (size_t, rlim_t) to eliminate signedness warnings.

This code was written with the help of AI.
2025-11-02 04:47:21 +09:00
Yu Watanabe
7829c9cc48 discover-image: introduce bus_property_get_image_is_read_only() with BUS_DEFINE_PROPERTY_GET() macro
This also makes image_is_read_only() return bool.

Follow-up for ee327e086e.
2025-11-01 18:11:18 +09:00
Yu Watanabe
cbd8a12bce Several cleanups around strv_extendf() (#39508) 2025-11-01 18:10:42 +09:00