Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 635102 - x11-base/xorg-server-1.19.5-r1: X server fails to start with error: "parse_vt_settings: Cannot open /dev/tty0 (Permission denied)"
Summary: x11-base/xorg-server-1.19.5-r1: X server fails to start with error: "parse_vt...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo X packagers
URL:
Whiteboard:
Keywords: PMASKED
Depends on:
Blocks:
 
Reported: 2017-10-22 21:05 UTC by Nick Wallingford
Modified: 2018-06-08 05:11 UTC (History)
18 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Xorg.0.log (Xorg.0.log,5.37 KB, text/plain)
2017-10-22 21:05 UTC, Nick Wallingford
Details
strace of /usr/libexec/Xorg failure (strace.log_running-usr-libexec-Xorg.log,46.48 KB, text/plain)
2017-10-23 11:47 UTC, Floyd Anderson
Details
startx.log (startx.log,1.81 KB, text/plain)
2018-03-02 16:14 UTC, Ben Kohler
Details
strace -ff -o /tmp/xorg startx -- vt2 - /usr/bin/X (xorg.logs.tar.gz,38.05 KB, application/gzip)
2018-03-08 19:56 UTC, Amadeusz Sławiński
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Wallingford 2017-10-22 21:05:39 UTC
Created attachment 499692 [details]
Xorg.0.log

After upgrading to -r1, X no longer works. startx shows a blank screen with a blinking cursor for a few seconds and then fails with an error:

parse_vt_settings: Cannot open /dev/tty0 (Permission denied)

Downgrading to xorg-server-1.19.5 and it starts working again.
Comment 1 Mark Nowiasz 2017-10-23 06:41:37 UTC
Something similar here - kodi didn't was unable to start. I think it has to do with the suid flag, which is missing in 1.19.5-r1 (but not in 1.19.5).
Comment 2 Tomáš Mózes 2017-10-23 10:49:19 UTC
Yes, please restore the suid USE flag:
https://github.com/gentoo/gentoo/commit/ca17c5f407cb5264369aafd39ead709e46777dc4

I also had the same problem.
Comment 3 Floyd Anderson 2017-10-23 11:47:27 UTC
Created attachment 499750 [details]
strace of /usr/libexec/Xorg failure

As mentioned in <https://bugs.gentoo.org/show_bug.cgi?id=450364#c5>, I got also
permission denied failures.

FWIW, in the last three years I never got hardware acceleration to work. I
always lost keyboard and mouse input when trying it and need a hard reboot afterwards. To avoid that I must explicitely set ‘Option "Accel" "no"’ to get
a working Xorg session.

While testing x11-base/xorg-server-1.19.5-r1[+suid-wrapper] and running Xorg
as root, I noticed (from the log) it runs *with* hardware acceleration for the
first time in all these years but I cannot use it because – guess what – I lost
my input devices. So for me it’s definitely a permission issue not just since
xorg-server-1.19.5-r1.
Comment 4 Larry the Git Cow gentoo-dev 2017-10-23 19:40:38 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7e9f7ca88eeeb4be5c5bfaa4f73cc3ba5c211947

commit 7e9f7ca88eeeb4be5c5bfaa4f73cc3ba5c211947
Author:     Chí-Thanh Christopher Nguyễn <chithanh@gentoo.org>
AuthorDate: 2017-10-23 19:40:12 +0000
Commit:     Chí-Thanh Christopher Nguyễn <chithanh@gentoo.org>
CommitDate: 2017-10-23 19:40:12 +0000

    profiles/package.mask: mask >=x11-base/xorg-server-1.19.5-r1
    
    Dropping suid breaks some use cases.
    
    Bug: https://bugs.gentoo.org/show_bug.cgi?id=450364
    Bug: https://bugs.gentoo.org/show_bug.cgi?id=635102

 profiles/package.mask | 5 +++++
 1 file changed, 5 insertions(+)}
