teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

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

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