From: Lennart Poettering Date: Fri, 19 Sep 2025 08:22:49 +0000 (+0200) Subject: homectl: mute console while running firstboot prompts X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0cfaea3619a97062d864a3eb977dab379f795815;p=thirdparty%2Fsystemd.git homectl: mute console while running firstboot prompts --- diff --git a/man/homectl.xml b/man/homectl.xml index 961266aea3d..82ea2e3943d 100644 --- a/man/homectl.xml +++ b/man/homectl.xml @@ -245,6 +245,16 @@ + + + + Takes a boolean argument. If true kernel log output and service manager status output + to the system console is temporarily disabled while firstboot --prompt-new-user is + running, so that its own output is not interrupted. Defaults to false. + + + + diff --git a/src/home/homectl.c b/src/home/homectl.c index 22665eae45f..199cb395379 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -4,6 +4,7 @@ #include #include "sd-bus.h" +#include "sd-varlink.h" #include "ask-password-api.h" #include "bitfield.h" @@ -112,6 +113,7 @@ static bool arg_prompt_new_user = false; static bool arg_prompt_shell = true; static bool arg_prompt_groups = true; static bool arg_chrome = true; +static bool arg_mute_console = false; STATIC_DESTRUCTOR_REGISTER(arg_identity_extra, sd_json_variant_unrefp); STATIC_DESTRUCTOR_REGISTER(arg_identity_extra_this_machine, sd_json_variant_unrefp); @@ -2839,6 +2841,9 @@ static int create_interactively(void) { return 0; } + _cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *mute_console_link = NULL; + (void) mute_console(&mute_console_link); + (void) terminal_reset_defensive_locked(STDOUT_FILENO, /* flags= */ 0); if (arg_chrome) @@ -3077,6 +3082,8 @@ static int help(int argc, char *argv[], void *userdata) { " --prompt-shell=no In first-boot mode, don't prompt for shells\n" " --chrome=no In first-boot mode, don't show colour bar at top\n" " and bottom of terminal\n" + " --mute-console=yes In first-boot mode, tell kernel/PID 1 to not\n" + " write to the console while running\n" "\n%4$sGeneral User Record Properties:%5$s\n" " -c --real-name=REALNAME Real name for user\n" " --realm=REALM Realm to create user in\n" @@ -3316,6 +3323,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_PROMPT_SHELL, ARG_PROMPT_GROUPS, ARG_CHROME, + ARG_MUTE_CONSOLE, }; static const struct option options[] = { @@ -3425,6 +3433,7 @@ static int parse_argv(int argc, char *argv[]) { { "prompt-shell", required_argument, NULL, ARG_PROMPT_SHELL }, { "prompt-groups", required_argument, NULL, ARG_PROMPT_GROUPS }, { "chrome", required_argument, NULL, ARG_CHROME }, + { "mute-console", required_argument, NULL, ARG_MUTE_CONSOLE }, {} }; @@ -5005,6 +5014,13 @@ static int parse_argv(int argc, char *argv[]) { break; + case ARG_MUTE_CONSOLE: + r = parse_boolean_argument("--mute-console=", optarg, &arg_mute_console); + if (r < 0) + return r; + + break; + case '?': return -EINVAL; diff --git a/units/systemd-homed-firstboot.service b/units/systemd-homed-firstboot.service index bc925924154..531c50f02d5 100644 --- a/units/systemd-homed-firstboot.service +++ b/units/systemd-homed-firstboot.service @@ -17,7 +17,7 @@ Before=systemd-user-sessions.service first-boot-complete.target [Service] Type=oneshot RemainAfterExit=yes -ExecStart=homectl firstboot --prompt-new-user --prompt-shell=no --prompt-groups=no +ExecStart=homectl firstboot --prompt-new-user --prompt-shell=no --prompt-groups=no --mute-console=yes StandardOutput=tty StandardInput=tty StandardError=tty