richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
803fb7
From b5eddaf0dea35bda7b68a401119c5f9f9104fb99 Mon Sep 17 00:00:00 2001
803fb7
From: Martin Pitt <martin.pitt@ubuntu.com>
803fb7
Date: Mon, 11 Apr 2016 21:03:29 +0200
803fb7
Subject: [PATCH] Install: correctly report symlink creations
803fb7
803fb7
All callers of create_symlink(), such as install_info_symlink_wants(), expect
803fb7
that to return > 0 if it actually did something, and then return that number.
803fb7
unit_file_enable() uses that to determine if any action was done
803fb7
(carries_install_info != 0) and if not, show a "The unit files have no
803fb7
[Install] section" warning.
803fb7
803fb7
Return 1 instead of 0 in the two code paths of create_symlink() when the link
803fb7
was created or replaced with a new value.
803fb7
803fb7
This fixes getting a bogus "No [Install] section" warning when enabling a unit
803fb7
with full path, like "systemctl enable /some/path/myunit.service".
803fb7
803fb7
(cherry picked from commit 3de1521427dee61000c1c124a521182b301a50de)
803fb7
Resolves: #1435098
803fb7
---
803fb7
 src/shared/install.c | 4 ++--
803fb7
 1 file changed, 2 insertions(+), 2 deletions(-)
803fb7
803fb7
diff --git a/src/shared/install.c b/src/shared/install.c
803fb7
index bdfd7b96a..e73f0c95b 100644
803fb7
--- a/src/shared/install.c
803fb7
+++ b/src/shared/install.c
803fb7
@@ -283,7 +283,7 @@ static int create_symlink(
803fb7
 
803fb7
         if (symlink(old_path, new_path) >= 0) {
803fb7
                 unit_file_changes_add(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path);
803fb7
-                return 0;
803fb7
+                return 1;
803fb7
         }
803fb7
 
803fb7
         if (errno != EEXIST)
803fb7
@@ -306,7 +306,7 @@ static int create_symlink(
803fb7
         unit_file_changes_add(changes, n_changes, UNIT_FILE_UNLINK, new_path, NULL);
803fb7
         unit_file_changes_add(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path);
803fb7
 
803fb7
-        return 0;
803fb7
+        return 1;
803fb7
 }
803fb7
 
803fb7
 static int mark_symlink_for_removal(