diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-09-19 13:10:10 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-09-19 13:10:10 +0200 |
commit | beaafb2ea6be591882aef21fe19b88e3b2461087 (patch) | |
tree | a61b375510b84f6b43bccfde4bbe0d46372aece5 /src/login/logind-dbus.c | |
parent | 468b21de7c9327bb8747d36e6273ed7aed97052a (diff) |
logind: rework power key/suspend key/lid switch handling
http://lists.freedesktop.org/archives/systemd-devel/2012-September/006604.html
https://bugzilla.gnome.org/show_bug.cgi?id=680689
This changes the meaning of the
HandlePowerKey=/HandleSleepKey=/HandleLidSwitch= setting of logind.conf
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r-- | src/login/logind-dbus.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 4f180b013d..4ae5ba70ba 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -722,10 +722,19 @@ static int bus_manager_inhibit(Manager *m, DBusConnection *connection, DBusMessa goto fail; } + /* Delay is only supported for shutdown/sleep */ + if (mm == INHIBIT_DELAY && (w & ~(INHIBIT_SHUTDOWN|INHIBIT_SLEEP))) { + r = -EINVAL; + goto fail; + } + r = verify_polkit(connection, message, - w == INHIBIT_SHUTDOWN ? (mm == INHIBIT_BLOCK ? "org.freedesktop.login1.inhibit-block-shutdown" : "org.freedesktop.login1.inhibit-delay-shutdown") : - w == INHIBIT_SLEEP ? (mm == INHIBIT_BLOCK ? "org.freedesktop.login1.inhibit-block-sleep" : "org.freedesktop.login1.inhibit-delay-sleep") : - (mm == INHIBIT_BLOCK ? "org.freedesktop.login1.inhibit-block-idle" : "org.freedesktop.login1.inhibit-delay-idle"), + w == INHIBIT_SHUTDOWN ? (mm == INHIBIT_BLOCK ? "org.freedesktop.login1.inhibit-block-shutdown" : "org.freedesktop.login1.inhibit-delay-shutdown") : + w == INHIBIT_SLEEP ? (mm == INHIBIT_BLOCK ? "org.freedesktop.login1.inhibit-block-sleep" : "org.freedesktop.login1.inhibit-delay-sleep") : + w == INHIBIT_IDLE ? "org.freedesktop.login1.inhibit-block-idle" : + w == INHIBIT_HANDLE_POWER_KEY ? "org.freedesktop.login1.inhibit-handle-power-key" : + w == INHIBIT_HANDLE_SLEEP_KEY ? "org.freedesktop.login1.inhibit-handle-sleep-key" : + "org.freedesktop.login1.inhibit-handle-lid-switch", false, NULL, error); if (r < 0) goto fail; @@ -1079,7 +1088,7 @@ static int bus_manager_can_shutdown_or_sleep( return r; multiple_sessions = r > 0; - blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL); + blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false); if (multiple_sessions) { r = verify_polkit(connection, message, action_multiple_sessions, false, &challenge, error); @@ -1193,7 +1202,7 @@ int bus_manager_shutdown_or_sleep_now_or_later( delayed = m->inhibit_delay_max > 0 && - manager_is_inhibited(m, w, INHIBIT_DELAY, NULL); + manager_is_inhibited(m, w, INHIBIT_DELAY, NULL, false); if (delayed) /* Shutdown is delayed, keep in mind what we @@ -1261,7 +1270,7 @@ static int bus_manager_do_shutdown_or_sleep( return r; multiple_sessions = r > 0; - blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL); + blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false); if (multiple_sessions) { r = verify_polkit(connection, message, action_multiple_sessions, interactive, NULL, error); @@ -2294,7 +2303,7 @@ int manager_dispatch_delayed(Manager *manager) { /* Continue delay? */ delayed = manager->delayed_timestamp + manager->inhibit_delay_max > now(CLOCK_MONOTONIC) && - manager_is_inhibited(manager, manager->delayed_what, INHIBIT_DELAY, NULL); + manager_is_inhibited(manager, manager->delayed_what, INHIBIT_DELAY, NULL, false); if (delayed) return 0; |