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;
}
static int have_multiple_sessions(
- DBusConnection *connection,
Manager *m,
- DBusMessage *message,
- DBusError *error) {
+ uid_t uid) {
Session *session;
Iterator i;
- unsigned long ul;
assert(m);
- ul = dbus_bus_get_unix_user(connection, dbus_message_get_sender(message), error);
- if (ul == (unsigned long) -1)
- return -EIO;
-
/* Check for other users' sessions. Greeter sessions do not count. */
HASHMAP_FOREACH(session, m->sessions, i)
- if (session->class == SESSION_USER && session->user->uid != ul)
+ if (session->class == SESSION_USER && session->user->uid != uid)
return true;
return false;
const char *result;
DBusMessage *reply = NULL;
int r;
+ unsigned long ul;
assert(m);
assert(connection);
}
}
- r = have_multiple_sessions(connection, m, message, error);
+ ul = dbus_bus_get_unix_user(connection, dbus_message_get_sender(message), error);
+ if (ul == (unsigned long) -1)
+ return -EIO;
+
+ r = have_multiple_sessions(m, (uid_t) ul);
if (r < 0)
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, true, (uid_t) ul);
if (multiple_sessions) {
r = verify_polkit(connection, message, action_multiple_sessions, false, &challenge, error);
delayed =
m->inhibit_delay_max > 0 &&
- manager_is_inhibited(m, w, INHIBIT_DELAY, NULL);
+ manager_is_inhibited(m, w, INHIBIT_DELAY, NULL, false, false, 0);
if (delayed)
/* Shutdown is delayed, keep in mind what we
bool multiple_sessions, blocked;
DBusMessage *reply = NULL;
int r;
+ unsigned long ul;
assert(m);
assert(connection);
return -ENOTSUP;
}
- r = have_multiple_sessions(connection, m, message, error);
+ ul = dbus_bus_get_unix_user(connection, dbus_message_get_sender(message), error);
+ if (ul == (unsigned long) -1)
+ return -EIO;
+
+ r = have_multiple_sessions(m, (uid_t) ul);
if (r < 0)
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, true, (uid_t) ul);
if (multiple_sessions) {
r = verify_polkit(connection, message, action_multiple_sessions, interactive, NULL, error);
/* 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, false, 0);
if (delayed)
return 0;