Commit Graph

9355 Commits

Author SHA1 Message Date
Andrii Chubatiuk
5209e9cb05 journal-remote: added custom headers support 2025-03-15 07:27:38 +09:00
Lennart Poettering
520372b7ee man: document how Restart= reacts to oom kill
Fixes: #36529
2025-03-12 22:35:51 +00:00
Yu Watanabe
86cbb13a4e udev/net: enable new [EnergyEfficientEthernet] section
Also fixes a typo in setting name.

Follow-up for cdc9be29b1.
Addresses post-merge comments for #36302.
2025-03-13 05:26:14 +09:00
Yu Watanabe
b15053de89 udev/net: fix assignment of ID_NET_NAME=
E.g. sd_device object of network interface 'hoge!foo' has sysname 'hoge/foo'.
So, previously udevd assigned 'hoge/foo' rather than 'hoge!foo' to ID_NET_NAME,
hence even when renaming is not requested, such interface was renamed to 'hoge_foo'
(note '/' cannot be used in network interface name, hence escaped to underbar).
2025-03-13 01:48:33 +09:00
nkraetzschmar
0bdf94e588 boot: add reboot-on-error config option
Enabling this option will cause the system to reboot in case the selected
entry fails to load.
2025-03-12 15:47:38 +01:00
Lennart Poettering
af9c45d5b6 hostname: support that /etc/hostname contains ??? as wildcards to be replaced by hash value from /etc/machine-id 2025-03-11 18:01:42 +01:00
Mike Yuan
406aeb5da6 core/service: introduce sd_notify() RESTART_RESET=1 for resetting restart counter
We have RestartMaxDelaySec= + RestartSteps= to exponentially increase
auto restart durations, but it currently cannot be reset by the service
itself, which makes it sometimes awkward to use. A typical pattern
in real life is that a service was once down (e.g. due to temporary
network interruption) and multiple restarts were attempted. Then,
future restarts would always wait for increated amount of time based on
RestartMaxDelaySec=, even after the original problem got resolved.
Such "persistence" could result in longer unavailablity than there
should be for failures that come later.
(C.f. https://utcc.utoronto.ca/~cks/space/blog/linux/SystemdResettingUnitBackoff)

Let's introduce a new sd_notify() notification for resetting the restart
counter. There were discussions about making this timer-based, but I think
it's more flexible to leave the decision-making to the service. This enables
them to do a combination of N successful requests + uptime check for instance.
2025-03-11 00:44:44 +01:00
NetSysFire
1f0e4af329 systemd.exec(5): RestrictAddressFamilies: mention address_families(7) 2025-03-11 00:00:55 +09:00
Yu Watanabe
2792b1181f meson: bump required minimum version to 0.62.0 (#36610)
- bump the requred minimum version of meson to 0.62.0,
- use install_symlink(), which is supported since meson-0.61.0,
- use more features provided by newer meson with careful
conditionalization.

Follow-up for 8442ac9c02.
Closes #35967.
2025-03-10 07:51:28 +09:00
Lennart Poettering
ef430b84e9 vmspawn: optionally grow image 2025-03-10 03:57:46 +09:00
Yu Watanabe
e2ea2d1349 man: fix typo
Follow-ups for fd0dd2d4bc.
2025-03-10 03:23:47 +09:00
Yu Watanabe
c0cc01de8a meson: use install_symlink() where applicable
Now our baseline of meson is 0.62, hence install_symlink() can be used.

Note, install_symlink() implies install_emptydir() for specified
install_dir. Hence, this also drops several unnecessary
install_emptydir() calls.

Note, the function currently does not support 'relative' and 'force' flags,
so several 'ln -frsT' inline calls cannot be replaced.
2025-03-10 02:41:40 +09:00
Luca Boccassi
d9208ff9a4 keyutil: support adding content into PKCS#7 signature (#36663)
Support including the data that was signed inside the PKCS#7 signature.
This creates a self-contained file where the signature of the data can
be verified without any other information, since the file contains the
data, signature, and certificate (which contains the public key used for
the signing).

One use case of this is IPE which requires a PKCS#7 signature that is
not "detached", i.e. includes the IPE configuration that has been
signed.

This also slightly adjusts the test case to use the x509 certificate
inside the PKCS#7 signature instead of supplying it externally during
verification.
2025-03-08 01:42:20 +00:00
Dan Streetman
f80bb317f6 keyutil: support adding content into PKCS#7 signature 2025-03-07 18:36:23 -05:00
Lennart Poettering
0e1ede4b4b homectl: add interface for controlling storage for negative machine ID matches 2025-03-07 18:15:04 +01:00
Lennart Poettering
c7a4216509 homed: re-establish inotify watches on SIGUSR1
Let's define a clean way how we can reestablish file watches in homed.
This is a relevant in case we overmount /home/ as a whole. It's very
useful for our testcase in particular.
2025-03-07 18:15:01 +01:00
Lennart Poettering
17f48a8cc7 homectl: making stripping of signatures from user records optional 2025-03-07 18:14:52 +01:00
Lennart Poettering
cc14c14782 homectl: also support registering (rather than creating) home directories via system credentials 2025-03-07 18:14:48 +01:00
Lennart Poettering
e8801cc5b3 homectl: expose "register" verb to register a user record locally 2025-03-07 18:14:45 +01:00
Lennart Poettering
cbf9a1c888 homed: add concept for "adopting" an existing homedir locally
Currently homed scans /home/ via inotify for new .home + .homedir/
popping up to register as local users. Let's also add an explicit way to
request this form of "adoption": a bus call that takes a path and that
makes a home dir activatable locally.

(Usecase: you cross boot between two systems – let's say your traditional
fedora and your ParticleOS – and want to use the same homedir from both:
simply mount the /home dir from the other somewhere, and then hit
"homectl adopt /somewhere/lennart.home" and you have the user locally
too).
2025-03-07 18:14:25 +01:00
Lennart Poettering
87c81a34eb homectl: also import signing keys at firstboot time 2025-03-07 18:14:09 +01:00
Lennart Poettering
88392a1f60 homectl: add signing key management verbs 2025-03-07 18:14:02 +01:00
Lennart Poettering
f1b6417fea homed: add apis for managing home signing keys
This makes it easier to actually migrate home directories between
systems.
2025-03-07 18:13:40 +01:00
Lennart Poettering
fd0dd2d4bc userdbctl: optionally show user/group data from JSON filerather than from system 2025-03-07 18:13:36 +01:00
Luca Boccassi
cb26206f2f hostnamectl: show image info in hostnamectl (#36638)
On image-based systems these properties are quite fundamental, hence
show them in the hostnamed output.
2025-03-06 22:36:20 +00:00
Lennart Poettering
10b8d65f3f dissect: accept --usr-hash=… too, similar to --root-hash=…
This addresses an omission, given that we have both kinds of hashes
these days.
2025-03-06 23:35:31 +01:00
Lennart Poettering
bc60034f43 hostnamectl: show image info in hostnamectl
On image-based systems these properties are quite fundamental, hence
show them in the hostnamed output.
2025-03-06 15:28:07 +01:00
Lennart Poettering
c22948f6c2 factory-reset: rework infrastructure, make it work with gpt-auto, and add support for resetting TPM as part of factory reset (#36512) 2025-03-05 15:25:36 +01:00
Lennart Poettering
b7ba8d55b8 run0: run agents during setup, until pty forwarder takes over
When services start up they might query for passwords, or issue polkit
requests. Hence it makese sense to run the password query agent and
polkit agent from systemd-run. We already ran the polkit agent, this
also ensures we run the password query agent.

There's one tweak to the story though: running the agents and the pty
forwarder concurrently is messy, since they both try to read from stdin
(one potentially, the other definitely). Hence, let's time the agents
properly: invoke them when we initialize, but stop them once the start
job for the unit we are supposed to run is complete, and only then run
the pty forwarder.

With this in place, the following series of commands starts to work
really nicely (which previously deadlocked):

    # homectl create foobar
    # run0 -u foobar

What happens in the background in run0 is this: a new session is invoked
for "foobar", which pulls in the user@.service instance for the user.
That user@.service instance will need to unlock the homedir first. Since
8af1b296cb this will happen via the askpw
logic. With this commit here this prompt will now be shown by run0. Once
the password is entered the directory is unlocked and the real session
begins. Nice!

This new behaviour is conditioned behind --pty-late (distinct from the
existing --pty switches). For systemd-run we will never enable this mode
by default, for compat with command lines that use ExecStartPre=
(because we won't process the pty anymore during that command) For
run0 however this changes the default to --pty-late (unless
--no-ask-password is specified). This reflects the fact that run0 is
more of an interctive tool and unlikely to be used in more complex
service start-up situations with ExecStartPre= and suchlike.

This also merges JobDoneContext into RunContext, since it doesn't really
make sense to have two contexts around to communicate between outer
stack frame and event handlers. Let's just have one, and pass it around
to all handlers the same way. In particular as we should delay exit only
until both the unit's job is complete *and* in case of --wait the unit
is exited, one of the two should not suffice.
2025-03-05 13:17:50 +01:00
Lennart Poettering
1c0b8270f4 gpt-auto-generator: if root=gpt-auto-force is specified ignore factory reset state 2025-03-05 12:38:28 +01:00
Lennart Poettering
73e53d2ee4 tpm2-clear: optionally reset TPM during a factory reset 2025-03-05 12:37:51 +01:00
Lennart Poettering
41d9ed93d9 factory-reset: revamp infrastructure
This introduces a bunch of facilities:

1. The factory-reset.target unit that requests a factory reset is now
   complemented by factory-reset-now.target that executes it at next
   boot.

2. This latter is added to the initial transaction via the new trivial
   systemd-factory-reset-generator.

3. A tool systemd-factory-reset has been added to query, request,
   cancel, complete factory reset operations (via EFI variables). Two of
   these are wrapped into units that are plugged into
   factory-reset.target and factory-reset-now.target respectively. The
   tool also provides a simple Varlink API.

This should make things a lot cleaner, and both be useful as explicit
implementation on UEFI, and as template + hookpoints for alternative
implementations on non-UEFI.
2025-03-05 12:37:26 +01:00
Lennart Poettering
9e050b0458 repart: port to new factory reset state apis 2025-03-05 12:37:24 +01:00
Lennart Poettering
f0f5d54202 nspawn: add ability to poweroff container cleanly with ^]^]p
It's sometimes very useful to be able to terminate a container quickly
but cleanly while talking to it. Introduce a hotkey for that: ^]^]p for
powering it off. In similar style add ^]^]r for rebooting it.
2025-03-04 23:02:31 +01:00
Mike Yuan
bb12d57cd5 mount-tool: never bind to device on explicit x-systemd.device-bound=no 2025-03-03 10:45:57 +01:00
Lennart Poettering
f2b1de6f5b Revert "sd-json: add new sd_json_variant_unset_field() call"
This reverts commit b6a2df6307.

