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