When xinit starts an X server that listens only on UNIX socket,

prefer DISPLAY=unix:0 rather than DISPLAY=:0.
This will prevent applications from ever falling back to TCP if the
UNIX socket connection fails (such as when the X server crashes).

joint work with tb@
cluebat and ok matthieu@
This commit is contained in:
dcoppa 2017-08-28 15:13:11 +00:00
parent e96db7b009
commit 7069c249d5

View File

@ -653,7 +653,14 @@ shutdown(void)
static void
set_environment(void)
{
if (setenv("DISPLAY", displayNum, TRUE) == -1)
char displayEnv[128];
int ret;
ret = snprintf(displayEnv, sizeof(displayEnv), "unix%s", displayNum);
if (ret < 0 || ret > sizeof(displayEnv))
Fatalx("unable to set DISPLAY");
if (setenv("DISPLAY", displayEnv, TRUE) == -1)
Fatal("unable to set DISPLAY");
}