logind: implement suspend/hibernate calls with inhibition logic

This commit is contained in:
Lennart Poettering
2012-05-08 19:02:25 +02:00
parent 6edd7d0a09
commit d889a2069a
11 changed files with 477 additions and 190 deletions
+11 -1
View File
@@ -1750,6 +1750,14 @@ static int reboot_with_logind(DBusConnection *bus, enum action a) {
method = "PowerOff";
break;
case ACTION_SUSPEND:
method = "Suspend";
break;
case ACTION_HIBERNATE:
method = "Hibernate";
break;
default:
return -EINVAL;
}
@@ -1839,7 +1847,9 @@ static int start_special(DBusConnection *bus, char **args) {
/* first try logind, to allow authentication with polkit */
if (geteuid() != 0 &&
(a == ACTION_POWEROFF ||
a == ACTION_REBOOT)) {
a == ACTION_REBOOT ||
a == ACTION_SUSPEND ||
a == ACTION_HIBERNATE)) {
r = reboot_with_logind(bus, a);
if (r >= 0)
return r;