ryantimwilson / rpms / systemd

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