chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
679b7d7
)
logind: don't allow suspending/hibernating if the kernel doesn't support it
author
Lennart Poettering
<lennart@poettering.net>
Sun, 23 Dec 2012 21:12:01 +0000
(22:12 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Sun, 23 Dec 2012 23:29:40 +0000
(
00:29
+0100)
src/login/logind-action.c
patch
|
blob
|
history
diff --git
a/src/login/logind-action.c
b/src/login/logind-action.c
index bd5664e90539bab48983fed5d8977690c3297da2..e1517d6ac2573d28e045c143eb8538dd4b5d2083 100644
(file)
--- a/
src/login/logind-action.c
+++ b/
src/login/logind-action.c
@@
-19,6
+19,8
@@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <unistd.h>
+
#include "conf-parser.h"
#include "special.h"
#include "dbus-common.h"
#include "conf-parser.h"
#include "special.h"
#include "dbus-common.h"
@@
-54,6
+56,7
@@
int manager_handle_action(
DBusError error;
int r;
InhibitWhat inhibit_operation;
DBusError error;
int r;
InhibitWhat inhibit_operation;
+ bool supported = true;
assert(m);
assert(m);
@@
-63,6
+66,20
@@
int manager_handle_action(
return 0;
}
return 0;
}
+ if (handle == HANDLE_SUSPEND)
+ supported = can_sleep("mem") > 0;
+ else if (handle == HANDLE_HIBERNATE)
+ supported = can_sleep("disk") > 0;
+ else if (handle == HANDLE_HYBRID_SLEEP)
+ supported = can_sleep("disk") > 0 && can_sleep_disk("suspend") > 0;
+ else if (handle == HANDLE_KEXEC)
+ supported = access("/sbin/kexec", X_OK) >= 0;
+
+ 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)) {
/* 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)) {