daandemeyer / rpms / systemd

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