summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Synacek <jan.synacek@gmail.com>2017-02-08 20:57:08 +0100
committerLennart Poettering <lennart@poettering.net>2017-02-08 20:57:08 +0100
commit6bc30691b109302d386007c6bdabcc27d04991bc (patch)
tree9d5fe0ba3319dfb99947ba3e046cd9028f6ed6c9 /src
parent4470860388e12a5dda1d65773e411a349221a3e9 (diff)
systemctl: make sure that --now is carried out (#5209)
When services are already enabled/disabled/masked, make sure that --now still enforces start/stop.
Diffstat (limited to 'src')
-rw-r--r--src/systemctl/systemctl.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 5cb07739d4..2809dece50 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -6218,21 +6218,25 @@ static int enable_unit(int argc, char *argv[], void *userdata) {
"4) In case of template units, the unit is meant to be enabled with some\n"
" instance name specified.");
- if (arg_now && n_changes > 0 && STR_IN_SET(argv[0], "enable", "disable", "mask")) {
- char *new_args[n_changes + 2];
+ if (arg_now && STR_IN_SET(argv[0], "enable", "disable", "mask")) {
sd_bus *bus;
- unsigned i;
+ unsigned len, i;
r = acquire_bus(BUS_MANAGER, &bus);
if (r < 0)
goto finish;
- new_args[0] = (char*) (streq(argv[0], "enable") ? "start" : "stop");
- for (i = 0; i < n_changes; i++)
- new_args[i + 1] = basename(changes[i].path);
- new_args[i + 1] = NULL;
+ len = strv_length(names);
+ {
+ char *new_args[len + 2];
- r = start_unit(strv_length(new_args), new_args, userdata);
+ new_args[0] = (char*) (streq(argv[0], "enable") ? "start" : "stop");
+ for (i = 0; i < len; i++)
+ new_args[i + 1] = basename(names[i]);
+ new_args[i + 1] = NULL;
+
+ r = start_unit(len + 1, new_args, userdata);
+ }
}
finish: