From e19b8719a54c343372e16b462c27f1e84c987b85 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Wed, 1 Feb 2017 08:48:13 +0100 Subject: [PATCH] Handle suspend, shutdown, reboot, etc within elogind Since we are catching the keys, we might as well just do suspend/reboot/etc handling here. * configure.ac: Get paths of halt and reboot. * Makefile.am (systemsleepdir, systemshutdowndir): New variables. Look in them for hooks to run. * src/login/logind-action.c: Inline the salient bits from systemd's sleep/sleep.c here. * src/login/logind-dbus.c (execute_shutdown_or_sleep): Call our own shutdown_or_sleep helper instead of invoking a systemd method. * src/login/logind-action.h: Declare shutdown_or_sleep. --- Makefile.am | 6 ++ src/basic/special.h | 14 ++-- src/basic/util.c | 6 +- src/basic/util.h | 2 +- src/login/logind-action.c | 153 +++++++++++++++++++++++++++++++++++++- src/login/logind-action.h | 2 + src/login/logind-dbus.c | 102 +++++++++++++------------ src/login/logind.c | 4 +- src/login/logind.h | 14 ++++ 9 files changed, 238 insertions(+), 65 deletions(-) diff --git a/Makefile.am b/Makefile.am index d84cfd6f2..6e8805898 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,6 +52,8 @@ pkgconfiglibdir=$(libdir)/pkgconfig polkitpolicydir=$(datadir)/polkit-1/actions bashcompletiondir=@bashcompletiondir@ zshcompletiondir=@zshcompletiondir@ +systemsleepdir=$(pkglibexecdir)/sleep.d +systemshutdowndir=$(pkglibexecdir)/shutdown.d # Our own, non-special dirs pkgsysconfdir=$(sysconfdir)/elogind @@ -119,6 +121,10 @@ AM_CPPFLAGS = \ -DROOTPREFIX=\"$(rootprefix)\" \ -DUDEVLIBEXECDIR=\"$(udevlibexecdir)\" \ -DPOLKIT_AGENT_BINARY_PATH=\"$(bindir)/pkttyagent\" \ + -DSYSTEM_SLEEP_PATH=\"$(systemsleepdir)\" \ + -DSYSTEM_SHUTDOWN_PATH=\"$(systemshutdowndir)\" \ + -DHALT=\"$(HALT)\" \ + -DREBOOT=\"$(REBOOT)\" \ -DKEXEC=\"$(KEXEC)\" \ -DLIBDIR=\"$(libdir)\" \ -DROOTLIBDIR=\"$(rootlibdir)\" \ diff --git a/src/basic/special.h b/src/basic/special.h index f30458f25..fe377fbce 100644 --- a/src/basic/special.h +++ b/src/basic/special.h @@ -30,14 +30,14 @@ * it to bring all services down that want to be brought down on * system shutdown. */ #define SPECIAL_SHUTDOWN_TARGET "shutdown.target" -#define SPECIAL_HALT_TARGET "halt.target" -#define SPECIAL_POWEROFF_TARGET "poweroff.target" -#define SPECIAL_REBOOT_TARGET "reboot.target" -#define SPECIAL_KEXEC_TARGET "kexec.target" +// #define SPECIAL_HALT_TARGET "halt.target" +// #define SPECIAL_POWEROFF_TARGET "poweroff.target" +// #define SPECIAL_REBOOT_TARGET "reboot.target" +// #define SPECIAL_KEXEC_TARGET "kexec.target" #define SPECIAL_EXIT_TARGET "exit.target" -#define SPECIAL_SUSPEND_TARGET "suspend.target" -#define SPECIAL_HIBERNATE_TARGET "hibernate.target" -#define SPECIAL_HYBRID_SLEEP_TARGET "hybrid-sleep.target" +// #define SPECIAL_SUSPEND_TARGET "suspend.target" +// #define SPECIAL_HIBERNATE_TARGET "hibernate.target" +// #define SPECIAL_HYBRID_SLEEP_TARGET "hybrid-sleep.target" /* Special boot targets */ #define SPECIAL_RESCUE_TARGET "rescue.target" diff --git a/src/basic/util.c b/src/basic/util.c index 3df91488c..38de72966 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -79,7 +79,8 @@ #include "mkdir.h" #include "path-util.h" // #include "exit-status.h" -// #include "hashmap.h" +#include "hashmap.h" +#include "set.h" // #include "env-util.h" #include "fileio.h" // #include "device-nodes.h" @@ -2890,8 +2891,6 @@ bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) { return endswith(de->d_name, suffix); } -/// UNNEEDED by elogind -#if 0 static int do_execute(char **directories, usec_t timeout, char *argv[]) { _cleanup_hashmap_free_free_ Hashmap *pids = NULL; _cleanup_set_free_free_ Set *seen = NULL; @@ -3031,7 +3030,6 @@ void execute_directories(const char* const* directories, usec_t timeout, char *a wait_for_terminate_and_warn(name, executor_pid, true); } -#endif // 0 bool nulstr_contains(const char*nulstr, const char *needle) { const char *i; diff --git a/src/basic/util.h b/src/basic/util.h index afe5ec6a5..200f3befe 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -394,7 +394,7 @@ DIR *xopendirat(int dirfd, const char *name, int flags); // UNNEEDED char *fstab_node_to_udev_node(const char *p); -// UNNEEDED void execute_directories(const char* const* directories, usec_t timeout, char *argv[]); +void execute_directories(const char* const* directories, usec_t timeout, char *argv[]); bool nulstr_contains(const char*nulstr, const char *needle); diff --git a/src/login/logind-action.c b/src/login/logind-action.c index f635fb1b6..eba097c61 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -21,13 +21,17 @@ #include +#include "sd-messages.h" +#include "util.h" +#include "strv.h" +#include "fileio.h" #include "conf-parser.h" -#include "special.h" +// #include "special.h" #include "sleep-config.h" -#include "bus-util.h" #include "bus-error.h" +#include "bus-util.h" #include "logind-action.h" -#include "formats-util.h" +// #include "formats-util.h" #include "process-util.h" #include "terminal-util.h" @@ -48,6 +52,8 @@ int manager_handle_action( [HANDLE_HYBRID_SLEEP] = "Hibernating and suspending..." }; +/// elogind does this itself. No target table required +#if 0 static const char * const target_table[_HANDLE_ACTION_MAX] = { [HANDLE_POWEROFF] = SPECIAL_POWEROFF_TARGET, [HANDLE_REBOOT] = SPECIAL_REBOOT_TARGET, @@ -57,6 +63,7 @@ int manager_handle_action( [HANDLE_HIBERNATE] = SPECIAL_HIBERNATE_TARGET, [HANDLE_HYBRID_SLEEP] = SPECIAL_HYBRID_SLEEP_TARGET }; +#endif // 0 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; InhibitWhat inhibit_operation; @@ -153,7 +160,12 @@ int manager_handle_action( log_info("%s", message_table[handle]); +/// elogind uses its own variant, which can use the handle directly. +#if 0 r = bus_manager_shutdown_or_sleep_now_or_later(m, target_table[handle], inhibit_operation, &error); +#else + r = bus_manager_shutdown_or_sleep_now_or_later(m, handle, inhibit_operation, &error); +#endif // 0 if (r < 0) { log_error("Failed to execute operation: %s", bus_error_message(&error, r)); return r; @@ -162,6 +174,141 @@ int manager_handle_action( return 1; } +static int run_helper(const char *helper) { + int pid = fork(); + if (pid < 0) { + return log_error_errno(errno, "Failed to fork: %m"); + } + + if (pid == 0) { + /* Child */ + + close_all_fds(NULL, 0); + + execlp(helper, helper, NULL); + log_error_errno(errno, "Failed to execute %s: %m", helper); + _exit(EXIT_FAILURE); + } + + return wait_for_terminate_and_warn(helper, pid, true); +} + +static int write_mode(char **modes) { + int r = 0; + char **mode; + + STRV_FOREACH(mode, modes) { + int k; + + k = write_string_file("/sys/power/disk", *mode, 0); + if (k == 0) + return 0; + + log_debug_errno(k, "Failed to write '%s' to /sys/power/disk: %m", + *mode); + if (r == 0) + r = k; + } + + if (r < 0) + log_error_errno(r, "Failed to write mode to /sys/power/disk: %m"); + + return r; +} + +static int write_state(FILE **f, char **states) { + char **state; + int r = 0; + + STRV_FOREACH(state, states) { + int k; + + k = write_string_stream(*f, *state, true); + if (k == 0) + return 0; + log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m", + *state); + if (r == 0) + r = k; + + fclose(*f); + *f = fopen("/sys/power/state", "we"); + if (!*f) + return log_error_errno(errno, "Failed to open /sys/power/state: %m"); + } + + return r; +} + +static int do_sleep(const char *arg_verb) { + _cleanup_strv_free_ char **modes = NULL, **states = NULL; + char *arguments[] = { + NULL, + (char*) "pre", + (char*) arg_verb, + NULL + }; + static const char* const dirs[] = {SYSTEM_SLEEP_PATH, NULL}; + + int r; + _cleanup_fclose_ FILE *f = NULL; + + /* This file is opened first, so that if we hit an error, + * we can abort before modifying any state. */ + f = fopen("/sys/power/state", "we"); + if (!f) + return log_error_errno(errno, "Failed to open /sys/power/state: %m"); + + /* Configure the hibernation mode */ + r = write_mode(modes); + if (r < 0) + return r; + + execute_directories(dirs, DEFAULT_TIMEOUT_USEC, arguments); + + log_struct(LOG_INFO, + LOG_MESSAGE_ID(SD_MESSAGE_SLEEP_START), + LOG_MESSAGE("Suspending system..."), + "SLEEP=%s", arg_verb, + NULL); + + r = write_state(&f, states); + if (r < 0) + return r; + + log_struct(LOG_INFO, + LOG_MESSAGE_ID(SD_MESSAGE_SLEEP_STOP), + LOG_MESSAGE("System resumed."), + "SLEEP=%s", arg_verb, + NULL); + + arguments[1] = (char*) "post"; + execute_directories(dirs, DEFAULT_TIMEOUT_USEC, arguments); + + return r; +} + +int shutdown_or_sleep(HandleAction action) { + switch (action) { + case HANDLE_POWEROFF: + return run_helper(HALT); + case HANDLE_REBOOT: + return run_helper(REBOOT); + case HANDLE_HALT: + return run_helper(HALT); + case HANDLE_KEXEC: + return run_helper(KEXEC); + case HANDLE_SUSPEND: + return do_sleep("suspend"); + case HANDLE_HIBERNATE: + return do_sleep("hibernate"); + case HANDLE_HYBRID_SLEEP: + return do_sleep("hybrid-sleep"); + default: + return -EINVAL; + } +} + static const char* const handle_action_table[_HANDLE_ACTION_MAX] = { [HANDLE_IGNORE] = "ignore", [HANDLE_POWEROFF] = "poweroff", diff --git a/src/login/logind-action.h b/src/login/logind-action.h index ff9806537..5269237c6 100644 --- a/src/login/logind-action.h +++ b/src/login/logind-action.h @@ -44,6 +44,8 @@ int manager_handle_action( bool ignore_inhibited, bool is_edge); +int shutdown_or_sleep(HandleAction action); + const char* handle_action_to_string(HandleAction h) _const_; HandleAction handle_action_from_string(const char *s) _pure_; diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index a0a23788b..5245c8898 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -817,12 +817,9 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus session->create_message = sd_bus_message_ref(message); - /* Now, let's wait until the slice unit and stuff got - * created. We send the reply back from - * session_send_create_reply(). */ - - /* Elogind note: replying directly, since we're not actually - starting slices and thus we aren't waiting on systemd. */ + /* Here upstream systemd starts cgroups and the user systemd, + and arranges to reply asynchronously. We reply + directly. */ r = session_send_create_reply(session, NULL); if (r < 0) @@ -1351,29 +1348,33 @@ static int have_multiple_sessions( static int bus_manager_log_shutdown( Manager *m, InhibitWhat w, - const char *unit_name) { + HandleAction action) { const char *p, *q; assert(m); - assert(unit_name); if (w != INHIBIT_SHUTDOWN) return 0; - if (streq(unit_name, SPECIAL_POWEROFF_TARGET)) { + switch (action) { + case HANDLE_POWEROFF: p = "MESSAGE=System is powering down."; q = "SHUTDOWN=power-off"; - } else if (streq(unit_name, SPECIAL_HALT_TARGET)) { + break; + case HANDLE_HALT: p = "MESSAGE=System is halting."; q = "SHUTDOWN=halt"; - } else if (streq(unit_name, SPECIAL_REBOOT_TARGET)) { + break; + case HANDLE_REBOOT: p = "MESSAGE=System is rebooting."; q = "SHUTDOWN=reboot"; - } else if (streq(unit_name, SPECIAL_KEXEC_TARGET)) { + break; + case HANDLE_KEXEC: p = "MESSAGE=System is rebooting with kexec."; q = "SHUTDOWN=kexec"; - } else { + break; + default: p = "MESSAGE=System is shutting down."; q = NULL; } @@ -1436,21 +1437,25 @@ int manager_set_lid_switch_ignore(Manager *m, usec_t until) { static int execute_shutdown_or_sleep( Manager *m, InhibitWhat w, - const char *unit_name, + HandleAction action, sd_bus_error *error) { +/// elogind does not need these, we do it ourselves +#if 0 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; const char *p; char *c; +#endif // 0 int r; assert(m); assert(w >= 0); assert(w < _INHIBIT_WHAT_MAX); - assert(unit_name); - bus_manager_log_shutdown(m, w, unit_name); + bus_manager_log_shutdown(m, w, action); +/// elogind does it directly without depending on systemd running the system +#if 0 r = sd_bus_call_method( m->bus, "org.freedesktop.systemd1", @@ -1459,10 +1464,15 @@ static int execute_shutdown_or_sleep( "StartUnit", error, &reply, - "ss", unit_name, "replace-irreversibly"); + "ss", NULL, "replace-irreversibly"); +#else + r = shutdown_or_sleep(action); +#endif // 0 if (r < 0) return r; +/// elogind neither needs a dbus reply, nor supports systemd action jobs +#if 0 r = sd_bus_message_read(reply, "o", &p); if (r < 0) return r; @@ -1475,6 +1485,7 @@ static int execute_shutdown_or_sleep( free(m->action_job); m->action_job = c; m->action_what = w; +#endif // 0 /* Make sure the lid switch is ignored for a while */ manager_set_lid_switch_ignore(m, now(CLOCK_MONOTONIC) + m->holdoff_timeout_usec); @@ -1495,7 +1506,7 @@ static int manager_inhibit_timeout_handler( assert(manager); assert(manager->inhibit_timeout_source == s); - if (manager->action_what == 0 || manager->action_job) + if (manager->action_what == 0) return 0; if (manager_is_inhibited(manager, manager->action_what, INHIBIT_DELAY, NULL, false, false, 0, &offending)) { @@ -1510,12 +1521,12 @@ static int manager_inhibit_timeout_handler( } /* Actually do the operation */ - r = execute_shutdown_or_sleep(manager, manager->action_what, manager->action_unit, &error); + r = execute_shutdown_or_sleep(manager, manager->action_what, manager->pending_action, &error); if (r < 0) { log_warning("Failed to send delayed message: %s", bus_error_message(&error, r)); - manager->action_unit = NULL; - manager->action_what = 0; + manager->pending_action = HANDLE_IGNORE; + manager->action_what = 0; } return 0; @@ -1524,7 +1535,7 @@ static int manager_inhibit_timeout_handler( static int delay_shutdown_or_sleep( Manager *m, InhibitWhat w, - const char *unit_name) { + HandleAction action) { int r; usec_t timeout_val; @@ -1532,7 +1543,6 @@ static int delay_shutdown_or_sleep( assert(m); assert(w >= 0); assert(w < _INHIBIT_WHAT_MAX); - assert(unit_name); timeout_val = now(CLOCK_MONOTONIC) + m->inhibit_delay_max; @@ -1551,7 +1561,7 @@ static int delay_shutdown_or_sleep( return r; } - m->action_unit = unit_name; + m->pending_action = action; m->action_what = w; return 0; @@ -1581,7 +1591,7 @@ static int send_prepare_for(Manager *m, InhibitWhat w, bool _active) { int bus_manager_shutdown_or_sleep_now_or_later( Manager *m, - const char *unit_name, + HandleAction action, InhibitWhat w, sd_bus_error *error) { @@ -1589,10 +1599,8 @@ int bus_manager_shutdown_or_sleep_now_or_later( int r; assert(m); - assert(unit_name); assert(w >= 0); assert(w <= _INHIBIT_WHAT_MAX); - assert(!m->action_job); /* Tell everybody to prepare for shutdown/sleep */ send_prepare_for(m, w, true); @@ -1604,11 +1612,11 @@ int bus_manager_shutdown_or_sleep_now_or_later( if (delayed) /* Shutdown is delayed, keep in mind what we * want to do, and start a timeout */ - r = delay_shutdown_or_sleep(m, w, unit_name); + r = delay_shutdown_or_sleep(m, w, action); else /* Shutdown is not delayed, execute it * immediately */ - r = execute_shutdown_or_sleep(m, w, unit_name, error); + r = execute_shutdown_or_sleep(m, w, action, error); return r; } @@ -1678,7 +1686,7 @@ static int verify_shutdown_creds( static int method_do_shutdown_or_sleep( Manager *m, sd_bus_message *message, - const char *unit_name, + HandleAction sleep_action, InhibitWhat w, const char *action, const char *action_multiple_sessions, @@ -1690,7 +1698,6 @@ static int method_do_shutdown_or_sleep( assert(m); assert(message); - assert(unit_name); assert(w >= 0); assert(w <= _INHIBIT_WHAT_MAX); @@ -1716,7 +1723,7 @@ static int method_do_shutdown_or_sleep( if (r != 0) return r; - r = bus_manager_shutdown_or_sleep_now_or_later(m, unit_name, w, error); + r = bus_manager_shutdown_or_sleep_now_or_later(m, sleep_action, w, error); if (r < 0) return r; @@ -1728,7 +1735,7 @@ static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error return method_do_shutdown_or_sleep( m, message, - SPECIAL_POWEROFF_TARGET, + HANDLE_POWEROFF, INHIBIT_SHUTDOWN, "org.freedesktop.login1.power-off", "org.freedesktop.login1.power-off-multiple-sessions", @@ -1742,7 +1749,7 @@ static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error * return method_do_shutdown_or_sleep( m, message, - SPECIAL_REBOOT_TARGET, + HANDLE_REBOOT, INHIBIT_SHUTDOWN, "org.freedesktop.login1.reboot", "org.freedesktop.login1.reboot-multiple-sessions", @@ -1756,7 +1763,7 @@ static int method_suspend(sd_bus_message *message, void *userdata, sd_bus_error return method_do_shutdown_or_sleep( m, message, - SPECIAL_SUSPEND_TARGET, + HANDLE_SUSPEND, INHIBIT_SLEEP, "org.freedesktop.login1.suspend", "org.freedesktop.login1.suspend-multiple-sessions", @@ -1846,7 +1853,7 @@ static int manager_scheduled_shutdown_handler( _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; Manager *m = userdata; - const char *target; + HandleAction action; int r; assert(m); @@ -1855,15 +1862,15 @@ static int manager_scheduled_shutdown_handler( return 0; if (streq(m->scheduled_shutdown_type, "halt")) - target = SPECIAL_HALT_TARGET; + action = HANDLE_HALT; else if (streq(m->scheduled_shutdown_type, "poweroff")) - target = SPECIAL_POWEROFF_TARGET; + action = HANDLE_POWEROFF; else - target = SPECIAL_REBOOT_TARGET; + action = HANDLE_REBOOT; - r = execute_shutdown_or_sleep(m, 0, target, &error); + r = execute_shutdown_or_sleep(m, 0, action, &error); if (r < 0) - return log_error_errno(r, "Unable to execute transition to %s: %m", target); + return log_error_errno(r, "Unable to execute transition to %s: %m", m->scheduled_shutdown_type); return 0; } @@ -2011,7 +2018,7 @@ static int method_hibernate(sd_bus_message *message, void *userdata, sd_bus_erro return method_do_shutdown_or_sleep( m, message, - SPECIAL_HIBERNATE_TARGET, + HANDLE_HIBERNATE, INHIBIT_SLEEP, "org.freedesktop.login1.hibernate", "org.freedesktop.login1.hibernate-multiple-sessions", @@ -2025,7 +2032,7 @@ static int method_hybrid_sleep(sd_bus_message *message, void *userdata, sd_bus_e return method_do_shutdown_or_sleep( m, message, - SPECIAL_HYBRID_SLEEP_TARGET, + HANDLE_HYBRID_SLEEP, INHIBIT_SLEEP, "org.freedesktop.login1.hibernate", "org.freedesktop.login1.hibernate-multiple-sessions", @@ -2524,6 +2531,8 @@ const sd_bus_vtable manager_vtable[] = { SD_BUS_VTABLE_END }; +/// UNNEEDED by elogind +#if 0 static int session_jobs_reply(Session *s, const char *unit, const char *result) { int r = 0; @@ -2577,11 +2586,8 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err session = hashmap_get(m->session_units, unit); if (session) { -/// elogind does not support scope jobs -#if 0 if (streq_ptr(path, session->scope_job)) session->scope_job = mfree(session->scope_job); -#endif // 0 session_jobs_reply(session, unit, result); @@ -2592,14 +2598,11 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err user = hashmap_get(m->user_units, unit); if (user) { -/// elogind does not support slice and service jobs -#if 0 if (streq_ptr(path, user->service_job)) user->service_job = mfree(user->service_job); if (streq_ptr(path, user->slice_job)) user->slice_job = mfree(user->slice_job); -#endif // 0 LIST_FOREACH(sessions_by_user, session, user->sessions) session_jobs_reply(session, unit, result); @@ -2610,6 +2613,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err return 0; } +#endif // 0 int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *path, *unit; diff --git a/src/login/logind.c b/src/login/logind.c index a51f02ebe..09007c255 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -197,7 +197,6 @@ static void manager_free(Manager *m) { free(m->scheduled_shutdown_type); free(m->scheduled_shutdown_tty); free(m->wall_message); - free(m->action_job); free(m); } @@ -643,6 +642,8 @@ static int manager_connect_bus(Manager *m) { if (r < 0) return log_error_errno(r, "Failed to add user enumerator: %m"); +/// elogind does not support systemd action jobs +#if 0 r = sd_bus_add_match(m->bus, NULL, "type='signal'," @@ -653,6 +654,7 @@ static int manager_connect_bus(Manager *m) { match_job_removed, m); if (r < 0) log_warning_errno(r, "Failed to add match for JobRemoved: %m"); +#endif // 0 r = sd_bus_add_match(m->bus, NULL, diff --git a/src/login/logind.h b/src/login/logind.h index 654744bb4..67ebbd88c 100644 --- a/src/login/logind.h +++ b/src/login/logind.h @@ -103,6 +103,8 @@ struct Manager { * this is != 0 and encodes what is being done */ InhibitWhat action_what; +/// elogind does all relevant actions on its own. No systemd jobs and units. +#if 0 /* If a shutdown/suspend was delayed due to a inhibitor this contains the unit name we are supposed to start after the delay is over */ @@ -111,6 +113,13 @@ struct Manager { /* If a shutdown/suspend is currently executed, then this is * the job of it */ char *action_job; +#else + /* If a shutdown/suspend was delayed due to a inhibitor this + contains the action we are supposed to perform after the + delay is over */ + HandleAction pending_action; +#endif // 0 + sd_event_source *inhibit_timeout_source; char *scheduled_shutdown_type; @@ -184,7 +193,12 @@ int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_err int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error); int match_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error); +/// eloginds own version does the action itself +#if 0 int bus_manager_shutdown_or_sleep_now_or_later(Manager *m, const char *unit_name, InhibitWhat w, sd_bus_error *error); +#else +int bus_manager_shutdown_or_sleep_now_or_later(Manager *m, HandleAction action, InhibitWhat w, sd_bus_error *error); +#endif // 0 int manager_send_changed(Manager *manager, const char *property, ...) _sentinel_; -- 2.30.2