From c6d49c2d669fcdb1e4e98439b98a6a2a43c5bdc1 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Mon, 26 Jun 2017 08:03:24 +0200 Subject: [PATCH] Prep v231.2: loginctl: Move check for cancelling a scheduled shutdown to allow extra wall messages. --- src/login/eloginctl.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/login/eloginctl.c b/src/login/eloginctl.c index 9e40e87ad..f86109dc2 100644 --- a/src/login/eloginctl.c +++ b/src/login/eloginctl.c @@ -196,6 +196,7 @@ void elogind_cleanup(void) { } static void elogind_log_special(enum elogind_action a) { +#ifdef ENABLE_DEBUG_ELOGIND switch (a) { case ACTION_HALT: log_struct(LOG_INFO, @@ -246,6 +247,7 @@ static void elogind_log_special(enum elogind_action a) { default: break; } +#endif // ENABLE_DEBUG_ELOGIND } static int elogind_reboot(sd_bus *bus, enum elogind_action a) { @@ -260,8 +262,6 @@ static int elogind_reboot(sd_bus *bus, enum elogind_action a) { if (!bus) return -EIO; - polkit_agent_open_if_enabled(); - switch (a) { case ACTION_POWEROFF: @@ -288,6 +288,7 @@ static int elogind_reboot(sd_bus *bus, enum elogind_action a) { return -EINVAL; } + polkit_agent_open_if_enabled(); r = elogind_set_wall_message(bus, table[a]); if (r < 0) { @@ -305,8 +306,7 @@ static int elogind_reboot(sd_bus *bus, enum elogind_action a) { method, &error, NULL, - "b", - arg_ask_password); + "b", arg_ask_password); if (r < 0) log_error("Failed to execute operation: %s", bus_error_message(&error, r)); @@ -322,8 +322,6 @@ static int elogind_schedule_shutdown(sd_bus *bus, enum elogind_action a) { if (!bus) return -EIO; - polkit_agent_open_if_enabled(); - switch (a) { case ACTION_POWEROFF: @@ -468,20 +466,9 @@ int start_special(int argc, char *argv[], void *userdata) { elogind_log_special(a); - /* Switch to cancel shutdown, if a shutdown action was requested, - and the option to cancel it was set: */ - if ( IN_SET(a, ACTION_POWEROFF, ACTION_REBOOT) - && (arg_action == ACTION_CANCEL_SHUTDOWN) ) - return elogind_cancel_shutdown(bus); - - r = check_inhibitors(bus, a); - if (r < 0) - return r; - /* No power off actions in chroot environments */ - if ((a == ACTION_POWEROFF || - a == ACTION_REBOOT) && - (running_in_chroot() > 0) ) { + if ( IN_SET(a, ACTION_POWEROFF, ACTION_REBOOT) + && (running_in_chroot() > 0) ) { log_info("Running in chroot, ignoring request."); return 0; } @@ -512,6 +499,16 @@ int start_special(int argc, char *argv[], void *userdata) { return log_oom(); } + /* Switch to cancel shutdown, if a shutdown action was requested, + and the option to cancel it was set: */ + if ( IN_SET(a, ACTION_POWEROFF, ACTION_REBOOT) + && (arg_action == ACTION_CANCEL_SHUTDOWN) ) + return elogind_cancel_shutdown(bus); + + r = check_inhibitors(bus, a); + if (r < 0) + return r; + /* Perform requested action */ if (IN_SET(a, ACTION_POWEROFF, -- 2.30.2