1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00

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
This commit is contained in:
Michal Schmidt 2012-06-12 09:31:43 +02:00
parent 4f5d327a49
commit 2154761fbb

View File

@ -930,27 +930,20 @@ static int have_multiple_sessions(
DBusMessage *message, DBusMessage *message,
DBusError *error) { DBusError *error) {
Session *s; Session *session;
Iterator i;
unsigned long ul;
assert(m); assert(m);
if (hashmap_size(m->sessions) > 1) ul = dbus_bus_get_unix_user(connection, dbus_message_get_sender(message), error);
return true; if (ul == (unsigned long) -1)
return -EIO;
/* Hmm, there's only one session, but let's make sure it /* Check for other users' sessions. Greeter sessions do not count. */
* actually belongs to the user who is asking. If not, better HASHMAP_FOREACH(session, m->sessions, i)
* be safe than sorry. */ if (session->class == SESSION_USER && session->user->uid != ul)
return true;
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;
return s->user->uid != ul;
}
return false; return false;
} }