[systemd-devel] [PATCH 1/2] shared/install: ignore ENOENT from unit_file_can_install

Dave Reisner dreisner at archlinux.org
Mon Sep 3 14:13:17 PDT 2012

When a service file contains an .include directive with a path that
doesn't exist, systemctl list-unit-files will simply error out with:

Failed to get unit file list: No such file or directory

To reproduce:

  # echo ".include /this/doesnt/exist" >/etc/systemd/system/foo.service
  # systemctl daemon-reload
  # systemctl list-unit-files
This is a repeat of a patch I posted previously, and later when it was
reviewed, I wasn't able to reproduce:


As for the journal logging, the message already exists:

Sep 03 17:00:44 beatbox systemd[1]: Failed to open configuration file '/this/doesnt/exist': No such file or directory

Should this be surfaced to the terminal as well?

 src/shared/install.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index ef1c3f5..2863a43 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -2007,7 +2007,7 @@ int unit_file_get_list(
                                 goto found;
                         r = unit_file_can_install(&paths, root_dir, f->path, true);
-                        if (r < 0) {
+                        if (r < 0 && r != -ENOENT) {
                                 goto finish;

More information about the systemd-devel mailing list