Commit Graph
255 Commits
Author SHA1 Message Date
Yu Watanabe 19deb47ade firstboot: drop redundant and spurious errno check
Follow-up for 2319154a6b.
2025-11-23 22:36:50 +09:00
Daan De Meyer 87fbd33372 clang-tidy: Fix all remaining misc-include-cleaner violations
- Remove unused includes
- Add common false positive headers to misc-include-cleaner.IgnoreHeaders
- Add IWYU pragma keep for uncommon false positive headers
2025-11-22 10:19:41 +01:00
Lennart Poettering 372f3159fd firstboot: don't talk about any 'new' installation
The firstboot interface might pop-up also during live mode (because it's
just very useful to have the right kbd mapping applied), and that's
hardly a "new installation". Hence use more generic terms
2025-09-26 16:40:14 +02:00
Lennart Poettering aa27bec194 firstboot: optionally, don't query for keymap unless connected to a real VT
The keymap only really matters if there's local access to a system, i.e.
if there's actually a physical kbd directly connected to it, to apply it
to. If during firstboot we are not talked to via a VT (but via SSH,
container, or hypervisor console or so instead), then it's very unlikely
we ever are. Hence, don't ask for a keymap, and let#s shortcut the
questions asked at boot.
2025-09-26 16:40:14 +02:00
Lennart Poettering bedcce1a1f firstboot: drop waiting for key when starting
We only show this blurb on the first question, but the first question is
interactive anyway, hence no need to wait for input first explicitly, we
won't progress anyway without user input.

(similar for homectl's firstboot)
2025-09-26 16:27:53 +02:00
Lennart Poettering 971637c47d firstboot: get rid of pointless strjoina() 2025-09-26 09:43:45 +02:00
Lennart Poettering 0d2cc656c8 firstboot: mute console while running on the console at boot
Fixes: #34448
2025-09-26 09:42:13 +02:00
Lennart Poettering 875a618ed3 firstboot: modernize --help output 2025-09-24 15:46:30 +02:00
Lennart Poettering 73ee723aa7 firstboot: show blue "chrome" bar at top 2025-09-24 15:46:30 +02:00
Lennart Poettering fa350969ab prompt-util: add generic prompt loop implementation
This is a generalization of the logic in systemd-firstboot. This also
ports over firstboot.c to make use of the new generalization.
2025-09-24 15:46:30 +02:00
Yu Watanabe de69562623 tree-wide: add missing '=' in short comments for function argument 2025-07-22 03:05:54 +09:00
Valentin David 0dc39dffbd Use paths specified from environment variables for /etc configuration files
Some configuration files that need updates are directly under in /etc. To
update them atomically, we need write access to /etc. For Ubuntu Core this is
an issue as /etc is not writable. Only a selection of subdirectories can be
writable. The general solution is symlinks or bind mounts to writable places.
But for atomic writes in /etc, that does not work. So Ubuntu has had a patch
for that that did not age well.

Instead we would like to introduce some environment variables for alternate
paths.

 * SYSTEMD_ETC_HOSTNAME: /etc/hostname
 * SYSTEMD_ETC_MACHINE_INFO: /etc/machine-info
 * SYSTEMD_ETC_LOCALTIME: /etc/localtime
 * SYSTEMD_ETC_LOCALE_CONF: /etc/locale.conf
 * SYSTEMD_ETC_VCONSOLE_CONF: /etc/vconsole.conf
 * SYSTEMD_ETC_ADJTIME: /etc/adjtime

While it is for now expected that there is a symlink from the standard, we
still try to read them from that alternate path. This is important for
`/etc/localtime`, which is a symlink, so we cannot have an indirect symlink or
bind mount for it.

Since machine-id is typically written only once and not updated. This commit
does not cover it. An initrd can properly create it and bind mount it.
2025-06-23 15:32:11 +02:00
Lennart Poettering 611bb28dc3 firstboot: make sure labelling is enabled
Preparation to address #37857.
2025-06-18 10:29:29 +02:00
Lennart Poettering f6e213e86a firstboot: use WRITE_STRING_FILE_LABEL more
Let's explicitly label 3 key files we generate in systemd-firstboot.

Addresses some more of #37857.
2025-06-18 10:21:26 +02:00
Lennart Poettering 3e5320e27d env-file: port write_env_file() to label_ops_pre()
Let's make more use of label_ops_pre()/label_ops_post(), and replace
write_env_file_label() by a flag to write_env_file().

This simplifies and normalizes the code.

This also makes one relevant change: it sets the new
WRITE_ENV_FILE_LABEL flag in firstboot.c when we write locale.conf,
where we previously did not (but should have). This should address one
detail of #37857.
2025-06-18 10:21:26 +02:00
Lennart Poettering 9ea5a6e7d6 fs-util: replace symlink_atomic_full_label() by a flag to symlinkat_atomic_full()
More porting work to label_ops_pre()/label_ops_post()

This also enables labelling of the /etc/localtime symlink in
systemd-firstboot, which should address one small facet of #37857
2025-06-18 10:21:25 +02:00
Daan De Meyer 86b9a3e31d tree-wide: Clean up includes
This removes more unused includes from the components already cleaned
up in #37467 and #37457.

Split out of #37344.
2025-05-21 10:49:42 +02:00
Daan De Meyer 8857aa74e5 tree-wide: Clean up includes
This commit cleans up the includes for all the small tools across
the tree.

A few cases of returning EXIT_SUCCESS are replaced with returning
0 to avoid including <stdlib.h>.

Split out of #37344.
2025-05-14 22:34:02 +02:00
Yu Watanabe 3a03b97d6f tree-wide: drop unnecessary inclusion of tmpfile-util.h 2025-04-30 05:38:48 +09:00
Daan De Meyer 8aa304d313 shared: Remove circular dependency between image-policy.h and dissect-image.h
ImagePolicy can just be a forward declaration in dissect-image.h.
2025-04-23 09:53:43 +02:00
Zbigniew Jędrzejewski-Szmek 1ae9b0cfa8 basic/glyph-util: rename "special glyph" to just "glyph"
Admittedly, some of our glyphs _are_ special, e.g. "O=" for SPECIAL_GLYPH_TOUCH ;)
But we don't need this in the name. The very long names make some invocations
very wordy, e.g. special_glyph(SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY).
Also, I want to add GLYPH_SPACE, which is not special at all.
2025-03-15 14:40:39 +01:00
Lennart Poettering d810815ed4 firstboot: welcome user with emoji in firstboot wizard 🧙 2025-03-15 05:12:12 +09: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
Lennart Poettering 9ab703d8e1 terminal-util: change 2nd parameter of terminal_reset_defensive() to flags
let's convert the 2nd argumeng form a boolean to a proper flags
parameter. Doesn't change behaviour in anyway, but is more readable, and
prepares ground for adding more flags soon.
2025-02-27 15:13:15 +01:00
Lennart Poettering 94a2b1cd25 firstboot: add auto-completion to various fields
This adds TAB-based auto-completion to various fields we query from the
user, such as locale, keymap, timezone, group membership.

