valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0403-systemctl-pid1-do-not-warn-about-missing-install-inf.patch

1abbee
From 5f273838f41f27e0045395c1677272d9dd12496c Mon Sep 17 00:00:00 2001
1abbee
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
1abbee
Date: Thu, 21 Apr 2016 20:04:21 -0400
1abbee
Subject: [PATCH] systemctl,pid1: do not warn about missing install info with
1abbee
 "preset"
1abbee
1abbee
When "preset" was executed for a unit without install info, we'd warn similarly
1abbee
as for "enable" and "disable". But "preset" is usually called for all units,
1abbee
because the preset files are provided by the distribution, and the units are under
1abbee
control of individual programs, and it's reasonable to call "preset" for all units
1abbee
rather then try to do it only for the ones that can be installed.
1abbee
We also don't warn about missing info for "preset-all". Thus it seems reasonable
1abbee
to silently ignore units w/o install info when presetting.
1abbee
1abbee
(In addition, when more than one unit was specified, we'd issue the warning
1abbee
only if none of them had install info. But this is probably something to fix
1abbee
for enable/disable too.)
1abbee
1abbee
Cherry-picked from: 39207373dd638e548019ddb49929f15795b8b404
1abbee
Resolves: #1373950
1abbee
---
1abbee
 man/systemctl.xml         | 26 +++++++++++++-------------
1abbee
 src/systemctl/systemctl.c |  7 ++++---
1abbee
 2 files changed, 17 insertions(+), 16 deletions(-)
1abbee
1abbee
diff --git a/man/systemctl.xml b/man/systemctl.xml
Pablo Greco 48fc63
index 2d0678d18d..bb21f3a887 100644
1abbee
--- a/man/systemctl.xml
1abbee
+++ b/man/systemctl.xml
1abbee
@@ -1012,22 +1012,22 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
1abbee
           <term><command>preset <replaceable>NAME</replaceable>...</command></term>
1abbee
 
1abbee
           <listitem>
1abbee
-            <para>Reset one or more unit files, as specified on the
1abbee
-            command line, to the defaults configured in the preset
1abbee
-            policy files. This has the same effect as
1abbee
-            <command>disable</command> or <command>enable</command>,
1abbee
-            depending how the unit is listed in the preset files.</para>
1abbee
+            <para>Reset the enable/disable status one or more unit files, as specified on
1abbee
+            the command line, to the defaults configured in the preset policy files. This
1abbee
+            has the same effect as <command>disable</command> or
1abbee
+            <command>enable</command>, depending how the unit is listed in the preset
1abbee
+            files.</para>
1abbee
 
1abbee
-            <para>Use <option>--preset-mode=</option> to control
1abbee
-            whether units shall be enabled and disabled, or only
1abbee
-            enabled, or only disabled.</para>
1abbee
+            <para>Use <option>--preset-mode=</option> to control whether units shall be
1abbee
+            enabled and disabled, or only enabled, or only disabled.</para>
1abbee
+
1abbee
+            <para>If the unit carries no install information, it will be silently ignored
1abbee
+            by this command.</para>
1abbee
 
1abbee
-            <para>For more information on the preset policy format,
1abbee
-            see
1abbee
+            <para>For more information on the preset policy format, see
1abbee
             <citerefentry><refentrytitle>systemd.preset</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1abbee
-            For more information on the concept of presets, please
1abbee
-            consult the 
1abbee
-            url="http://freedesktop.org/wiki/Software/systemd/Preset">Preset</ulink>
1abbee
+            For more information on the concept of presets, please consult the
1abbee
+            <ulink url="http://freedesktop.org/wiki/Software/systemd/Preset">Preset</ulink>
1abbee
             document.</para>
1abbee
           </listitem>
1abbee
         </varlistentry>
1abbee
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
Pablo Greco 48fc63
index e4b404abc2..e854508d9d 100644
1abbee
--- a/src/systemctl/systemctl.c
1abbee
+++ b/src/systemctl/systemctl.c
1abbee
@@ -5367,6 +5367,7 @@ static int enable_unit(sd_bus *bus, char **args) {
1abbee
         UnitFileChange *changes = NULL;
1abbee
         unsigned n_changes = 0;
1abbee
         int carries_install_info = -1;
1abbee
+        bool ignore_carries_install_info = false;
1abbee
         int r;
1abbee
 
1abbee
         if (!args[1])
1abbee
@@ -5404,7 +5405,6 @@ static int enable_unit(sd_bus *bus, char **args) {
1abbee
                         r = unit_file_link(arg_scope, arg_runtime, arg_root, names, arg_force, &changes, &n_changes);
1abbee
                 else if (streq(verb, "preset")) {
1abbee
                         r = unit_file_preset(arg_scope, arg_runtime, arg_root, names, arg_preset_mode, arg_force, &changes, &n_changes);
1abbee
-                        carries_install_info = r;
1abbee
                 } else if (streq(verb, "mask"))
1abbee
                         r = unit_file_mask(arg_scope, arg_runtime, arg_root, names, arg_force, &changes, &n_changes);
1abbee
                 else if (streq(verb, "unmask"))
1abbee
@@ -5424,7 +5424,7 @@ static int enable_unit(sd_bus *bus, char **args) {
1abbee
         } else {
1abbee
                 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL, *m = NULL;
1abbee
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
1abbee
-                int expect_carries_install_info = false;
1abbee
+                bool expect_carries_install_info = false;
1abbee
                 bool send_force = true, send_preset_mode = false;
1abbee
                 const char *method;
1abbee
 
1abbee
@@ -5450,6 +5450,7 @@ static int enable_unit(sd_bus *bus, char **args) {
1abbee
                                 method = "PresetUnitFiles";
1abbee
 
1abbee
                         expect_carries_install_info = true;
1abbee
+                        ignore_carries_install_info = true;
1abbee
                 } else if (streq(verb, "mask"))
1abbee
                         method = "MaskUnitFiles";
1abbee
                 else if (streq(verb, "unmask")) {
1abbee
@@ -5515,7 +5516,7 @@ static int enable_unit(sd_bus *bus, char **args) {
1abbee
                         r = 0;
1abbee
         }
1abbee
 
1abbee
-        if (carries_install_info == 0)
1abbee
+        if (carries_install_info == 0 && !ignore_carries_install_info)
1abbee
                 log_warning("The unit files have no [Install] section. They are not meant to be enabled\n"
1abbee
                             "using systemctl.\n"
1abbee
                             "Possible reasons for having this kind of units are:\n"