84b277
From 736a7f8c5d6c711ece23b0f347d3b89ac7464b08 Mon Sep 17 00:00:00 2001
84b277
From: Lukas Nykryn <lnykryn@redhat.com>
84b277
Date: Tue, 26 Aug 2014 13:33:08 +0200
84b277
Subject: [PATCH] systemctl: fix broken list-unit-files with --root
84b277
84b277
(cherry picked from commit 81fc054dc7c365545bca86d78bf36a12658cedb3)
84b277
84b277
Related: #1111199
84b277
84b277
Conflicts:
84b277
	src/shared/install.c
84b277
---
84b277
 src/shared/install.c | 7 ++++++-
84b277
 1 file changed, 6 insertions(+), 1 deletion(-)
84b277
84b277
diff --git a/src/shared/install.c b/src/shared/install.c
84b277
index 598323a..2c8f907 100644
84b277
--- a/src/shared/install.c
84b277
+++ b/src/shared/install.c
84b277
@@ -1973,6 +1973,7 @@ int unit_file_get_list(
84b277
                         union dirent_storage buffer;
84b277
                         UnitFileList __attribute__((cleanup(unitfilelist_free)))
84b277
                                 *f = NULL;
84b277
+                        _cleanup_free_ char *path = NULL;
84b277
 
84b277
                         r = readdir_r(d, &buffer.de, &de);
84b277
                         if (r != 0)
84b277
@@ -2027,7 +2028,11 @@ int unit_file_get_list(
84b277
                                 goto found;
84b277
                         }
84b277
 
84b277
-                        r = unit_file_can_install(&paths, root_dir, f->path, true);
84b277
+                        path = path_make_absolute(de->d_name, *i);
84b277
+                        if (!path)
84b277
+                                return -ENOMEM;
84b277
+
84b277
+                        r = unit_file_can_install(&paths, root_dir, path, true);
84b277
                         if (r == -EINVAL ||  /* Invalid setting? */
84b277
                             r == -EBADMSG || /* Invalid format? */
84b277
                             r == -ENOENT     /* Included file not found? */)