try hostname uncanonified if getaddrinfo() fails

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8194 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2000-04-19 14:19:38 +00:00
parent cb35b03467
commit 499c5a0751

View File

@@ -555,12 +555,13 @@ fail:
/*
* Return 0 iff `cookie' is compatible with the cookie for the
* localhost with name given in `disp_he' and display number in
* `disp_nr'.
* localhost with name given in `ai' (or `hostname') and display
* number in `disp_nr'.
*/
static int
match_local_auth (Xauth* auth, struct addrinfo *ai, int disp_nr)
match_local_auth (Xauth* auth,
struct addrinfo *ai, const char *hostname, int disp_nr)
{
int auth_disp;
char *tmp_disp;
@@ -582,6 +583,11 @@ match_local_auth (Xauth* auth, struct addrinfo *ai, int disp_nr)
auth->address_length) == 0)
return 0;
}
if (hostname != NULL
&& (auth->family == FamilyLocal
|| auth->family == FamilyWild)
&& strncmp (auth->address, hostname, auth->address_length) == 0)
return 0;
return 1;
}
@@ -622,17 +628,17 @@ find_auth_cookie (FILE *f)
hints.ai_protocol = IPPROTO_TCP;
error = getaddrinfo (display, NULL, &hints, &ai);
if (error) {
warnx ("getaddrinfo %s: %s", display, gai_strerror(error));
return NULL;
}
if (error)
ai = NULL;
for (; (ret = XauReadAuth (f)) != NULL; XauDisposeAuth(ret)) {
if (match_local_auth (ret, ai, disp) == 0) {
if (match_local_auth (ret, ai, display, disp) == 0) {
if (ai != NULL)
freeaddrinfo (ai);
return ret;
}
}
if (ai != NULL)
freeaddrinfo (ai);
return NULL;
}