X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-action.c;h=74114ee0a126aede7f2dc48a137ba44b138d7fc8;hb=71fda00f320379f5cbee8e118848de98caaa229d;hp=e1517d6ac2573d28e045c143eb8538dd4b5d2083;hpb=dc3a1b76a6a6f9dfe9b451f534587251b50a0685;p=elogind.git diff --git a/src/login/logind-action.c b/src/login/logind-action.c index e1517d6ac..74114ee0a 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -21,10 +21,13 @@ #include +#include + #include "conf-parser.h" #include "special.h" #include "dbus-common.h" #include "logind-action.h" +#include "sleep-config.h" int manager_handle_action( Manager *m, @@ -56,10 +59,15 @@ int manager_handle_action( DBusError error; int r; InhibitWhat inhibit_operation; - bool supported = true; + bool supported; assert(m); + if (m->action_what) { + log_debug("Action already in progress, ignoring."); + return -EALREADY; + } + /* If the key handling is turned off, don't do anything */ if (handle == HANDLE_IGNORE) { log_debug("Refusing operation, as it is turned off."); @@ -67,13 +75,15 @@ int manager_handle_action( } if (handle == HANDLE_SUSPEND) - supported = can_sleep("mem") > 0; + supported = can_sleep("suspend") > 0; else if (handle == HANDLE_HIBERNATE) - supported = can_sleep("disk") > 0; + supported = can_sleep("hibernate") > 0; else if (handle == HANDLE_HYBRID_SLEEP) - supported = can_sleep("disk") > 0 && can_sleep_disk("suspend") > 0; + supported = can_sleep("hybrid-sleep") > 0; else if (handle == HANDLE_KEXEC) - supported = access("/sbin/kexec", X_OK) >= 0; + supported = access(KEXEC, X_OK) >= 0; + else + supported = true; if (!supported) { log_warning("Requested operation not supported, ignoring.");