-
Notifications
You must be signed in to change notification settings - Fork 970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't use ' dup2(0, 3)' unconditionally #1709
Comments
That code is absolutely ancient, so unfortunately you would have to ask RealVNC why it was written that way. But I agree, using Have you tried changing it and see if everything seems to work? |
Not yet. |
It might be, unfortunately. It shouldn't, of course, but it might. So testing will be needed. It does set |
... introduced when we migrated to the xorg-server 1.19.x code base in TurboVNC 2.2 (a661ed1). - Use dup() to obtain a free file descriptor for the inetd socket rather than statically assigning FD 3. Otherwise, if Xvnc calls a function (such as getpwuid()) that invokes libnss_sss prior to calling ddxProcessArgument(), then libnss_sss will obtain the first free file descriptor (3) for its own purposes, ddxProcessArgument() will clobber that file descriptor, and hilarity will ensue. TurboVNC doesn't currently make an early call to a function that invokes libnss_sss, but referring to TigerVNC/tigervnc#1709, TigerVNC does. It is possible that we will do so in the future. Based on: TigerVNC/tigervnc@7a9773a - Explicitly redirect stderr (FD 2) to /dev/null rather than simply closing it. Otherwise, OsInit() (more specifically ospoll_create()) will obtain the first free file descriptor (2) to use for polling, then it will check whether FD 2 (which it assumes is still stderr) is writable. Since polling file descriptors aren't writable, OsInit() will redirect FD 2 to /dev/null, thus breaking the polling subsystem. (Symptomatically, that caused the TurboVNC Server, when used with the -inetd option, to do nothing when a VNC viewer connected.) Based on: TigerVNC/tigervnc@712cf86 - Move the inetd RFB connection code from ProcessInputEvents() to the end of InitInput(), since ProcessInputEvents() isn't usually called until/unless a window manager is started. (Symptomatically, that also caused the TurboVNC Server, when used with the -inetd option, to do nothing when a VNC viewer connected.) Probably fixes #303
... introduced when we migrated to the xorg-server 1.19.x code base in TurboVNC 2.2 (a661ed1). - Use dup() to obtain a free file descriptor for the inetd socket rather than statically assigning FD 3. Otherwise, if Xvnc calls a function (such as getpwuid()) that invokes libnss_sss prior to calling ddxProcessArgument(), then libnss_sss will obtain the first free file descriptor (3) for its own purposes, ddxProcessArgument() will clobber that file descriptor, and hilarity will ensue. TurboVNC doesn't currently make an early call to a function that invokes libnss_sss, but referring to TigerVNC/tigervnc#1709, TigerVNC does. It is possible that we will do so in the future. Based on: TigerVNC/tigervnc@7a9773a - Explicitly redirect stderr (FD 2) to /dev/null rather than simply closing it. Otherwise, OsInit() (more specifically ospoll_create()) will obtain the first free file descriptor (2) to use for polling, then it will check whether FD 2 (which it assumes is still stderr) is writable. Since polling file descriptors aren't writable, OsInit() will redirect FD 2 to /dev/null, thus breaking the polling subsystem. (Symptomatically, that caused the TurboVNC Server, when used with the -inetd option, to do nothing when a VNC viewer connected.) Based on: TigerVNC/tigervnc@712cf86 - Move the inetd RFB connection code from ProcessInputEvents() to the end of InitInput(), since ProcessInputEvents() isn't usually called until/unless a window manager is started. (Symptomatically, that also caused the TurboVNC Server, when used with the -inetd option, to do nothing when a VNC viewer connected.) Probably fixes #303
When a system is configured to use 'libnss_sss.so.2' as NSS provider (i.e. /etc/nsswitch.conf contains "passwd: sss files ...") this code -
tigervnc/unix/xserver/hw/vnc/xvnc.c
Line 369 in effd854
- ruins internal state of 'libnss_sss.so.2'
The flow is as follows:
getpwuid(getuid))
but not necessarily);dup2(0, 3);
strace looks like:
And Xvnc log:
To Reproduce
Configure system:
and try to login: after successful authentication session terminates.
Client (please complete the following information):
Doesn't matter.
Server (please complete the following information):
Linux/TigerVNC (Xvnc)
What is the reason to use
dup2()
and assignvncInetdSock=3
unconditionally instead ofdup()
and obtain assigned fd usingF_GETFD
?Issue is worked around with the help of SSSD/sssd#7085 but I think this is a bug in TigerVNC
The text was updated successfully, but these errors were encountered: