pid1: improve the check guarding unit_file_preset_all()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 14 Sep 2017 13:44:48 +0000 (15:44 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 14 Sep 2017 17:07:44 +0000 (19:07 +0200)
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).

src/core/manager.c

index 5237b47..156943b 100644 (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");