From 309a29dfd24f4175de334ca1593e3fe2436ab082 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 9 Jan 2015 16:14:19 +0100 Subject: logind: when a bus call is done on a session, user or seat, optionally determine them from the caller credentials More specifically, if an operation is requested on a session with an empty name, the caller's session is used. If an operation is requested on a seat with an empty name, the seat of the caller's session is used. Finally, if an operation on the user with UID -1 is requested, the user of the client's session is used (and not the UID of the client!). --- src/login/logind-session-dbus.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/login/logind-session-dbus.c') diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c index a6b15f28a0..d3411314d8 100644 --- a/src/login/logind-session-dbus.c +++ b/src/login/logind-session-dbus.c @@ -490,23 +490,21 @@ int session_object_find(sd_bus *bus, const char *path, const char *interface, vo if (streq(path, "/org/freedesktop/login1/session/self")) { _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; sd_bus_message *message; - pid_t pid; + const char *name; message = sd_bus_get_current_message(bus); if (!message) return 0; - r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds); + r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_SESSION|SD_BUS_CREDS_AUGMENT, &creds); if (r < 0) return r; - r = sd_bus_creds_get_pid(creds, &pid); + r = sd_bus_creds_get_session(creds, &name); if (r < 0) return r; - r = manager_get_session_by_pid(m, pid, &session); - if (r <= 0) - return 0; + session = hashmap_get(m->sessions, name); } else { _cleanup_free_ char *e = NULL; const char *p; @@ -520,10 +518,11 @@ int session_object_find(sd_bus *bus, const char *path, const char *interface, vo return -ENOMEM; session = hashmap_get(m->sessions, e); - if (!session) - return 0; } + if (!session) + return 0; + *found = session; return 1; } -- cgit v1.2.3-54-g00ecf