daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
803fb7
From 10bf9c070764d09a4b39aa65ccba8b7501918a34 Mon Sep 17 00:00:00 2001
803fb7
From: Jan Synacek <jan.synacek@gmail.com>
803fb7
Date: Wed, 8 Feb 2017 20:57:08 +0100
803fb7
Subject: [PATCH] systemctl: make sure that --now is carried out (#5209)
803fb7
803fb7
When services are already enabled/disabled/masked, make sure
803fb7
that --now still enforces start/stop.
803fb7
(cherry picked from commit 6bc30691b109302d386007c6bdabcc27d04991bc)
803fb7
Resolves: #1417459
803fb7
---
803fb7
 src/systemctl/systemctl.c | 20 ++++++++++++--------
803fb7
 1 file changed, 12 insertions(+), 8 deletions(-)
803fb7
803fb7
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
803fb7
index ff8b4e978..0333599c8 100644
803fb7
--- a/src/systemctl/systemctl.c
803fb7
+++ b/src/systemctl/systemctl.c
803fb7
@@ -5549,16 +5549,20 @@ static int enable_unit(sd_bus *bus, char **args) {
803fb7
                             "3) A unit may be started when needed via activation (socket, path, timer,\n"
803fb7
                             "   D-Bus, udev, scripted systemctl call, ...).\n");
803fb7
 
803fb7
-        if (arg_now && n_changes > 0 && STR_IN_SET(args[0], "enable", "disable", "mask")) {
803fb7
-                char *new_args[n_changes + 2];
803fb7
-                unsigned i;
803fb7
+        if (arg_now && STR_IN_SET(args[0], "enable", "disable", "mask")) {
803fb7
+                unsigned len, i;
803fb7
 
803fb7
-                new_args[0] = streq(args[0], "enable") ? (char *)"start" : (char *)"stop";
803fb7
-                for (i = 0; i < n_changes; i++)
803fb7
-                        new_args[i + 1] = basename(changes[i].path);
803fb7
-                new_args[i + 1] = NULL;
803fb7
+                len = strv_length(names);
803fb7
+                {
803fb7
+                        char *new_args[len + 2];
803fb7
 
803fb7
-                r = start_unit(bus, new_args);
803fb7
+                        new_args[0] = (char*) (streq(args[0], "enable") ? "start" : "stop");
803fb7
+                        for (i = 0; i < len; i++)
803fb7
+                                new_args[i + 1] = basename(names[i]);
803fb7
+                        new_args[i + 1] = NULL;
803fb7
+
803fb7
+                        r = start_unit(bus, new_args);
803fb7
+                }
803fb7
         }
803fb7
 
803fb7
 finish: