summaryrefslogtreecommitdiff
path: root/src/logind-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-06-24 22:55:39 +0200
committerLennart Poettering <lennart@poettering.net>2011-06-24 22:55:39 +0200
commit21c390ccd1b4f7bc962c16549df929ad518a1d37 (patch)
tree68458572b17f28cd20ea560216f0eea668cefddc /src/logind-dbus.c
parent0771475394887e3635e67196fa6f56486fa2126c (diff)
logind: properly handle if two session with identical loginuids are attempted to be created
Diffstat (limited to 'src/logind-dbus.c')
-rw-r--r--src/logind-dbus.c50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/logind-dbus.c b/src/logind-dbus.c
index 2bad549fc5..d48d68c2bb 100644
--- a/src/logind-dbus.c
+++ b/src/logind-dbus.c
@@ -314,9 +314,53 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
goto fail;
}
- if (hashmap_get(m->sessions, id)) {
- r = -EEXIST;
- goto fail;
+ session = hashmap_get(m->sessions, id);
+
+ if (session) {
+
+ /* Session already exists, client is probably
+ * something like "su" which changes uid but
+ * is still the same audit session */
+
+ reply = dbus_message_new_method_return(message);
+ if (!reply) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ /* Create a throw-away fd */
+ if (pipe(pipe_fds) < 0) {
+ r = -errno;
+ goto fail;
+ }
+
+ close_nointr_nofail(pipe_fds[0]);
+ pipe_fds[0] = -1;
+
+ p = session_bus_path(session);
+ if (!p) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ b = dbus_message_append_args(
+ reply,
+ DBUS_TYPE_STRING, &session->id,
+ DBUS_TYPE_OBJECT_PATH, &p,
+ DBUS_TYPE_STRING, &session->user->runtime_path,
+ DBUS_TYPE_UNIX_FD, &pipe_fds[1],
+ DBUS_TYPE_INVALID);
+ free(p);
+
+ if (!b) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ close_nointr_nofail(pipe_fds[1]);
+ *_reply = reply;
+
+ return 0;
}
} else {