2014-09-19 15:11:36 +02:00
|
|
|
---
|
|
|
|
src/login/logind-action.c | 5 +++++
|
|
|
|
src/login/logind-dbus.c | 20 ++++++++++++++++----
|
|
|
|
2 files changed, 21 insertions(+), 4 deletions(-)
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
Index: systemd-218/src/login/logind-action.c
|
2014-09-19 15:11:36 +02:00
|
|
|
===================================================================
|
2015-02-13 10:43:21 +01:00
|
|
|
--- systemd-218.orig/src/login/logind-action.c
|
|
|
|
+++ systemd-218/src/login/logind-action.c
|
|
|
|
@@ -83,6 +83,11 @@ int manager_handle_action(
|
2014-09-19 15:11:36 +02:00
|
|
|
|
|
|
|
/* If the key handling is inhibited, don't do anything */
|
|
|
|
if (inhibit_key > 0) {
|
|
|
|
+ if (inhibit_key == INHIBIT_HANDLE_POWER_KEY) {
|
|
|
|
+ int fd;
|
|
|
|
+ fd = open("/run/systemd/acpi-shutdown", O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR);
|
|
|
|
+ close(fd);
|
|
|
|
+ }
|
|
|
|
if (manager_is_inhibited(m, inhibit_key, INHIBIT_BLOCK, NULL, true, false, 0, NULL)) {
|
|
|
|
log_debug("Refusing operation, %s is inhibited.", inhibit_what_to_string(inhibit_key));
|
|
|
|
return 0;
|
2015-02-13 10:43:21 +01:00
|
|
|
Index: systemd-218/src/login/logind-dbus.c
|
2014-09-19 15:11:36 +02:00
|
|
|
===================================================================
|
2015-02-13 10:43:21 +01:00
|
|
|
--- systemd-218.orig/src/login/logind-dbus.c
|
|
|
|
+++ systemd-218/src/login/logind-dbus.c
|
|
|
|
@@ -1487,9 +1487,11 @@ static int method_do_shutdown_or_sleep(
|
2014-09-19 15:11:36 +02:00
|
|
|
sd_bus_error *error) {
|
|
|
|
|
|
|
|
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
|
|
|
|
- bool multiple_sessions, blocked;
|
|
|
|
+ bool multiple_sessions, blocked, shutdown_through_acpi;
|
|
|
|
int interactive, r;
|
|
|
|
uid_t uid;
|
|
|
|
+ int fd;
|
|
|
|
+ struct stat buf;
|
|
|
|
|
|
|
|
assert(m);
|
|
|
|
assert(message);
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -1533,7 +1535,17 @@ static int method_do_shutdown_or_sleep(
|
2014-09-19 15:11:36 +02:00
|
|
|
multiple_sessions = r > 0;
|
|
|
|
blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid, NULL);
|
|
|
|
|
|
|
|
- if (multiple_sessions) {
|
|
|
|
+ fd = open ("/run/systemd/acpi-shutdown", O_NOFOLLOW|O_PATH|O_CLOEXEC);
|
|
|
|
+ if (fd >= 0) {
|
2014-09-24 17:07:37 +02:00
|
|
|
+ shutdown_through_acpi = ((fstat(fd,&buf) == 0) && (time(NULL) - buf.st_mtime <= 65) && !sleep_verb);
|
2014-09-19 15:11:36 +02:00
|
|
|
+ close(fd);
|
|
|
|
+ unlink ("/run/systemd/acpi-shutdown");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ shutdown_through_acpi = false;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (multiple_sessions && !shutdown_through_acpi) {
|
2015-02-13 10:43:21 +01:00
|
|
|
r = bus_verify_polkit_async(message, CAP_SYS_BOOT, action_multiple_sessions, interactive, &m->polkit_registry, error);
|
2014-09-19 15:11:36 +02:00
|
|
|
if (r < 0)
|
2015-02-13 10:43:21 +01:00
|
|
|
return r;
|
|
|
|
@@ -1541,7 +1553,7 @@ static int method_do_shutdown_or_sleep(
|
2014-09-19 15:11:36 +02:00
|
|
|
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (blocked) {
|
|
|
|
+ if (blocked && !shutdown_through_acpi) {
|
2015-02-13 10:43:21 +01:00
|
|
|
r = bus_verify_polkit_async(message, CAP_SYS_BOOT, action_ignore_inhibit, interactive, &m->polkit_registry, error);
|
2014-09-19 15:11:36 +02:00
|
|
|
if (r < 0)
|
2015-02-13 10:43:21 +01:00
|
|
|
return r;
|
|
|
|
@@ -1549,7 +1561,7 @@ static int method_do_shutdown_or_sleep(
|
2014-09-19 15:11:36 +02:00
|
|
|
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (!multiple_sessions && !blocked) {
|
|
|
|
+ if (!multiple_sessions && !blocked && !shutdown_through_acpi) {
|
2015-02-13 10:43:21 +01:00
|
|
|
r = bus_verify_polkit_async(message, CAP_SYS_BOOT, action, interactive, &m->polkit_registry, error);
|
2014-09-19 15:11:36 +02:00
|
|
|
if (r < 0)
|
2015-02-13 10:43:21 +01:00
|
|
|
return r;
|