summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-07-01 15:05:01 +0200
committerSven Eden <yamakuzure@gmx.net>2017-03-14 10:05:54 +0100
commitf03a8ebfc1c4acf74491ebd8ef5555a7f10f92c2 (patch)
tree0511c22a2abf4ea64c0b734f42dd75bb1d93c34d /src/login
parent2054442fa4eaef0d904bcbbe1b98f57386ceb87d (diff)
login: re-use VT-sessions if they already exist
Right now, if you start a session via 'su' or 'sudo' from within a session, we make sure to re-use the existing session instead of creating a new one. We detect this by reading the session of the requesting PID. However, with gnome-terminal running as a busname-unit, and as such running outside the session of the user, this will no longer work. Therefore, this patch makes sure to return the existing session of a VT if you start a new one. This has the side-effect, that you will re-use a session which your PID is not part of. This works fine, but will break assumptions if the parent session dies (and as such close your session even though you think you're part of it). However, this should be perfectly fine. If you run multiple logins on the same session, you should really know what you're doing. The current way of silently accepting it but choosing the last registered session is just weird.
Diffstat (limited to 'src/login')
-rw-r--r--src/login/logind-dbus.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 640ae92f7..659ce18a4 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -690,6 +690,8 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
}
manager_get_session_by_pid(m, leader, &session);
+ if (!session && vtnr > 0)
+ session = (vtnr < m->seat0->position_count) ? m->seat0->positions[vtnr] : NULL;
if (session) {
_cleanup_free_ char *path = NULL;
_cleanup_close_ int fifo_fd = -1;