summaryrefslogtreecommitdiff
path: root/src/login/logind-session-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-09 16:14:19 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-09 18:35:36 +0100
commit309a29dfd24f4175de334ca1593e3fe2436ab082 (patch)
treead38b8a702fcde2b5a82d07ecf130e3ffd952268 /src/login/logind-session-dbus.c
parent3909ba34ec9b2c63d9938b6ba37af54a214fcff3 (diff)
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!).
Diffstat (limited to 'src/login/logind-session-dbus.c')
-rw-r--r--src/login/logind-session-dbus.c15
1 files changed, 7 insertions, 8 deletions
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;
}