mirror of
https://github.com/systemd/systemd.git
synced 2026-08-09 17:38:42 +00:00
Add a --firstboot mode that interactively walks the user through enrolling a passphrase, a recovery key, or a FIDO2 token, with one menu entry per suitable token currently plugged in (driven by a new fido2_enumerate_devices() helper). Pressing enter at the top-level menu leaves the volume unchanged; for each already-enrolled credential type the wizard offers to wipe it as part of the operation. It populates the same EnrollContext the command line and Varlink paths use, so the actual enrollment goes through the shared enroll_now() path. A companion --prompt-suppress= option takes a list of slot types: if a slot of any listed type already exists, the wizard does nothing and exits successfully. This lets it be hooked into the boot process while staying quiet once the system has been set up. The accompanying systemd-cryptenroll-firstboot.service runs this from the initrd, after systemd-repart has created the encrypted volume but before we transition to the host, suppressing itself once a password, recovery key or FIDO2 token is enrolled. To make that work, determine_default_node() now looks below /sysroot/ when running in the initrd, since the host file systems aren't at their final location yet. While the wizard is active it draws the same installer-style chrome (blue bars at the top and bottom of the terminal) as systemd-sysinstall, using the shared prompt_loop_yes_no() helper for its wipe confirmations. Honours the systemd.firstboot= kernel command line option. Fixes: #36298
42 lines
1.6 KiB
Desktop File
42 lines
1.6 KiB
Desktop File
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
#
|
|
# This file is part of systemd.
|
|
#
|
|
# systemd is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU Lesser General Public License as published by
|
|
# the Free Software Foundation; either version 2.1 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# Runs from the initrd: once systemd-repart has created/grown the partitions
|
|
# (including any encrypted ones) on first boot, but before we transition into
|
|
# the host, give the user a chance to interactively enroll a disk encryption
|
|
# credential.
|
|
|
|
[Unit]
|
|
Description=Interactive Disk Encryption Setup
|
|
Documentation=man:systemd-cryptenroll(1)
|
|
|
|
ConditionPathExists=/etc/initrd-release
|
|
|
|
# We want a first boot check, but in the initrd that's not a defined
|
|
# state. Hence let's look into the mounted image directly for the primary
|
|
# indicator for the first boot state
|
|
ConditionFileNotEmpty=!/sysroot/etc/machine-id
|
|
ConditionPathIsEncrypted=/sysroot/var
|
|
|
|
DefaultDependencies=no
|
|
After=systemd-repart.service systemd-vconsole-setup.service systemd-mute-console.socket initrd-fs.target
|
|
Conflicts=shutdown.target initrd-switch-root.target
|
|
Before=shutdown.target initrd-switch-root.target initrd.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
RemainAfterExit=yes
|
|
# Ignore failures: there might not be an encrypted volume to enroll into, or the
|
|
# user might decline, neither of which should hold up the boot.
|
|
ExecStart=-systemd-cryptenroll --firstboot --prompt-suppress=password,recovery,fido2 --unlock-headless --mute-console=yes
|
|
StandardOutput=tty
|
|
StandardInput=tty
|
|
StandardError=tty
|
|
TTYReset=yes
|