It makes it a lot easier to quickly iterate through firstboot without
typing too much.
2025-02-17 15:21:18 +01:00
Lennart Poettering b6478aa12f terminal-util: beef up show_menu()
This modernizes the function a bit, and adds some bits:

1. whether to show numbers before entries is now optional, and if they
   are shown they are displayed in grey.

2. a common prefix can now be grayed out (later useful for completion
   support)

3. some variables have been named to clarify their purpose

4. the table display dimensions can now be auto-sized (by specifying
   SIZE_MAX and number of columns and column width)
2025-02-17 15:21:13 +01:00
Lennart Poettering 8fcd85768b terminal-util: tweak any_key_to_proceed() a bit
1. Make the message a bit more visible, by adding ANSI color. This
   matters in particular during boot, where the message otherwise might
   be overprinted by other output

2. Let's turn off terminal echo so that whatever key is entered is not
   made visible on screen, and we can handle newline and other keys
   reasonably uniformly.
2025-02-17 15:07:38 +01:00
Daan De Meyer 8a008fa792 firstboot: Populate XKBLAYOUT and friends as well in vconsole.conf
Let's derive XKBLAYOUT and friends from the given keymap and populate
these as well in vconsole.conf so that if the user configures a keymap
it's also respected in display managers such as gdm.
2025-02-07 09:18:36 +09:00
Zbigniew Jędrzejewski-Szmek b66a4c157e firstboot: fix crash when hostname question is skipped 2025-01-30 19:48:43 +01:00
Lennart Poettering d66894a7a5 ask-password-api: add new "hup_fd" field to AskPasswordReq
This new field allows specification of an fd on which the password
prompt logic will look for POLLHUP events for, and if seen will abort
the query.

