Skip to content

Commit

Permalink
Fix -inetd not working with xserver >= 1.19
Browse files Browse the repository at this point in the history
xserver 1.19's OsInit will create a pollfd, followed by checking if fd 2 /
stderr is writable and if it is not, replacing fd 2 with /dev/null.

Since we close stderr in inetd mode to avoid xserver messages being send
to the client as vnc data, the pollfd becomes fd 2, only to be replaced
by /dev/null since a pollfd is not writable.

This commit fixes this by opening /dev/null directly after the close(2),
avoiding that the pollfd becomes fd 2.

Alan Coopersmith: Change to use dup2() for atomic switch of fd

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
jwrdegoede authored and CendioOssman committed Jan 10, 2017
1 parent 4ece7c5 commit 712cf86
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion unix/xserver/hw/vnc/xvnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,17 @@ ddxProcessArgument(int argc, char *argv[], int i)

if (strcmp(argv[i], "-inetd") == 0)
{
int nullfd;

dup2(0,3);
vncInetdSock = 3;
close(2);

/* Avoid xserver >= 1.19's epoll-fd becoming fd 2 / stderr only to be
replaced by /dev/null by OsInit() because the pollfd is not
writable, breaking ospoll_wait(). */
nullfd = open("/dev/null", O_WRONLY);
dup2(nullfd, 2);
close(nullfd);

if (!displaySpecified) {
int port = vncGetSocketPort(vncInetdSock);
Expand Down

0 comments on commit 712cf86

Please sign in to comment.