teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0361-install-fix-disable-via-unit-file-path.patch

1abbee
From 96df052a6a9d09cde2d437861727bf37fe6446b4 Mon Sep 17 00:00:00 2001
1abbee
From: Michal Sekletar <msekleta@redhat.com>
1abbee
Date: Tue, 12 Jul 2016 09:40:02 +0200
1abbee
Subject: [PATCH] install: fix disable via unit file path
1abbee
1abbee
Drop the check for unit file name validity. install_info_add does that
1abbee
anyway. Also pass NULL in place of name argument to install_info_add if
1abbee
we are dealing with path to a unit file. install_info_add will figure
1abbee
out a name from a path and it will correctly populate
1abbee
UnitFileInstallInfo with both name and path. Then in
1abbee
unit_file_search called from install_info_traverse we can take a
1abbee
shortcut and attempt to load unit file directly.
1abbee
1abbee
Cherry-picked from: 4dfbf0b176ff0e8a352617eba5e79065ee477969
1abbee
Resolves: #1348208
1abbee
---
1abbee
 src/shared/install.c | 8 +++++---
1abbee
 1 file changed, 5 insertions(+), 3 deletions(-)
1abbee
1abbee
diff --git a/src/shared/install.c b/src/shared/install.c
181b3f
index 5288bb450..f190dbfab 100644
1abbee
--- a/src/shared/install.c
1abbee
+++ b/src/shared/install.c
1abbee
@@ -1910,10 +1910,12 @@ int unit_file_disable(
1abbee
                 return r;
1abbee
 
1abbee
         STRV_FOREACH(i, files) {
1abbee
-                if (!unit_name_is_valid(*i, UNIT_NAME_ANY))
1abbee
-                        return -EINVAL;
1abbee
 
1abbee
-                r = install_info_add(&c, *i, NULL, NULL);
1abbee
+                if (!is_path(*i))
1abbee
+                        r = install_info_add(&c, *i, NULL, NULL);
1abbee
+                else
1abbee
+                        r = install_info_add(&c, NULL, *i, NULL);
1abbee
+
1abbee
                 if (r < 0)
1abbee
                         return r;
1abbee
         }