use getnameinfo

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7500 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-12-04 18:10:28 +00:00
parent 21f1a32d5d
commit 4a9a216cef

View File

@@ -663,16 +663,11 @@ static void
doit(struct sockaddr *who, int who_len) doit(struct sockaddr *who, int who_len)
{ {
char *host = NULL; char *host = NULL;
struct hostent *hp = NULL;
int level; int level;
int ptynum; int ptynum;
char user_name[256]; char user_name[256];
int error; int error;
char host_addr[256]; char host_addr[256];
void *addr;
int addr_sz;
const char *tmp;
int af;
/* /*
* Find an available pty to use. * Find an available pty to use.
@@ -697,52 +692,18 @@ doit(struct sockaddr *who, int who_len)
} }
#endif /* _SC_CRAY_SECURE_SYS */ #endif /* _SC_CRAY_SECURE_SYS */
af = who->sa_family; error = getnameinfo (who, who_len, host_addr, sizeof(host_addr),
switch (af) { NULL, 0,
case AF_INET : { registerd_host_only ? NI_NAMEREQD : 0);
struct sockaddr_in *sin = (struct sockaddr_in *)who; if (error)
addr = &sin->sin_addr;
addr_sz = sizeof(sin->sin_addr);
break;
}
#ifdef HAVE_IPV6
case AF_INET6 : {
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)who;
addr = &sin6->sin6_addr;
addr_sz = sizeof(sin6->sin6_addr);
break;
}
#endif
default :
fatal (net, "Unknown address family\r\n");
break;
}
hp = getipnodebyaddr (addr, addr_sz, af, &error);
if (hp == NULL && registerd_host_only) {
fatal(net, "Couldn't resolve your address into a host name.\r\n\ fatal(net, "Couldn't resolve your address into a host name.\r\n\
Please contact your net administrator"); Please contact your net administrator");
} else if (hp != NULL) {
host = hp->h_name;
}
tmp = inet_ntop(af, addr, host_addr, sizeof(host_addr));
if (tmp == NULL)
strlcpy (host_addr, "unknown address", sizeof(host_addr));
if (host == NULL)
host = host_addr;
/* /*
* We must make a copy because Kerberos is probably going * We must make a copy because Kerberos is probably going
* to also do a gethost* and overwrite the static data... * to also do a gethost* and overwrite the static data...
*/ */
strlcpy(remote_host_name, host, sizeof(remote_host_name)); strlcpy(remote_host_name, host_addr, sizeof(remote_host_name));
if (hp != NULL)
freehostent (hp);
host = remote_host_name; host = remote_host_name;
/* XXX - should be k_gethostname? */ /* XXX - should be k_gethostname? */
@@ -763,8 +724,8 @@ Please contact your net administrator");
*/ */
if (strlen(remote_host_name) > abs(utmp_len)) if (strlen(remote_host_name) > abs(utmp_len))
strlcpy(remote_host_name, strlcpy(remote_host_name,
host_addr, host_addr,
sizeof(remote_host_name)); sizeof(remote_host_name));
#ifdef AUTHENTICATION #ifdef AUTHENTICATION
auth_encrypt_init(hostname, host, "TELNETD", 1); auth_encrypt_init(hostname, host, "TELNETD", 1);