chiark / gitweb /
Prep v231.2: Really set an extra wall message (if any) and display it when cancelling...
authorSven Eden <yamakuzure@gmx.net>
Mon, 26 Jun 2017 06:18:53 +0000 (08:18 +0200)
committerSven Eden <yamakuzure@gmx.net>
Mon, 26 Jun 2017 06:18:53 +0000 (08:18 +0200)
src/login/eloginctl.c
src/login/logind-dbus.c

index f86109d..e67c14f 100644 (file)
@@ -176,6 +176,14 @@ int elogind_cancel_shutdown(sd_bus *bus) {
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
         int r;
 
+        r = elogind_set_wall_message(bus, NULL);
+
+        if (r < 0) {
+                log_warning_errno(r, "Failed to set wall message, ignoring: %s",
+                                  bus_error_message(&error, r));
+                sd_bus_error_free(&error);
+        }
+
         r = sd_bus_call_method(
                         bus,
                         "org.freedesktop.login1",
index cb67c66..9001fbc 100644 (file)
@@ -2153,6 +2153,9 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_
 static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userdata, sd_bus_error *error) {
         Manager *m = userdata;
         bool cancelled;
+#if 1 /// elogind needs to construct the message to allow extra wall messages
+        _cleanup_free_ char *l = NULL;
+#endif // 1
 
         assert(m);
         assert(message);
@@ -2172,8 +2175,20 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
                         (void) sd_bus_creds_get_tty(creds, &tty);
                 }
 
+#if 0 /// elogind wants to allow extra cancellation messages
                 utmp_wall("The system shutdown has been cancelled",
                           uid_to_name(uid), tty, logind_wall_tty_filter, m);
+#else
+                r = asprintf(&l, "%s%sThe system shutdown has been cancelled!",
+                             strempty(m->wall_message),
+                             isempty(m->wall_message) ? "" : "\n");
+                if (r < 0) {
+                        log_oom();
+                        return 0;
+                }
+
+                utmp_wall(l, uid_to_name(uid), tty, logind_wall_tty_filter, m);
+#endif // 0
         }
 
         return sd_bus_reply_method_return(message, "b", cancelled);