anitazha / rpms / systemd

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