From 4b54c211e5e86d6ed62386ad9b7d676808b55766 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 7 Nov 2022 14:21:28 -0800 Subject: Recognize raw IPv6 numeric address Originally fixed for Solaris in Oct. 2002 under Sun bug 4759889 "xhost does not accept raw IPv6 numeric address" Before this fix: % xhost +2001:DB8::11 xhost: unknown address family "2001" xhost: bad hostname "2001:DB8::11" After this fix: % xhost +2001:DB8::11 2001:DB8::11 being added to access control list Signed-off-by: Alan Coopersmith --- xhost.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/xhost.c b/xhost.c index 6398506..9b0a093 100644 --- a/xhost.c +++ b/xhost.c @@ -394,11 +394,21 @@ change_host(Display *dpy, char *name, Bool add) name += 3; } if (family == FamilyWild && (cp = strchr(lname, ':'))) { - *cp = '\0'; - fprintf (stderr, "%s: unknown address family \"%s\"\n", - ProgramName, lname); - free(lname); - return 0; +#ifdef IPv6 + /* + * Check to see if inet_pton() can grok it as an IPv6 address + */ + if (inet_pton(AF_INET6, lname, &addr6.s6_addr) == 1) { + family = FamilyInternet6; + } else +#endif + { + *cp = '\0'; + fprintf (stderr, "%s: unknown address family \"%s\"\n", + ProgramName, lname); + free(lname); + return 0; + } } free(lname); -- cgit v1.2.3