diff --git a/src/core/main.c b/src/core/main.c index 5c02e30880..11c7f6fad8 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2614,6 +2614,11 @@ static void log_execution_mode(bool *ret_first_boot) { } } + /* Make the first-boot file visible now: the credential import + * consults in_first_boot() for systemd.credentials_boot_policy= which runs + * before the manager object is created. */ + (void) update_first_boot_file(first_boot); + assert_se(uname(&uts) >= 0); if (strverscmp_improved(uts.release, KERNEL_BASELINE_VERSION) < 0) diff --git a/src/core/manager.c b/src/core/manager.c index 27ca84c4e9..f5daa59e1a 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -4842,21 +4842,32 @@ fail: } void manager_set_first_boot(Manager *m, bool b) { + int r; + assert(m); if (!MANAGER_IS_SYSTEM(m)) return; if (m->first_boot != (int) b) { - if (b) - (void) touch("/run/systemd/first-boot"); - else - (void) unlink("/run/systemd/first-boot"); + r = update_first_boot_file(b); + if (r < 0) + log_warning_errno(r, "Failed to update the first-boot file, ignoring: %m"); } m->first_boot = b; } +int update_first_boot_file(bool b) { + if (b) + return touch("/run/systemd/first-boot"); + + if (unlink("/run/systemd/first-boot") < 0 && errno != ENOENT) + return -errno; + + return 0; +} + void manager_disable_confirm_spawn(void) { (void) touch("/run/systemd/confirm_spawn_disabled"); } diff --git a/src/core/manager.h b/src/core/manager.h index 8262bfbec8..12d6cf4470 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -719,6 +719,8 @@ void manager_log_caller(Manager *manager, PidRef *caller, const char *method); int manager_allocate_idle_pipe(Manager *m); +int update_first_boot_file(bool b); + void unit_defaults_init(UnitDefaults *defaults, RuntimeScope scope); void unit_defaults_done(UnitDefaults *defaults);