systemctl: fix silent failure when --root is not found
Some calls to lookup_path_init() were not followed by any log emission. E.g.: $ SYSTEMD_LOG_LEVEL=debug systemctl --root=/missing enable unit; echo $? 1 Let's add a helper function and use it in various places. $ SYSTEMD_LOG_LEVEL=debug build/systemctl --root=/missing enable unit; echo $? Failed to initialize unit search paths for root directory /missing: No such file or directory 1 $ SYSTEMCTL_SKIP_SYSV=1 build/systemctl --root=/missing enable unit; echo $? Failed to initialize unit search paths for root directory /missing: No such file or directory Failed to enable: No such file or directory. 1 The repeated error in the second case is not very nice, but this is a niche case and I don't think it's worth the trouble to trying to avoid it.
This commit is contained in:
+6
-6
@@ -1751,11 +1751,11 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds, const char *roo
|
||||
|
||||
/* If we are running in test mode, we still want to run the generators,
|
||||
* but we should not touch the real generator directories. */
|
||||
r = lookup_paths_init(&m->lookup_paths, m->unit_file_scope,
|
||||
MANAGER_IS_TEST_RUN(m) ? LOOKUP_PATHS_TEMPORARY_GENERATED : 0,
|
||||
root);
|
||||
r = lookup_paths_init_or_warn(&m->lookup_paths, m->unit_file_scope,
|
||||
MANAGER_IS_TEST_RUN(m) ? LOOKUP_PATHS_TEMPORARY_GENERATED : 0,
|
||||
root);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to initialize path lookup table: %m");
|
||||
return r;
|
||||
|
||||
dual_timestamp_get(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_GENERATORS_START));
|
||||
r = manager_run_environment_generators(m);
|
||||
@@ -3343,9 +3343,9 @@ int manager_reload(Manager *m) {
|
||||
m->uid_refs = hashmap_free(m->uid_refs);
|
||||
m->gid_refs = hashmap_free(m->gid_refs);
|
||||
|
||||
r = lookup_paths_init(&m->lookup_paths, m->unit_file_scope, 0, NULL);
|
||||
r = lookup_paths_init_or_warn(&m->lookup_paths, m->unit_file_scope, 0, NULL);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to initialize path lookup table, ignoring: %m");
|
||||
return r;
|
||||
|
||||
(void) manager_run_environment_generators(m);
|
||||
(void) manager_run_generators(m);
|
||||
|
||||
Reference in New Issue
Block a user