From: Zbigniew Jędrzejewski-Szmek Date: Thu, 14 Sep 2017 13:44:48 +0000 (+0200) Subject: pid1: improve the check guarding unit_file_preset_all() X-Git-Tag: v235~96^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=81fe6cdee2a9f029259aba48ea590614d7678abf;p=thirdparty%2Fsystemd.git 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). --- diff --git a/src/core/manager.c b/src/core/manager.c index 5237b476608..156943b3566 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -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");