]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: if no logind, don't try to schedule shutdown
authorSamuel Morris <samorris@lexmark.com>
Tue, 28 Aug 2018 14:40:51 +0000 (10:40 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 29 Aug 2018 15:51:53 +0000 (17:51 +0200)
If logind is not supported, don't try to schedule a shutdown,
immediately poweroff. This is the behavior indicated by the current
message given to the user, but the command is returning an error. I
believe this was broken on this commit:
7f96539d45028650f2ba9452095473a9c455d84b

src/systemctl/systemctl.c

index c91363f9d7320d17c9d261757b4bee5880a84b54..ff204cd789ce2d05ce7c9d5a8b26a29f3cfe3dad 100644 (file)
@@ -8511,7 +8511,6 @@ static int halt_now(enum action a) {
 
 static int logind_schedule_shutdown(void) {
 
-#if ENABLE_LOGIND
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
         char date[FORMAT_TIMESTAMP_MAX];
         const char *action;
@@ -8563,10 +8562,6 @@ static int logind_schedule_shutdown(void) {
         if (!arg_quiet)
                 log_info("Shutdown scheduled for %s, use 'shutdown -c' to cancel.", format_timestamp(date, sizeof(date), arg_when));
         return 0;
-#else
-        log_error("Cannot schedule shutdown without logind support, proceeding with immediate shutdown.");
-        return -ENOSYS;
-#endif
 }
 
 static int halt_main(void) {
@@ -8577,7 +8572,11 @@ static int halt_main(void) {
                 return r;
 
         if (arg_when > 0)
+#if ENABLE_LOGIND
                 return logind_schedule_shutdown();
+#else
+                log_error("Cannot schedule shutdown without logind support, proceeding with immediate shutdown.");
+#endif
 
         if (geteuid() != 0) {
                 if (arg_dry_run || arg_force > 0) {