(krb5_sock_to_principal): look in aliases for the real name

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8788 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2000-07-23 21:06:12 +00:00
parent 56a2b20c0d
commit 70777792f0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 1998, 1999 Kungliga Tekniska H<>gskolan
* Copyright (c) 1997 - 2000 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -50,6 +50,7 @@ krb5_sock_to_principal (krb5_context context,
struct hostent *hostent;
int family;
char hname[256];
char *tmp;
if (getsockname (sock, sa, &len) < 0)
return errno;
@@ -65,7 +66,18 @@ krb5_sock_to_principal (krb5_context context,
if (hostent == NULL)
return h_errno;
strlcpy(hname, hostent->h_name, sizeof(hname));
tmp = hostent->h_name;
if (strchr(tmp, '.') == NULL) {
char **a;
for (a = hostent->h_aliases; a != NULL && *a != NULL; ++a)
if (strchr(*a, '.') != NULL) {
tmp = *a;
break;
}
}
strlcpy(hname, tmp, sizeof(hname));
return krb5_sname_to_principal (context,
hname,
sname,