]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
login: provide delayed action in ScheduledShutdown property
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 9 Oct 2024 01:07:31 +0000 (10:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 9 Oct 2024 16:59:31 +0000 (01:59 +0900)
Even though we can get the existence of delayed action through
PreparingForShutdownWithMetadata property or friends, for consistency
with CancelScheduledShutdown() method, it is better to also provide the
information through ScheduledShutdown property.

src/login/logind-dbus.c

index ee449a8445d3a98bb34f1dc702a0ab63af358638..04c09ba8ab822447ec186df1d5bbf98de39cd449 100644 (file)
@@ -412,10 +412,23 @@ static int property_get_scheduled_shutdown(
         if (r < 0)
                 return r;
 
-        r = sd_bus_message_append(
-                        reply, "st",
-                        handle_action_to_string(m->scheduled_shutdown_action),
-                        m->scheduled_shutdown_timeout);
+        if (m->delayed_action) {
+                usec_t t = m->scheduled_shutdown_timeout; /* fall back to the schedule time on failure below */
+
+                if (m->inhibit_timeout_source) {
+                        r = sd_event_source_get_time(m->inhibit_timeout_source, &t);
+                        if (r < 0)
+                                log_debug_errno(r, "Failed to get time of inhibit timeout event source, ignoring: %m");
+                }
+
+                r = sd_bus_message_append(
+                                reply, "st",
+                                handle_action_to_string(m->delayed_action->handle), t);
+        } else
+                r = sd_bus_message_append(
+                                reply, "st",
+                                handle_action_to_string(m->scheduled_shutdown_action),
+                                m->scheduled_shutdown_timeout);
         if (r < 0)
                 return r;