Commit Graph
56861 Commits
Author SHA1 Message Date
Yu Watanabe 82b6dc1a17 sd-json: accept NULL path in sd_json_parse_file_at() too, port one manual fdopen() to it (#39538) 2025-11-05 01:40:27 +09:00
jouyouyun 2b8c7adbec cgls: print error messages when --unit and --user-unit are used together
Mixing the `--unit` and `--user-unit` options will result in error messages.
During the parsing phase, only the `arg_show_unit` record of the last
occurrence of the option is used; all names are placed in the same `arg_names`,
thus mixing the two types of units in the query.

For example, `-u foo --user-unit bar` will also treat `foo` as a user unit and
query it in the user service.
2025-11-05 01:38:18 +09:00
Chris Down a8c3ac6672 systemctl: Fix shutdown time parsing across DST changes
When parsing an absolute time specification like `hh:mm` for the
`shutdown` command, the code interprets a time in the past as "tomorrow
at this time". It currently implements this by adding a fixed 24-hour
duration (`USEC_PER_DAY`) to the timestamp.

This assumption breaks across DST transitions, as the day might not be
24 hours long. This can cause the shutdown to be scheduled at the wrong
time (typically off by one hour in either direction).

Change the logic to perform calendar arithmetic instead of timestamp
arithmetic. If the calculated time is in the past, we increment
`tm.tm_mday` and call `mktime_or_timegm_usec()` a second time.

This delegates all date normalization logic to `mktime()`, which
correctly handles all edge cases, including DST transitions, month-end
rollovers, and leap years.

Fixes: https://github.com/systemd/systemd/issues/39232
2025-11-05 01:36:47 +09:00
jouyouyun 05b880ac46 nss-myhostname: use FAMILY_ADDRESS_SIZE instead of the integer 16 when copying ip addr
To avoid copying extra characters when using IPv4.
2025-11-05 01:33:31 +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
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
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
Mike Yuan d98c783516 sysupdated: port to sd_json_parse_file_at() 2025-11-04 10:46:01 +01:00
Mike Yuan 89b9a68e5f sd-json: accept NULL path in sd_json_parse_file_at() too 2025-11-03 22:32:57 +01:00
Mike Yuan eaebc33220 fileio: mask off O_NOFOLLOW in xfopenat_regular() for fd_reopen()
in a similar fashion as xopenat_full()
2025-11-03 22:32:25 +01:00
jouyouyun 10cdb58690 backlight: fix typo 2025-11-03 11:07:46 +00:00
jouyouyun 49ca2d8778 bootctl: fix typo 2025-11-03 11:30:42 +01:00
Lennart Poettering f8fcf7de7c kernel-install: move staging area to /var/tmp/
The generated files (UKIs...) can potentially be huge, hence create them
in /var/tmp/, rather than /tmp/.
2025-11-03 09:01:44 +01:00
Lennart Poettering d73d369133 analyze: add new verb for determining NvPCR values 2025-11-02 21:14:35 +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 8a6e77f1a8 tpm2-setup: measure "anchor" extension early at boot into nvpcrs 2025-11-02 21:14:35 +01:00
Lennart Poettering 2da86d62ff tpm2-setup: split out SRK setup into a function of its own 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 b95912446e pcrlock: make sure we can parse nv_index measurement records in TCG CEL
Make the systemd-pcrlock tool compatible with TCG CEL records that
encode measurements into nvindexes rather than PCRs.

This doesn't add code for actually predicting them, but just makes sure
we can parse them correctly and display them reasonably.
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 d2d1fc59b4 conf-files: optionally truncate suffix from discovered files 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
Lennart Poettering 7ecc69c33b fileio: add new flag READ_FULL_FILE_VERIFY_REGULAR() that checks if file we operate on is regular 2025-11-02 21:14:35 +01:00
Lennart Poettering 1acec1c890 fileio: make filename/path argument optional in xfopenat_full(), read_full_file_full() 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 4f589e8a50 resolvectl: fix typo
Follow-up for 7517e41a49.
2025-11-02 17:00:23 +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 c604b78b92 repart: drop OpenSSL specific logics when OpenSSL support is disabled 2025-11-02 16:07:46 +09:00
Yu Watanabe e3ae29ead7 repart: merge common conditions
No functional change, just refactoring.
2025-11-02 16:07:46 +09:00
Yu Watanabe 6e91c5d8ea repart: make sign_verity_roothash() take Context
No functional change, just refactoring.
2025-11-02 16:07:46 +09:00
Yu Watanabe 0158eabb01 repart: load x509 certificate and private key after Context is allocated
This splits out context_load_keys() from parse_argv().
No functional change, just refactoring.
2025-11-02 16:07:46 +09:00
Yu Watanabe 219a67c131 bootctl: return earlier when secure boot auto-enrollment is requested but OpenSSL support is disabled 2025-11-02 16:07:46 +09:00
Yu Watanabe 1b48b63b51 bootctl: move conditions into corresponding 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