<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, 8 Jul 2015 at 04:31 David Herrmann <<a href="mailto:dh.herrmann@gmail.com">dh.herrmann@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
<br>
On Tue, Jul 7, 2015 at 6:14 PM, poma <<a href="mailto:pomidorabelisima@gmail.com" target="_blank">pomidorabelisima@gmail.com</a>> wrote:<br>
><br>
> Revert "login: re-use VT-sessions if they already exist" - commit 0204c4b<br>
> <a href="http://cgit.freedesktop.org/systemd/systemd/commit/?id=0204c4b" rel="noreferrer" target="_blank">http://cgit.freedesktop.org/systemd/systemd/commit/?id=0204c4b</a><br>
<br>
Can someone elaborate what exactly lightdm does here? We really want<br>
to prevent multiple sessions on the same VT. This is just nasty and<br>
never made any sense. So I'm really interested why lightdm doesn't<br>
kill it's manager-session before it starts the new session. Any<br>
particular reason here?<br>
<br>
Furthermore, how exactly does lightdm do all this. Is there a control<br>
daemon running outside the session, then there's the graphical login<br>
processes with their own 'lightdm' session? Once the login is done,<br>
you start the new session from the control daemon and _afterwards_<br>
destroy the lightdm-session?<br>
<br></blockquote><div><br></div><div>If I follow the thread correctly the issue here is having two logind sessions open using the same VT?<br><br></div><div>Yes, this can definitely happen in LightDM in the following case:<br><br></div><div>1. LightDM starts up<br></div><div>2. LightDM starts an X server on a free VT (e.g. 7)<br></div><div>3. LightDM starts a greeter process which connects to the X server. Via libpam-systemd a logind session is opened.<br></div><div>4. User logs in via greeter.<br></div><div>5. LightDM stops the greeter by sending a SIGTERM to it. The greeter closes the PAM session which closes the logind session.<br></div><div>6. LightDM starts the user session. The existing X server is used so this session is on the same VT as the greeter session was.<br><br></div><div>The issue is that after step 5 LightDM considers the greeter session to be completely closed. However, it appears that closing the PAM session only cases the logind session to be put into the "closing" state. As pointed out we have an issue where Unity Greeter isn't waiting for some of its child processes before exiting and that is keeping the logind session open for a short time. I think there's still a race here in any case because the display manager just has no idea when the session is really closed.<br><br></div><div>I've been looking for the right way to handle this with logind since we should be able to make the daemon completely aware of the state of the session so we can avoid this. GDM as far as I can tell also doesn't appear to check if the logind sesion is actually closed.<br><br></div><div>The check for the greeter is certainly a workaround for the particular first login case as described above. The issue can also probably occur by a misbehaving user session. i.e. logging out then in again could leave the display manager thinking a VT is free while there are still logind sessions open with that VT.<br><br></div><div>So the correct solution might be to just to ignore logind sessions in the "closing" state when checking if a VT is used more than once.<br><br></div><div>Another option is to require display managers to ensure a logind session is closed before reusing VTs. This would require more work and also is a little bit weird in the traditional X case since the VT is actually owned by the X server and not the session.<br><br></div><div>--Robert<br></div></div></div>