diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-11-07 14:21:28 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-11-07 14:21:28 -0800 |
commit | 4b54c211e5e86d6ed62386ad9b7d676808b55766 (patch) | |
tree | b009ce3b1fb3a657ccfd5a498a5ab1f7c10e240a | |
parent | 1d7015ba70362b09ac6a001d77e693a03fa0375e (diff) |
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 <alan.coopersmith@oracle.com>
-rw-r--r-- | xhost.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -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); |