The usecase for this is that when we query for a pw on behalf of a
Varlink client we can abort the query automatically if the client dies.
2025-01-02 16:38:44 +01:00
Lennart Poettering c4a02a526d ask-password-api: move timeout into AskPasswordRequest structure too 2025-01-02 16:38:25 +01:00
Lennart Poettering 72068d9d25 ask-password-api: move tty_fd into AskPasswordRequest structure, too 2025-01-02 16:38:12 +01:00
Lennart Poettering 4ff3689ad2 ask-password-api: move 'flag_file' from function parameter into AskPasswordRequest structure 2025-01-02 16:38:00 +01:00
Michael Ferrari 178d80d719 firstboot: generalize prompt_loop more
Allows unifying the custom logic for the hostname and root shell. Root
password prompting remains separate as it's logic is substantially
different to the other prompts.
2024-10-30 20:13:56 +01:00
Michael Ferrari 26f9e08231 firstboot: use consistent wording for prompts 2024-10-30 20:13:53 +01:00
Michael Ferrari f4da5ed538 firstboot: clean up welcome message 2024-10-30 20:13:47 +01:00
Michael Ferrari d689dd88fd firstboot: order non-interactive options last 2024-10-30 20:13:41 +01:00
Daan De Meyer d8a77d55e6 bus-util: Log more information when connecting to a bus socket fails
Let's log about which bus we're trying to connect to and what transport
we're using to do it.
2024-10-09 10:27:53 +02:00
Daan De Meyer ec75a254d2 Move show_menu() to terminal-util.h 2024-10-02 15:05:24 +02:00
Yu Watanabe ffdf497860 strv: introduce strv_find_closest()
Follow-up for 1e1ac5d53b.
2024-09-21 05:06:12 +09:00
Michael Ferrari 1e1ac5d53b firstboot: add similar input suggestion
This uses the same logic as similar verb suggestion for command line
utilities. Try to be helpful when the user entered something invalid
instead of just showing the prompt again.
2024-09-20 08:34:03 +09:00
Michael Ferrari 91ea3dcf35 homed: wait for user input during firstboot
This mirrors the behavior of `systemd-firstboot` and allows bootup
messages to settle down before user input is actually processed.

See: https://github.com/systemd/systemd/issues/34448
2024-09-18 03:21:11 +09:00
Michael Ferrari 87e0eafe03 firstboot: reduce log level of timezone validation
An error message is already printed directly after, so the user already
knows that the validation failed. This also isn't done for the other
validation functions.
2024-09-05 10:08:42 +09:00
Michael Ferrari 3f084827ff firstboot: reduce empty input log level
The user knows they pressed `Enter`, no need to inform them again about
that they skipped the prompt.
2024-09-05 10:08:42 +09:00
Michael Ferrari b7c0d924bd firstboot: add newline before key wait
When sd-firstboot is ran during first boot of a new system this missing
newline leads to a bootup message being appended on the same line as the
message instructing to press a key.
2024-09-05 10:08:38 +09:00
Dan Nicholson 35bc4c3424 firstboot: fix root params with creds and prompting disabled
Remove an early return that prevents --prompt-root-password or
--prompt-root-shell and systemd.firstboot=off using credentials. In that case,
arg_prompt_root_password and arg_prompt_root_shell will be false, but the
prompt helpers still need to be called to read the credentials. Furthermore, if
only the root shell has been set, don't overwrite the root password.
2024-07-31 04:02:43 -06:00
Dan Nicholson 2319154a6b firstboot: handle missing root password entries
If /etc/passwd and/or /etc/shadow exist but don't have an existing root entry,
one needs to be added. Previously this only worked if the files didn't exist.
2024-07-31 04:02:39 -06:00
Dan Nicholson 5088de9daa firstboot: create locked and empty root passwords consistently
Although locked and empty passwords in /etc/passwd are treated the same, in all
other cases the entry is configured to read the password from /etc/shadow.
2024-07-31 00:40:56 -06:00
Lennart Poettering 2cd19499a0 tree-wide: acquire /dev/console lock around any attempts to reset TTY 2024-07-19 11:44:04 +02:00
Lennart Poettering 967bcc6e26 tree-wide: reset stdout not stdin
We nowadays reset TTYs by writing ANSI sequences to them. This can only
work if we operate on an *output* fd, not an input fd. Hence switch
various cases where we erroneously used an input fd to use an output fd
instead.
2024-07-19 11:44:04 +02:00