<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - user_elect_display() overwrites DISPLAY with TTY session when switching VT away from a graphical session"
href="https://bugs.freedesktop.org/show_bug.cgi?id=90769#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - user_elect_display() overwrites DISPLAY with TTY session when switching VT away from a graphical session"
href="https://bugs.freedesktop.org/show_bug.cgi?id=90769">bug 90769</a>
from <span class="vcard"><a class="email" href="mailto:bugzilla@tecnocode.co.uk" title="Philip Withnall <bugzilla@tecnocode.co.uk>"> <span class="fn">Philip Withnall</span></a>
</span></b>
<pre>Created <span class=""><a href="attachment.cgi?id=116145" name="attach_116145" title="logind: Fix user_elect_display() to be more stable">attachment 116145</a> <a href="attachment.cgi?id=116145&action=edit" title="logind: Fix user_elect_display() to be more stable">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=90769&attachment=116145'>[review]</a>
logind: Fix user_elect_display() to be more stable
The previous implementation of user_elect_display() could easily end up
overwriting the user’s valid graphical session with a new TTY session.
For example, consider the situation where there is one session:
c1, type = SESSION_X11, !stopping, class = SESSION_USER
it is initially elected as the user’s display (i.e. u->display = c1).
If another session is started, on a different VT, the sessions_by_user
list becomes:
c1, type = SESSION_X11, !stopping, class = SESSION_USER
c2, type = SESSION_TTY, !stopping, class = SESSION_USER
In the previous code, graphical = c1 and text = c2, as expected.
However, neither graphical nor text fulfil the conditions for setting
u->display = graphical (because neither is better than u->display), so
the code falls through to check the text variable. The conditions for
this match, as u->display->type != SESSION_TTY (it’s actually
SESSION_X11). Hence u->display is set to c2, which is incorrect, because
session c1 is still valid.
Refactor user_elect_display() to use a more explicit filter and
pre-order comparison over the sessions. This can be demonstrated to be
stable and only ever ‘upgrade’ the session to a more graphical one.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>