From d2ff8ff6236b21bf3a967f6e4a9deeef48315adc Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sun, 19 Apr 1998 07:44:33 +0000 Subject: [PATCH] (connect_local_xsocket): update to try the list of potential socket pathnames git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4781 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/kx/common.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/appl/kx/common.c b/appl/kx/common.c index 8aa6ef70e..73b67f4e3 100644 --- a/appl/kx/common.c +++ b/appl/kx/common.c @@ -277,16 +277,19 @@ connect_local_xsocket (unsigned dnr) { int fd; struct sockaddr_un addr; + char **path; - fd = socket (AF_UNIX, SOCK_STREAM, 0); - if (fd < 0) - err (1, "socket AF_UNIX"); - addr.sun_family = AF_UNIX; - snprintf (addr.sun_path, sizeof(addr.sun_path), - X_UNIX_PATH "%u", dnr); - if (connect (fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) - err (1, "connect"); - return fd; + for (path = x_paths; *path; ++path) { + fd = socket (AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) + err (1, "socket AF_UNIX"); + memset (&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + snprintf (addr.sun_path, sizeof(addr.sun_path), *path, dnr); + if (connect (fd, (struct sockaddr *)&addr, sizeof(addr)) == 0) + return fd; + } + err (1, "connecting to local display %u", dnr); } int