X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-action.c;h=74114ee0a126aede7f2dc48a137ba44b138d7fc8;hb=299404a19f26aa4f203042d8285ee0b7afa5bf40;hp=bd5664e90539bab48983fed5d8977690c3297da2;hpb=23406ce58aa7142e8df3c5c9e5ac34a01e90e3e0;p=elogind.git
diff --git a/src/login/logind-action.c b/src/login/logind-action.c
index bd5664e90..74114ee0a 100644
--- a/src/login/logind-action.c
+++ b/src/login/logind-action.c
@@ -19,10 +19,15 @@
along with systemd; If not, see .
***/
+#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,
@@ -54,15 +59,37 @@ int manager_handle_action(
DBusError error;
int r;
InhibitWhat inhibit_operation;
+ 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.");
return 0;
}
+ if (handle == HANDLE_SUSPEND)
+ supported = can_sleep("suspend") > 0;
+ else if (handle == HANDLE_HIBERNATE)
+ supported = can_sleep("hibernate") > 0;
+ else if (handle == HANDLE_HYBRID_SLEEP)
+ supported = can_sleep("hybrid-sleep") > 0;
+ else if (handle == HANDLE_KEXEC)
+ supported = access(KEXEC, X_OK) >= 0;
+ else
+ supported = true;
+
+ if (!supported) {
+ log_warning("Requested operation not supported, ignoring.");
+ return -ENOTSUP;
+ }
+
/* If the key handling is inhibited, don't do anything */
if (inhibit_key > 0) {
if (manager_is_inhibited(m, inhibit_key, INHIBIT_BLOCK, NULL, true, false, 0)) {