Bug 1177513 - Xorg without root rights breaks by streams redirection
Summary: Xorg without root rights breaks by streams redirection
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: xorg-x11-xinit
Version: 21
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: X/OpenGL Maintenance List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-28 11:40 UTC by Andrew
Modified: 2015-01-28 19:53 UTC (History)
3 users (show)

Fixed In Version: xorg-x11-xinit-1.3.4-3.fc21
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-01-28 19:53:09 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
[PATCH xinit] startx: Pass -keeptty when telling the server to start on the current tty (1.16 KB, patch)
2015-01-22 13:35 UTC, Hans de Goede
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1078902 0 unspecified CLOSED Xorg without root rights 2021-02-22 00:41:40 UTC

Description Andrew 2014-12-28 11:40:24 UTC
Tried to launch Xorg w/o root privileges as described here: https://bugzilla.redhat.com/show_bug.cgi?id=1078902#c5

Result: it's ok when launched as simple "startx" but fails with specific streams redirection.

More precisely, failing cases are:

1. startx < /dev/null
Error in xorg log:
> Fatal server error:
> [   101.797] (EE) xf86OpenConsole: Cannot open virtual console 2 (Permission denied)

2. startx &> /tmp/file
> Fatal server error:
> [   196.962] (EE) xf86OpenConsole: VT_ACTIVATE failed: Operation not permitted

3. startx 2> /tmp/file
Same error as for "&>"

Cases 2. and 3. corrupt VT—it's necessary to issue "reset" to fix it.

Working cases:

1. startx > /tmp/file

2. startx 2>&1 > /tmp/file
This last method is enough for my purposes.


kernel 3.17.7-300.fc21.x86_64
xorg-x11-server-common-1.16.2.901-1.fc21.x86_64
selinux: permissive

Some additional info starts from here:
https://bugzilla.redhat.com/show_bug.cgi?id=1078902#c9

Comment 1 Andrew 2015-01-08 20:08:17 UTC
Amendment: "startx 2>&1 > /tmp/file" is my fail. Sure it doesn't redirect stderr to file. When fixed ("startx > /tmp/file 2>&1") it has the same error as for another stderr redirections described.

Comment 2 Hans de Goede 2015-01-20 15:16:18 UTC
Hmm, so adding some logging:

[ 17404.898] (++) using VT number 2

[ 17404.898] (++) stat 0 result 0 S_ISCHR 0 major 0 minor 0
[ 17404.898] (++) stat 1 result 0 S_ISCHR 0 major 0 minor 0
[ 17404.898] (++) stat 2 result 0 S_ISCHR 1 major 4 minor 2
[ 17404.898] (--) controlling tty is VT number 2, auto-enabling KeepTty

and when redirecting stderr:

[ 17404.898] (++) using VT number 2

[ 17404.898] (++) stat 0 result 0 S_ISCHR 0 major 0 minor 0
[ 17404.898] (++) stat 1 result 0 S_ISCHR 0 major 0 minor 0
[ 17404.898] (++) stat 2 result 0 S_ISCHR 0 major 0 minor 0
[ 17404.898] (--) controlling tty is VT number 2, auto-enabling KeepTty

So it seems that xinit already detaches stdin and stdout from the terminal leaving only stderr, and if you then redirect stderr the "auto-enabling KeepTty" breaks.

This works however:

startx -- -keeptty 2> /dev/null

IOW explictly telling X to keeptty works, so we can fix this by patching startx to add -keeptty when it is adding a vt# argument matching the current tty (which it does when no -- vt# is specified).

Comment 3 Hans de Goede 2015-01-22 13:35:59 UTC
Created attachment 982820 [details]
[PATCH xinit] startx: Pass -keeptty when telling the server to start on the current tty

Comment 4 Fedora Update System 2015-01-22 21:08:59 UTC
xorg-x11-xinit-1.3.4-3.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/xorg-x11-xinit-1.3.4-3.fc21

Comment 5 Fedora Update System 2015-01-26 02:28:31 UTC
Package xorg-x11-xinit-1.3.4-3.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing xorg-x11-xinit-1.3.4-3.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-1067/xorg-x11-xinit-1.3.4-3.fc21
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2015-01-28 19:53:09 UTC
xorg-x11-xinit-1.3.4-3.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.