summaryrefslogtreecommitdiffstats
path: root/libexec/ftpd/logwtmp.c
diff options
context:
space:
mode:
authorshin <shin@FreeBSD.org>2000-01-27 09:28:38 +0000
committershin <shin@FreeBSD.org>2000-01-27 09:28:38 +0000
commitce15efb7c04858f00b57c16093d4a3043809048e (patch)
tree8b3d00f78a4a5a34cc3b17e29c28b4472d93a35c /libexec/ftpd/logwtmp.c
parentdcbae417f8f4365a5eea807290162acd308b720d (diff)
downloadFreeBSD-src-ce15efb7c04858f00b57c16093d4a3043809048e.zip
FreeBSD-src-ce15efb7c04858f00b57c16093d4a3043809048e.tar.gz
another tcp apps IPv6 updates.(should be make world safe)
ftp, telnet, ftpd, faithd also telnet related sync with crypto, secure, kerberosIV Obtained from: KAME project
Diffstat (limited to 'libexec/ftpd/logwtmp.c')
-rw-r--r--libexec/ftpd/logwtmp.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/libexec/ftpd/logwtmp.c b/libexec/ftpd/logwtmp.c
index d3f2ec5..2ac57d1 100644
--- a/libexec/ftpd/logwtmp.c
+++ b/libexec/ftpd/logwtmp.c
@@ -43,6 +43,7 @@ static const char rcsid[] =
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <sys/socket.h>
#include <fcntl.h>
#include <time.h>
@@ -68,15 +69,23 @@ ftpd_logwtmp(line, name, host)
struct stat buf;
if (strlen(host) > UT_HOSTSIZE) {
- struct hostent *hp = gethostbyname(host);
+ struct addrinfo hints, *res;
+ int error;
+ static char hostbuf[BUFSIZ];
- if (hp != NULL) {
- struct in_addr in;
-
- memmove(&in, hp->h_addr, sizeof(in));
- host = inet_ntoa(in);
- } else
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = PF_UNSPEC;
+ error = getaddrinfo(host, NULL, &hints, &res);
+ if (error)
host = "invalid hostname";
+ else {
+ getnameinfo(res->ai_addr, res->ai_addrlen,
+ hostbuf, sizeof(hostbuf), NULL, 0,
+ NI_NUMERICHOST);
+ host = hostbuf;
+ if (strlen(host) > UT_HOSTSIZE)
+ host[UT_HOSTSIZE] = '\0';
+ }
}
if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
OpenPOWER on IntegriCloud