From e4b138548f33d03b7074753a84953060f9f81763 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 9 Oct 2024 10:07:31 +0900 Subject: [PATCH] login: provide delayed action in ScheduledShutdown property 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 | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index ee449a8445d..04c09ba8ab8 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -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; -- 2.47.3