summaryrefslogtreecommitdiff
path: root/src/systemctl/systemctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-09 18:39:01 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-09 18:39:01 +0200
commitc6312fb3cf97699ebfd1c117c544f5db4d9df4f1 (patch)
treec567fd75a1478123ab05dfb3e51a2f8c691b22d6 /src/systemctl/systemctl.c
parentc36d25218bda22f0aff4f078ffe23a1bcf45dd25 (diff)
parent7681f5b88907f5bc01405ee7607d4c3702f1c65f (diff)
Merge pull request #1220 from zonque/logind-dry-run
logind: make dry run command line arguments work again (v2)
Diffstat (limited to 'src/systemctl/systemctl.c')
-rw-r--r--src/systemctl/systemctl.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index a82b9b83a2..74d7fc2b3b 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -7358,7 +7358,6 @@ static int halt_main(sd_bus *bus) {
* the machine. */
if (arg_when <= 0 &&
- !arg_dry &&
arg_force <= 0 &&
(arg_action == ACTION_POWEROFF ||
arg_action == ACTION_REBOOT)) {
@@ -7375,6 +7374,7 @@ static int halt_main(sd_bus *bus) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_flush_close_unref_ sd_bus *b = NULL;
_cleanup_free_ char *m = NULL;
+ const char *action;
if (avoid_bus()) {
log_error("Unable to perform operation without bus connection.");
@@ -7407,6 +7407,24 @@ static int halt_main(sd_bus *bus) {
sd_bus_error_free(&error);
}
+ switch (arg_action) {
+ case ACTION_HALT:
+ action = "halt";
+ break;
+ case ACTION_POWEROFF:
+ action = "poweroff";
+ break;
+ case ACTION_KEXEC:
+ action = "kexec";
+ break;
+ default:
+ action = "reboot";
+ break;
+ }
+
+ if (arg_dry)
+ action = strjoina("dry-", action);
+
r = sd_bus_call_method(
b,
"org.freedesktop.login1",
@@ -7416,10 +7434,7 @@ static int halt_main(sd_bus *bus) {
&error,
NULL,
"st",
- arg_action == ACTION_HALT ? "halt" :
- arg_action == ACTION_POWEROFF ? "poweroff" :
- arg_action == ACTION_KEXEC ? "kexec" :
- "reboot",
+ action,
arg_when);
if (r < 0)
log_warning_errno(r, "Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: %s",