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