pid1: improve the check guarding unit_file_preset_all()

When running in systemd-analyze verify, first_boot was initialized to -1
and never changed, so we'd try to run unit_file_preset_all(). Change the
check to > 0 which is more correct. Also, add a separate test for !test_run,
since we wouldn't want to run presets even if we were in first boot
(or /etc was empty for whatever other reason).
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-09-14 15:44:48 +02:00
parent dbbf424c8b
commit 81fe6cdee2

View file

@ -1332,7 +1332,10 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
if (r < 0)
return r;
if (m->first_boot && m->unit_file_scope == UNIT_FILE_SYSTEM) {
if (m->first_boot > 0 &&
m->unit_file_scope == UNIT_FILE_SYSTEM &&
!m->test_run) {
q = unit_file_preset_all(UNIT_FILE_SYSTEM, 0, NULL, UNIT_FILE_PRESET_ENABLE_ONLY, NULL, 0);
if (q < 0)
log_full_errno(q == -EEXIST ? LOG_NOTICE : LOG_WARNING, q, "Failed to populate /etc with preset unit settings, ignoring: %m");