Bug 81932 - logind (215) not allowing more than one non-root Xorg server to open its own virtual terminal
Summary: logind (215) not allowing more than one non-root Xorg server to open its own ...
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-30 22:25 UTC by Brian Bidulock
Modified: 2014-08-18 21:04 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Brian Bidulock 2014-07-30 22:25:16 UTC

    
Comment 1 Brian Bidulock 2014-07-30 22:35:26 UTC
Woah, don't hit enter on the description line....

The problem experienced is when attemping to run two Xorg 1.16 servers non-root from startx in seperate virtual terminals.  The first starts ok, the second fails when attempting to open its virtual terminal.  From Xorg.*.log of the second:

 [  8259.535] (II) systemd-logind: took control of session /org/freedesktop/login1/session/c10
 [  8259.536] (II) xfree86: Adding drm device (/dev/dri/card0)
 [  8259.536] (II) systemd-logind: got fd for /dev/dri/card0 226:0 fd 12 paused 0
 ...
 [  8259.549] (++) using VT number 6
 [  8259.554] (--) controlling tty is VT number 6, auto-enabling KeepTty
 [  8259.554] (EE) 
 Fatal server error:
 [  8259.568] (EE) xf86OpenConsole: Cannot open virtual console 6 (Permission denied)
 [  8259.573] (EE) 
 [  8259.578] (EE) 

From journalctl:

 Jul 30 14:41:59 habeascorpus.pigworks.openss7.net login[8764]: LOGIN ON tty5 BY brian
 Jul 30 14:42:17 habeascorpus.pigworks.openss7.net systemd-logind[601]: cannot mute VT 5 for session c15 (-16/17)

Looking at src/login/logind-session.c where this error message is generated, it uses sigprocmask to block USR1 signal and calls sd_event_add_signal().  sd_event_add_signal() uses pthread_sigmask() to check that USR1 is blocked (which it isn't for the second Xorg server) and returns -EBUSY (-16 in error message).  sigprocmask() is for use only in single-threaded programs.  It appears that sigprocmask() is blocking USR1 on the main thread and pthread_sigmask() is checking it in the running thread.  This results in sd_restore_vts() setting the permission on the virtual terminal back to root, but the Xorg server is still allowed to take control of the session.  The result is that xf86OpenConsole() has insufficient permissions to open the virtual terminal.

Please correct.
Comment 2 Brian Bidulock 2014-07-31 00:06:34 UTC
I tried recompiling 215 with pthread_sigmask instead of sigprocmask in sd_prepare_vts() and it still behaves the same.  The -EBUSY must be returned from checking whether the signal is installed on s->manager->event in sd_event_add_signal() instead of the pthread_sigmask() check.  Is this the case of a per-session signal being managed as a manager-wide signal?
Comment 3 Lennart Poettering 2014-08-18 21:04:26 UTC
Should be fixed in git.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.