summaryrefslogtreecommitdiff
path: root/src/login/logind-dbus.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2012-06-12 09:31:43 +0200
committerMichal Schmidt <mschmidt@redhat.com>2012-06-12 10:36:33 +0200
commit2154761fbbc931e3e3d83100fa42609c99cd2536 (patch)
tree8c43238bae6a3b7bf62cf743d73d34ad50a1f7dc /src/login/logind-dbus.c
parent4f5d327a49e1a40ae0a3b8f1855dc90f3c0d953f (diff)
logind: fix check for multiple sessions
The "$action-multiple-sessions" polkit actions are defined as "$action while other users are logged in". To me this implies that the following sessions should not count: - greeter sessions - user sessions belonging to the same user as the one who's asking Not sure how to treat class SESSION_LOCK_SCREEN. I never have these. I just ignore every class that's not SESSION_USER. https://bugzilla.redhat.com/show_bug.cgi?id=814424
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r--src/login/logind-dbus.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 17bd5e5c3c..3cde83166f 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -930,27 +930,20 @@ static int have_multiple_sessions(
DBusMessage *message,
DBusError *error) {
- Session *s;
+ Session *session;
+ Iterator i;
+ unsigned long ul;
assert(m);
- if (hashmap_size(m->sessions) > 1)
- return true;
-
- /* Hmm, there's only one session, but let's make sure it
- * actually belongs to the user who is asking. If not, better
- * be safe than sorry. */
-
- s = hashmap_first(m->sessions);
- if (s) {
- unsigned long ul;
-
- ul = dbus_bus_get_unix_user(connection, dbus_message_get_sender(message), error);
- if (ul == (unsigned long) -1)
- return -EIO;
+ ul = dbus_bus_get_unix_user(connection, dbus_message_get_sender(message), error);
+ if (ul == (unsigned long) -1)
+ return -EIO;
- return s->user->uid != ul;
- }
+ /* 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)
+ return true;
return false;
}