Commit Graph
79908 Commits
Author SHA1 Message Date
Lennart Poettering 4efd46c44b terminal-util: during terminal reset clear from beginning of line to end of screen
tianocore does some weird shit with its terminal emulation and regular
fills half the terminal with grey background and then invokes us with
this not cleared up. Hence let us clear this up for it: as part of the
ansi sequence based reset let's position the cursor explicitly at the
beginning of the current line, and erase everything till the end of the
screen. This makes boot output in tianocore vms much much cleaner.

Note that this does *not* erase any terminal output *before* the cursor
position where we take over, because that typically contains valuable
information still we should not erase.
2025-03-06 22:32:32 +00:00
Lennart Poettering 4d44670dc6 update TODO 2025-03-06 23:11:20 +01:00
Lennart Poettering 457f4cfbba update TODO 2025-03-06 22:32:30 +01:00
Lennart Poettering 8ef9ceb7e5 Factory reset followup (#36621)
@poettering hrm, there's still one thing unclear to me: we currently
have no way for canceling factory reset via IPC. And adding that to
varlink service solely doesn't seem feasible either, since the state
departs from the active state of `factory-reset.target` and it would
become impossible to re-request it without restarting
`factory-reset.target` _and all dependencies_, which feels
unmaintainable.
2025-03-06 17:43:04 +01:00
Lennart Poettering e0a634d520 docs: mention when /var/ has to be writable
In light of https://github.com/systemd/systemd/issues/36635 let's
clarify things a bit regarding writability of /var/.
2025-03-06 17:26:27 +01:00
Lennart Poettering bc0763551f sysext,sysupdate: resolve incompatibilities (#36617)
Fixes #24562.
Fixes #34445.
Replaces #36311.
2025-03-06 14:05:35 +01:00
Lennart Poettering 729620b846 udev-builtin-blkid: ignore root partitions with name "_empty"
This is how sysupdate marks empty partitions, hence ignore that.

Kinda a follow-up for 54ae0edc4a
2025-03-06 14:05:14 +01:00
Yu Watanabe 5c9feb2d6e tree-wide: drop unnecessary break in default branch 2025-03-06 11:42:20 +01:00
Lennart Poettering c65f40b1a1 update TODO 2025-03-06 11:30:06 +01:00
Lennart Poettering 399c7187f7 gpt-auto: image policy fixes (#36629)
Let's make sure we can define a proper image policy on ParticleOS
images.
2025-03-06 11:27:35 +01:00
Lennart Poettering de4144cfc3 sysupdate: don't get confused by sysext on /usr/
Fixes: #24562
2025-03-06 10:27:55 +01:00
Lennart Poettering 02d0848df3 sysext: export backing devnum in metadata dir 2025-03-06 10:27:55 +01:00
Lennart Poettering 42c589eae5 sysext: execute merge even if no extensions are installed as long as --mutable= is on
This way we can make an immutable OS mutable, without any extensions or
so.

Fixes: #34445
2025-03-06 10:27:51 +01:00
Lennart Poettering 6d6538fb3f gpt-auto-generator: do not apply image policy on the root fs and /usr/ fs
At the moment the gpt-auto generator does its things we already
transitioned into the host OS, i.e. the root fs and /usr/ are mounted.
Hence suppress image policy checks for those two partitions.

This actually matters, because the root hash/usr hash is taken into
consideration for the image policy checks, but we don't have that in
gpt-auto and hence would refuse operation claiming policy conflicts
event though we never actually operate on the root fs via the dissection
logic.
2025-03-06 09:42:18 +01:00
Lennart Poettering 87bffa1eae gpt-auto-generator: move around in_initrd() tests
The partition enumeration only runs on the main system, and we test that
early, hence no point in repeating this in functions further down the
call chain. But let's keep it in place as assert()s, just in case.

Also, move the top-level in_initrd() into add_mounts(), so that the
tests are nicely encapsulated in the code they protect.
2025-03-06 09:42:15 +01:00
Lennart Poettering e706cadce5 image-policy: add image_policy_ignore_designators() helper
This new helper patches a provide image policy, setting the policy for
specified designators to "ignore".

This is useful for contexts where we only want to mount some subset of
the available partitions, and hence don't care about the parts of the
policy that cover the others. Specifically this is useful in
systemd-gpt-auto-generator, which runs at a moment the root file system
is already established, and hence the policy for the root file system
can be ignored, the facts are already established.
2025-03-06 09:41:46 +01:00
Luca Boccassi c0af4859d0 mkosi: update debian commit reference
* dfdab6b205 Install new files
* e00bee5b4a Install new files
2025-03-06 08:59:25 +09:00
Daan De Meyer ba6a152000 mkosi: update fedora commit reference
* 4ab2a9e539 Drop old self-Obsoletes and provides
* ec182495e7 Drop libbpf versioned dependency version to 1.4.7
* 1f8d2b0ebd Make self-obsoletes for the sysusers split conditional
* 0d95af264f Include epoch in versioned libbpf dependency
* 8230f501b6 Make sure we pull in libbpf >= 1.5.0 if libbpf is installed
2025-03-06 08:59:10 +09:00
Daan De Meyer 4435dd7c72 mkosi: Don't install dnf anymore on Fedora
We have dnf5 on Fedora, no need to install dnf there anymore
2025-03-05 21:36:22 +00:00
Lennart Poettering 3568c47664 dissect: show basic image data even when can't enter the file systems 2025-03-05 21:21:36 +01:00
Mike Yuan 911de19c72 hibernate-resume-config: log louder on invalid kernel version/os-release id
Prompted by 45623d4ad6

We do make use of the os-release ids to determine whether to initial resume
if they're present, hence log at warning level if invalid. While at it,
raise the level for the kernel version too, which is generally interesting
to the user if something goes wrong.
2025-03-05 17:18:21 +01:00
Mike Yuan 97be702ffc factory-reset-tool: error out if we can't cancel pending reset
First of all, it seems very unlikely that we'd be in the pending state
if not booted via EFI in the first place. Moreover, the operation didn't
work out, hence let's not spurious report success.
2025-03-05 17:17:21 +01:00
Yu Watanabe 050094e65c tpm2-clear: fix typo
Follow-up for 73e53d2ee4.
2025-03-06 01:09:15 +09:00
Yu Watanabe c07fdf7b94 factory-reset: fix typo
Follow-up for 41d9ed93d9.
2025-03-06 01:07:42 +09:00
Mike Yuan f1d790a18b tpm2-clear: make it clear that we default to true for systemd.tpm2_allow_clear 2025-03-05 17:04:00 +01:00
Mike Yuan 5c7b3335db tpm2-clear: make getenv() failure fatal, correct one log level
This operation is destructive, and we bail if the proc_cmdline_get_bool()
call below fails already. Better be safe than sorry.
2025-03-05 17:03:59 +01:00
Mike Yuan ab4c84b0e9 tpm2-clear: use plain DEFINE_MAIN_FUNCTION
We don't return any positive exit status.
2025-03-05 17:03:59 +01:00
Mike Yuan 28ac3309d7 units/meson: remove unneeded linebreak 2025-03-05 17:03:59 +01:00
Mike Yuan 651b44bdda units: refuse manual operations on factory-reset-now.target and friends
It is strictly mandatory that this is done during initial
transaction, and not later when the system is already running.
Hence let's refuse manual start for all of the involved units.
Additionally, refuse manual stop for systemd-factory-reset-complete.service,
as it flags the factory reset completion through
/run/systemd/factory-reset-complete, which never gets removed
for the whole boot.
2025-03-05 17:03:59 +01:00
Thorsten Kukuk 54cd851bd9 sysupdate: fix features and vaccum if all features are disabled
If all transfer definitions are features and disabled, a wrong error
is reported that there are no transfer definitions.
This breaks the features and vaccum verb, as they work on disabled
features, too.
2025-03-06 00:53:27 +09: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
Yu Watanabe b690298d7a sd-varlink: fix typo
Follow-up for 837849561b.
2025-03-05 23:17:36 +09:00
Yu Watanabe 7ae2ea52ac TODO: fix typo
Follow-up for 31ec0d8a2e.
2025-03-05 23:17:36 +09:00
Luca Boccassi 383df6ff06 test-async: Wait for asynchronous_sync() to finish (#36611)
Otherwise, if the system is busy, TEST-02-UNITTESTS will fail as
systemd will time out trying to kill the transient unit that we're
running test-async in.
2025-03-05 12:36:45 +00: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 0f2425b2fc update TODO 2025-03-05 12:38:46 +01:00
Lennart Poettering 14ab9aafc2 gpt-auto: add common parse_gpt_auto_root() parser 2025-03-05 12:38:33 +01:00
Lennart Poettering 1ed0f6e9bf docs: document factory reset logic 2025-03-05 12:38:30 +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 c7da91ff66 gpt-auto symlinks: take factory reset mode into consideration
In relevant factory reset situation the root disk itself is subject to
removal. This somewhat conflicts with automatic root disk discovery,
since the system first comes up with one candidate for the root disk,
which is then replaced by another.

Let's address this by determining at the moment of probing for the
gpt-root logic what the factory reset state currently is. This is then
used to maintain two distinct symlinks to the gpt auto root device: one
which is always available and one that is only available if factory
reset is off or complete.

The new symlinks is not used by anything yet. This will be added in a
later commit.
2025-03-05 12:38:25 +01:00
Lennart Poettering 9f0c830b5f udev: add builtin that reports current factory reset state 2025-03-05 12:38:13 +01:00
Lennart Poettering 73e53d2ee4 tpm2-clear: optionally reset TPM during a factory reset 2025-03-05 12:37:51 +01:00
Lennart Poettering daae8f858d units: also require /dev/tpm0 to be around before tpm2.target can be reached
While we typically just use /dev/tpmrm0 for accessing the TPM chip (i.e
via the kernel's own resource manager), some sysfs properties that
matter are on /dev/tpm0 only (i.e. the version without the kernel TPM
resource manager). Hence, wait for both to show up in tpm2.target, so
that we can be sure the full API is available.

This matters because we want to access /sys/class/tpm/tpm0/ppi/request
in the next commit.
2025-03-05 12:37:48 +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 45623d4ad6 shared: add generic factory reset state apis
Let's provide a generic implementation of the systemd.factory_reset
kernel cmdline checking repart implements. Moreover add support for
leaving the factory reset state again.

This only establishes the basic APIs, it does not hook them up with
anything.
2025-03-05 12:37:03 +01:00
Luca Boccassi 7eb1cd2f0c Ukify tweaks (#36389) 2025-03-05 11:26:47 +00:00
Aaron Rogers 08633ea902 cryptsetup: align tpm2-blob 2025-03-05 11:41:30 +01:00
Lennart Poettering 31ec0d8a2e update TODO 2025-03-05 11:40:46 +01:00
Zbigniew Jędrzejewski-Szmek 6446c7d99b ukify: avoid treating invalid option as an argument
For some reason, argparse treats undefined options as positional args in
certain scenarios:

$ src/ukify/ukify.py --badopt='11'
ukify.py: error: unrecognized arguments: --badopt=11
$ src/ukify/ukify.py --badopt '11'
ukify.py: error: unrecognized arguments: --badopt
$ src/ukify/ukify.py --badopt '11 12'
Assuming obsolete command line syntax with no verb. Please use 'build'.
Traceback (most recent call last):
  File "/home/zbyszek/src/systemd/src/ukify/ukify.py", line 2497, in <module>
    main()
    ~~~~^^
  File "/home/zbyszek/src/systemd/src/ukify/ukify.py", line 2485, in main
    check_inputs(opts)
    ~~~~~~~~~~~~^^^^^^
  File "/home/zbyszek/src/systemd/src/ukify/ukify.py", line 671, in check_inputs
    value.open().close()
    ~~~~~~~~~~^^
  File "/usr/lib64/python3.13/pathlib/_local.py", line 537, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '--badopt=11 12'

I suspect that this is some crap compat for Windows, where option parsing is
an even bigger mess than here.

Being told about positional args, when no positional args were specified is
confusing, so add a check for this.
2025-03-05 11:17:33 +01:00