Comment 5 jospezial 2017-10-25 16:50:56 UTC
(In reply to Floyd Anderson from comment #3)
> Created attachment 499750 [details]
> strace of /usr/libexec/Xorg failure
> 
> As mentioned in <https://bugs.gentoo.org/show_bug.cgi?id=450364#c5>, I got
> also
> permission denied failures.
> 
> FWIW, in the last three years I never got hardware acceleration to work. I
> always lost keyboard and mouse input when trying it and need a hard reboot
> afterwards. To avoid that I must explicitely set ‘Option "Accel" "no"’ to get
> a working Xorg session.
> 
> While testing x11-base/xorg-server-1.19.5-r1[+suid-wrapper] and running Xorg
> as root, I noticed (from the log) it runs *with* hardware acceleration for
> the
> first time in all these years but I cannot use it because – guess what – I
> lost
> my input devices. So for me it’s definitely a permission issue not just since
> xorg-server-1.19.5-r1.

Is your user in the video group?
Comment 6 Floyd Anderson 2017-10-26 04:39:33 UTC
(In reply to jospezial from comment #5)
>
> Is your user in the video group?

Yes, my user is in the video group. As you can see in my attachment, I’m able
to get a proper file descriptor, e.g. for ‘/dev/dri/card0’.

Thanks for your interest.
Comment 7 jospezial 2017-12-09 11:21:56 UTC
How does it go on?
Is upstream work needed or done?
Can we do something?

I use x11-base/xorg-server-9999::gentoo .
It is hit by "profiles/package.mask: mask >=x11-base/xorg-server-1.19.5-r1" too.
Can I rebuild it or will I have then problems too?

ls -l /usr/libexec/Xorg*
-rwxr-xr-x 1 root root 2910760 22. Okt 18:26 /usr/libexec/Xorg
-rws--x--x 1 root root   10360 22. Okt 18:26 /usr/libexec/Xorg.wrap
Comment 8 Larry the Git Cow gentoo-dev 2017-12-28 01:29:17 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=223d6b7e15d965e9254c303fa43f279deeec8f9d

commit 223d6b7e15d965e9254c303fa43f279deeec8f9d
Author:     Matt Turner <mattst88@gentoo.org>
AuthorDate: 2017-12-28 01:21:06 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2017-12-28 01:28:23 +0000

    x11-base/xorg-server: Drop version 1.19.5-r1
    
    -r1 changed suid behavior, breaking some users for unknown reasons.
    
    Bug: https://bugs.gentoo.org/635102
    Bug: https://bugs.gentoo.org/635582

 profiles/package.mask                             |   5 -
 x11-base/xorg-server/xorg-server-1.19.5-r1.ebuild | 251 ----------------------
 2 files changed, 256 deletions(-)}
Comment 9 jospezial 2017-12-29 18:50:44 UTC
(In reply to Larry the Git Cow from comment #8)
> The bug has been referenced in the following commit(s):
> 
> https://gitweb.gentoo.org/repo/gentoo.git/commit/
> ?id=223d6b7e15d965e9254c303fa43f279deeec8f9d
> 
> commit 223d6b7e15d965e9254c303fa43f279deeec8f9d
> Author:     Matt Turner <mattst88@gentoo.org>
> AuthorDate: 2017-12-28 01:21:06 +0000
> Commit:     Matt Turner <mattst88@gentoo.org>
> CommitDate: 2017-12-28 01:28:23 +0000
> 
>     x11-base/xorg-server: Drop version 1.19.5-r1
>     
>     -r1 changed suid behavior, breaking some users for unknown reasons.
>     
>     Bug: https://bugs.gentoo.org/635102
>     Bug: https://bugs.gentoo.org/635582
> 
>  profiles/package.mask                             |   5 -
>  x11-base/xorg-server/xorg-server-1.19.5-r1.ebuild | 251
> ----------------------
>  2 files changed, 256 deletions(-)}

xorg-server-9999.ebuild still has
--enable-suid-wrapper
instead of
$(use_enable suid install-setuid)

is this good or bad?
Comment 10 Matt Turner gentoo-dev 2018-03-01 20:01:29 UTC
I've added xorg-server-1.19.99.901 to the tree, with the --enable-suid-wrapper flag passed unconditionally. Let's give this another try and see if it still causes problems. If it does, I'll poke some people upstream and see if they have an idea what's wrong.
Comment 11 Ben Kohler gentoo-dev 2018-03-02 16:14:50 UTC
Created attachment 521850 [details]
startx.log

I am seeing a failure on this new xorg-server-1.19.99.901 but only on startx.  Starting sddm via /etc/init.d/xdm works ok.  I've attached the terminal output of startx.  I'm using openrc/consolekit.  

~/.xinitrc has "exec ck-launch-session startkde" in it, which does work ok on the older USE=suid xorg-server
Comment 12 Ben Kohler gentoo-dev 2018-03-02 16:59:32 UTC
FWIW if I add 'needs_root_rights = yes' to /etc/X11/X11/Xwrapper.config then startx does work, but I think this just short-circuits the whole thing to force root-Xorg on.  

So definitely not a proper solution but an ok workaround for people who cannot afford to downgrade xorg-server atm.
Comment 13 Nick Wallingford 2018-03-03 22:38:49 UTC
(In reply to Matt Turner from comment #10)
> I've added xorg-server-1.19.99.901 to the tree, with the
> --enable-suid-wrapper flag passed unconditionally. Let's give this another
> try and see if it still causes problems. If it does, I'll poke some people
> upstream and see if they have an idea what's wrong.

Fails for me with the same issue.
Comment 14 gyroninja 2018-03-03 23:24:56 UTC
I can confirm this is still happening as of early this morning.
A work around I saw online that worked for me was using "startx -- vt1 -keeptty" to launch X instead of just startx.
Comment 15 Andrey Grozin gentoo-dev 2018-03-06 12:45:24 UTC
(In reply to Matt Turner from comment #10)
> I've added xorg-server-1.19.99.901 to the tree, with the
> --enable-suid-wrapper flag passed unconditionally. Let's give this another
> try and see if it still causes problems. If it does, I'll poke some people
> upstream and see if they have an idea what's wrong.
After upgrading xorg-server to 1.19.99.901 on my notebook, startx fails, Xorg.0.log says

Fatal server error:
[    54.624] (EE) parse_vt_settings: Cannot open /dev/tty0 (Permission denied)

As a temporary workaround, I tried chmod o+x /dev/tty0 (I wanted to have X quickly). Then startx fails with

Fatal server error:
[   206.870] (EE) xf86OpenConsole: Cannot open virtual console 7 (Permission denied)

So, I had to downgrade xorg-server to 1.19.5-r1, and things returned to normal.
Comment 16 Konstantin M 2018-03-07 23:00:37 UTC
Same problem here, also with the updated ebuild xorg-server-1.19.99.901-r1.
Comment 17 Amadeusz Sławiński 2018-03-08 19:56:46 UTC
Created attachment 523028 [details]
strace -ff -o /tmp/xorg startx -- vt2  -  /usr/bin/X

So, on my desktop (xfce, VIDEO_CARDS="intel i965")
- X doesn't start when trying to "startx" and error is
parse_vt_settings: Cannot open /dev/tty0 (Permission denied)
strace is pretty clear, that it has problem opening tty device with simple "startx"
openat(AT_FDCWD, "/dev/tty0", O_WRONLY) = -1 EACCES (Permission denied)

in case I tell it, on which tty it tries to run (startx -- vt2)
ioctl(9, DRM_IOCTL_SET_MASTER, 0)       = -1 EACCES (Permission denied)

strace -ff -o /tmp/xorg attached (xorg.18578 seems to be of main interest)



And then on my laptop (windowmaker, no dbus, VIDEO_CARDS="nouveau", and was non root xorg as per instructions on wiki: https://wiki.gentoo.org/wiki/Non_root_Xorg)
- X starts, however mouse and keyboard doesn't respond

to get input back to working state I need to use permission change from wiki but instead of changing permission of /usr/bin/X, I need to apply changes on /usr/libexec/Xorg
(-rwxr-sr-x. 1 root input 2599560 Mar 7 22:27 /usr/libexec/Xorg)
Comment 18 Amadeusz Sławiński 2018-03-08 23:47:09 UTC
So I figured why it doesn't work on my desktop, apparently modesetting driver calls SetMaster() and if it fails it exits 
https://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/drivers/modesetting/driver.c#n1540

if I make it nonfailing it works similarly to my laptop, ie, I need to give it permissions to access input devices.
-rwxr-sr-x 1 root input 2573800 Mar  9 00:30 /usr/libexec/Xorg


Xorg.wrap, should probably be improved to check if it can call DRM_IOCTL_SET_MASTER for modesetting cards, as it is one that requires root rights
drivers/gpu/drm/drm_ioctl.c:    DRM_IOCTL_DEF(DRM_IOCTL_SET_MASTER, drm_setmaster_ioctl, DRM_UNLOCKED|DRM_ROOT_ONLY),

in contrast to the one it checks (https://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/xorg-wrapper.c#n245)
ddrivers/gpu/drm/rm_ioctl.c:    DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, DRM_CONTROL_ALLOW|DRM_UNLOCKED),


anyway it's probably for upstream to decide.

In the meantime can we go back to having suid flag? It's easier to manage.
Comment 19 gyroninja 2018-03-09 04:43:01 UTC
My input had broke too and I fixed it by emerging libinput IIRC. I saw messages about it not being able to load it in Xorg.log
Comment 20 Matt Turner gentoo-dev 2018-03-10 02:32:17 UTC
I just added xinit-1.4.0 to the tree, which looks like it has some potential fixes. Please give that a try.
Comment 21 gyroninja 2018-03-10 23:29:57 UTC
(In reply to Matt Turner from comment #20)
Nope. Same issue.
Comment 22 Amadeusz Sławiński 2018-03-11 17:16:47 UTC
So, I still need to run it as "startx -- vt1", if I want it to start at all (but I don't mind this, as it allows me to run as user)

Re intel modesetting problem, it's separate bug, so commented again here: https://bugs.gentoo.org/649678

As for input devices, apparently year ago there was migration to INPUT_DEVICES="libinput" on default profiles (https://bugs.gentoo.org/601132), but changing it to such config doesn't help me at all, I still need to change /usr/libexec/Xorg permissions to have it working
Comment 23 gyroninja 2018-03-11 22:34:29 UTC
I also want to clarify, for fixing input I had to emerge x11-drivers/xf86-input-libinput, earlier I just said just libinput which is inaccurate.
Comment 24 Matt Turner gentoo-dev 2018-03-11 22:40:59 UTC
So, I'm thinking this isn't ready for primetime.

Can someone patch their xorg-server with https://src.fedoraproject.org/rpms/xorg-x11-server/blob/master/f/0001-Fedora-hack-Make-the-suid-root-wrapper-always-start-.patch) and see if all their problems go away? Just put the patch in /etc/portage/patches/x11-base/xorg-server/
Comment 25 Amadeusz Sławiński 2018-03-11 23:25:52 UTC
Yes, the patch works, but it's effectively same as running suid root.

To run as user it needs to be allowed input access and only runs on current tty (-- vt1 etc.), can't be started on tty7.
Comment 26 Matt Turner gentoo-dev 2018-03-11 23:36:02 UTC
Also, is everyone who is dealing with this problem running without systemd?
Comment 27 gyroninja 2018-03-12 00:45:55 UTC
(In reply to Matt Turner from comment #26)
> Also, is everyone who is dealing with this problem running without systemd?
I'm not running systemd. My init system is "openrc (OpenRC) 0.35.2 (Gentoo Linux).
Comment 28 alex.aralis 2018-03-12 00:51:36 UTC
I am not using systemd and still am affected.
Comment 29 Andrey Grozin gentoo-dev 2018-03-12 19:28:30 UTC
(In reply to Matt Turner from comment #26)
> Also, is everyone who is dealing with this problem running without systemd?
I'm using openrc-0.35.2. And I start X by startx, not from a display manager.
Comment 30 Matt Turner gentoo-dev 2018-04-15 23:06:09 UTC
Please try 1.19.99.904.
Comment 31 Larry the Git Cow gentoo-dev 2018-04-15 23:07:17 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=39fdaceded21ebd4c6665ec6147ab65f263ac564

commit 39fdaceded21ebd4c6665ec6147ab65f263ac564
Author:     Matt Turner <mattst88@gentoo.org>
AuthorDate: 2018-04-15 22:56:14 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2018-04-15 22:56:14 +0000

    x11-base/xorg-server: Install setuid without systemd
    
    When using systemd, the Xserver does not need to run with root
    privileges. Without systemd... I'm not sure.
    
    Bug: https://bugs.gentoo.org/635102
    Bug: https://bugs.gentoo.org/635582

 x11-base/xorg-server/xorg-server-9999.ebuild | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)}
Comment 32 Alex Barker 2018-04-24 01:42:34 UTC
(In reply to Matt Turner from comment #30)
> Please try 1.19.99.904.

Tired, display messed up with crash (radeon).  Did not try 9999.
Comment 33 Matt Turner gentoo-dev 2018-05-07 01:41:14 UTC
I pushed 1.19.99.905 to the tree. Can any of the many people who commented while the the package.mask was not in place please test?
Comment 34 Tomáš Mózes 2018-05-24 12:56:59 UTC
(In reply to Matt Turner from comment #33)
> I pushed 1.19.99.905 to the tree. Can any of the many people who commented
> while the the package.mask was not in place please test?

I don't see that version any more, but it works properly with 1.19.5-r2.
Comment 35 Matt Turner gentoo-dev 2018-05-24 15:26:08 UTC
(In reply to Tomáš Mózes from comment #34)
> (In reply to Matt Turner from comment #33)
> > I pushed 1.19.99.905 to the tree. Can any of the many people who commented
> > while the the package.mask was not in place please test?
> 
> I don't see that version any more, but it works properly with 1.19.5-r2.

Please test 1.20.0 (1.19.99.905 was RC5 of 1.20.0)
Comment 36 Nick Wallingford 2018-05-25 05:59:54 UTC
xorg-server-1.20.0 works for me.
Comment 37 Tomáš Mózes 2018-05-25 06:41:25 UTC
(In reply to Matt Turner from comment #35)
> (In reply to Tomáš Mózes from comment #34)
> > (In reply to Matt Turner from comment #33)
> > > I pushed 1.19.99.905 to the tree. Can any of the many people who commented
> > > while the the package.mask was not in place please test?
> > 
> > I don't see that version any more, but it works properly with 1.19.5-r2.
> 
> Please test 1.20.0 (1.19.99.905 was RC5 of 1.20.0)

Yes, that one works too, thank you.
Comment 38 Matt Turner gentoo-dev 2018-06-08 05:11:20 UTC
Awesome. Thanks for testing!