diff options
author | Jeremy Huddleston Sequoia <jeremyhu@apple.com> | 2014-12-31 02:42:17 -0800 |
---|---|---|
committer | Jeremy Huddleston Sequoia <jeremyhu@apple.com> | 2014-12-31 02:45:45 -0800 |
commit | f990dd936b5fd1a40290bb88cde517a0ac38f823 (patch) | |
tree | 3fe687e231081e31a065d4eed35383e81c617e69 /parsedpy.c | |
parent | 047f92a85796fca563d9345d6c4798b64be77cff (diff) | |
download | xorg-app-xauth-f990dd936b5fd1a40290bb88cde517a0ac38f823.tar.gz |
Update DISPLAY parsing to work with new launchd paths in Yosemite
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Diffstat (limited to 'parsedpy.c')
-rw-r--r-- | parsedpy.c | 31 |
1 files changed, 29 insertions, 2 deletions
@@ -42,6 +42,9 @@ in this Software without prior written authorization from The Open Group. #include <X11/Xauth.h> /* for FamilyLocal */ #include <X11/Xmu/SysUtil.h> +#include <sys/stat.h> +#include <sys/syslimits.h> + #if defined(UNIXCONN) || defined(LOCALCONN) #define UNIX_CONNECTION "unix" #define UNIX_CONNECTION_LENGTH 4 @@ -158,8 +161,32 @@ parse_displayname (const char *displayname, if (!host) return False; - if(strncmp (host, "/tmp/launch", 11) == 0) { - family = FamilyLocal; + { + /* + * If using launchd socket, remove the screen number from the end + * of $DISPLAY and check if it is a path to a socket. + */ + char path[PATH_MAX]; + struct stat sbuf; + +#ifdef HAVE_STRLCPY + strlcpy(path, displayname, sizeof(path)); +#else + strncpy(path, displayname, sizeof(path)); + buf[sizeof(path) - 1] = '\0'; +#endif + if (0 == stat(path, &sbuf)) { + family = FamilyLocal; + } else { + char *dot = strrchr(path, '.'); + if (dot) { + *dot = '\0'; + /* screen = atoi(dot + 1); */ + if (0 == stat(path, &sbuf)) { + family = FamilyLocal; + } + } + } } /* |