diff options
author | Ray Strode <rstrode@redhat.com> | 2022-05-06 14:23:59 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2022-05-10 09:31:34 -0400 |
commit | 7898badde44cf518da6879c2622b6db9cd709c7d (patch) | |
tree | 556c25344328b2310ee273e53c242da017ce80e4 | |
parent | 3b5df889f58a99980a35a7b4a18eb4e7d2abeac4 (diff) |
Automatically disable inet6 transport if ipv6 is disabled on machine
If a machine is booted with ipv6.disable=1, trying to bind to an
AF_INET6 socket will fail with AFNOSUPPORT.
The tcp transport automatically falls back to ipv4 in this case, but
the more specific inet6 transport just fails.
This failure leads to MakeAllCOTSServerListeners returning a partial
success.
Unfortunately, the X server can't really contiue with partial successes
from this function if -displayfd is in use, since that would, in other
cases, potentially lead to the -displayfd electing a display number that
is potentially partially in use by a rogue program.
This commit addresses the issue by automatically disabling transports
when they fail with AFNOSUPPORT, leading them to get ignored, rather than
proceeding and ultimately returning from MakeAllCOTSServerListerns with
partial=TRUE.
-rw-r--r-- | Xtranssock.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Xtranssock.c b/Xtranssock.c index 632c1b5..0177186 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -611,12 +611,19 @@ TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, const char *protocol, break; } if (i < 0) { - if (i == -1) - prmsg (1,"SocketOpenCOTSServer: Unable to open socket for %s\n", - thistrans->TransName); - else + if (i == -1) { + if (errno == EAFNOSUPPORT) { + thistrans->flags |= TRANS_NOLISTEN; + prmsg (1,"SocketOpenCOTSServer: Socket for %s unsupported on this system.\n", + thistrans->TransName); + } else { + prmsg (1,"SocketOpenCOTSServer: Unable to open socket for %s\n", + thistrans->TransName); + } + } else { prmsg (1,"SocketOpenCOTSServer: Unable to determine socket type for %s\n", thistrans->TransName); + } return NULL; } |