X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogin%2Flogind-dbus.c;h=3cde83166f21208424f87fa1fd8e43255e8c441c;hp=17bd5e5c3cde493462fe236f1537495a2b6ba68d;hb=2154761fbbc931e3e3d83100fa42609c99cd2536;hpb=4f5d327a49e1a40ae0a3b8f1855dc90f3c0d953f diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 17bd5e5c3..3cde83166 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; }