core: make /run/systemd/first-boot available earlier
For the new systemd.credentials_boot_policy= setting we need to be able to differenciate if its a firstboot or not early. But `manager_set_first_boot` is run after `initialize_runtime()` which imports the credentials. So we need to touch the file so that the credentials_boot_policy setting can work. Unfortunately we cannot just move manager_set_first_boot() earlier because there is no manager yet at this point.
This commit is contained in:
@@ -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)
|
||||
|
||||
+15
-4
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user