mirror of
https://github.com/systemd/systemd
synced 2024-10-15 12:34:37 +00:00
core: never apply first boot presets in the initrd
Presets are useful to initialize uninitialized /etc, but that doesn't apply to the initrd. Also, let's rename etc_empty → first_boot. After all, the variable doesn't actually reflect whether /etc is really empty, it just reflects whether /etc/machine-id existed originally or not. Moreover, we later on directly initialize manager_set_first_boot() from it, hence let's just name it the same way all through the codepath, to make this all less confusing. See: #7100
This commit is contained in:
parent
85cb415124
commit
fd1306121d
|
@ -1406,7 +1406,7 @@ int main(int argc, char *argv[]) {
|
|||
bool loaded_policy = false;
|
||||
bool arm_reboot_watchdog = false;
|
||||
bool queue_default_job = false;
|
||||
bool empty_etc = false;
|
||||
bool first_boot = false;
|
||||
char *switch_root_dir = NULL, *switch_root_init = NULL;
|
||||
struct rlimit saved_rlimit_nofile = RLIMIT_MAKE_CONST(0), saved_rlimit_memlock = RLIMIT_MAKE_CONST((rlim_t) -1);
|
||||
const char *error_message = NULL;
|
||||
|
@ -1767,18 +1767,17 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
if (in_initrd())
|
||||
log_info("Running in initial RAM disk.");
|
||||
else {
|
||||
/* Let's check whether we are in first boot, i.e. whether /etc is still unpopulated. We use
|
||||
* /etc/machine-id as flag file, for this: if it exists we assume /etc is populated, if it
|
||||
* doesn't it's unpopulated. This allows container managers and installers to provision a
|
||||
* couple of files already. If the container manager wants to provision the machine ID itself
|
||||
* it should pass $container_uuid to PID 1. */
|
||||
|
||||
/* Let's check whether /etc is already populated. We
|
||||
* don't actually really check for that, but use
|
||||
* /etc/machine-id as flag file. This allows container
|
||||
* managers and installers to provision a couple of
|
||||
* files already. If the container manager wants to
|
||||
* provision the machine ID itself it should pass
|
||||
* $container_uuid to PID 1. */
|
||||
|
||||
empty_etc = access("/etc/machine-id", F_OK) < 0;
|
||||
if (empty_etc)
|
||||
log_info("Running with unpopulated /etc.");
|
||||
first_boot = access("/etc/machine-id", F_OK) < 0;
|
||||
if (first_boot)
|
||||
log_info("Running with unpopulated /etc.");
|
||||
}
|
||||
} else {
|
||||
_cleanup_free_ char *t;
|
||||
|
||||
|
@ -1863,7 +1862,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
set_manager_defaults(m);
|
||||
manager_set_show_status(m, arg_show_status);
|
||||
manager_set_first_boot(m, empty_etc);
|
||||
manager_set_first_boot(m, first_boot);
|
||||
|
||||
/* Remember whether we should queue the default job */
|
||||
queue_default_job = !arg_serialization || arg_switched_root;
|
||||
|
|
|
@ -1345,8 +1345,9 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* If this is the first boot, and we are in the host system, then preset everything */
|
||||
if (m->first_boot > 0 &&
|
||||
m->unit_file_scope == UNIT_FILE_SYSTEM &&
|
||||
MANAGER_IS_SYSTEM(m) &&
|
||||
!m->test_run_flags) {
|
||||
|
||||
r = unit_file_preset_all(UNIT_FILE_SYSTEM, 0, NULL, UNIT_FILE_PRESET_ENABLE_ONLY, NULL, 0);
|
||||
|
|
Loading…
Reference in a new issue