The functionality is entirely redundant, we already have
sd_json_variant_filter() which does the same, and is in fact even more
powerful, since it takes a list instead of a single field to remove.
2025-03-02 11:04:15 +00:00
Daan De Meyer
38701809a8 core: Add DelegateNamespaces= (#36532) 2025-03-01 15:18:45 +01:00
Daan De Meyer
8234cd9989 core: Add DelegateNamespaces=
This delegates one or more namespaces to the service. Concretely,
this setting influences in which order we unshare namespaces. Delegated
namespaces are unshared *after* the user namespace is unshared. Other
namespaces are unshared *before* the user namespace is unshared.

Fixes #35369
2025-03-01 13:54:58 +01:00
Lennart Poettering
250118f3f0 sbsign: Add support for offline signing (#36485)
Add new options --prepare-offline-signing, --signed-data= and
--signed-data-signature= which allow for offline signing in a
similar manner to pesign.
2025-02-27 17:34:05 +01:00
Daan De Meyer
8c0098d486 sbsign: Add support for offline signing
Add new options --prepare-offline-signing, --signed-data= and
--signed-data-signature= which allow for offline signing in a
similar manner to pesign.
2025-02-27 13:47:07 +01:00
Lennart Poettering
2f093d8364 man: follow our own naming rules more closely
In some examples we inserted "-initrd" after the "public-key" instead of
before when naming PEM files. Let's fix that, and stick to common
suffixes.
2025-02-27 10:08:50 +01:00
Lennart Poettering
da468d61ee man: follow our certificate/public-key/private-key PEM file naming rules
In 2cc58b6c8a and related we established
rules on naming certs/public-keys/private-keys:

*-public-key.pem
*-private-key.pem
*-certificate.pem

Let's follow that naming in repart's man page too.
2025-02-27 10:08:39 +01:00
Daan De Meyer
27e040f742 keyutil: Reword pkcs7 documentation string a little 2025-02-27 10:03:12 +01:00
Yu Watanabe
98fc082c31 man: fix typo
Follow-up for f8825c1364.
2025-02-27 13:37:20 +09:00
Daan De Meyer
461bd9277a meson: Add missing dbus_programs dependency on update-dbus-docs
All dbus programs have to be up-to-date for update-dbus-docs to
produce the expected output, so add the missing dependency.
2025-02-27 12:39:52 +09:00
Lennart Poettering
9a4f9e84c4 pam_systemd_home: tweak order in authentication stack
Let's move pam_systemd_home before pam_unix in the authentication hook.

Since a while we are exposing shadow entries for homed log entries via
NSS. This means that pam_unix now potentially has enough data for
authenticating a user on its own, without letting pam_systemd_home do
that. This is superficially OK, but also means that authentication will
always go via password, even if pkcs11/fido2 is registered.

Let's move this around, but be careful about it: let's list the precise
errors which we think are enough to terminating further PAM processing,
so that pam_unix comes into control in all cases where it's not clear
that pam_systemd_home owns the user record.

This previously wasn't visible to me, because on Fedora until authselect
1.5.1 (released earleir this year) the NSS shadow stuff was not enabled.

This does the same also for the "account" stack, except that the order
there already was as we want it.

Finally, shorten the account stack, by just requiring pam_unix.so and
dropping pam_permit.so, because it doesn't really serve much purpose
(and Fedora doesn't use it by default either.)
2025-02-26 18:12:08 +01:00
Lennart Poettering
14871a6529 efivars: kill SystemdOptions efi var support
This has been depracted since v254 (2023). Let's kill it for
good now, it has been long enough with 2y. Noone has shown up who wants
to keep it. And given it doesn't work in SB world anyway, and is not
measured is quite problematic security wise.
2025-02-26 17:28:43 +01:00
Mike Yuan
c578bf6e17 Expose chassis asset tag in hostnamed (#36487)
Closes #36442
2025-02-26 14:28:26 +01:00
Markus Kurz
2006e341d3 udev_device_has_tag: fix typo 2025-02-26 20:34:15 +09:00
Jelle van der Waa
7e638ccf59 hostnamed: expose ChassisAssetTag in dbus/varlink
Expose /sys/class/dmi/id/chassis_asset_tag in varlink/dbus commonly used
by companies to track inventory such as laptops.

On desktops and other products the `chassis_asset_tag` can contain
rubbish similar to product_name/product_vendor.

Closes: #36442
2025-02-26 11:29:25 +01:00