summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-06-17 14:59:07 +0000
committerache <ache@FreeBSD.org>1996-06-17 14:59:07 +0000
commit87e1afbd93806de284d32e8ad045257b64ab7349 (patch)
tree1c5ef356980a448d0e01ba62964b7945541d624d /libexec
parentaba2bff439b6d99def06b8e2338b3e0060281808 (diff)
downloadFreeBSD-src-87e1afbd93806de284d32e8ad045257b64ab7349.zip
FreeBSD-src-87e1afbd93806de284d32e8ad045257b64ab7349.tar.gz
If hostname > UT_HOSTSIZE, use its numerical address instead to keep
valid utmp and wtmp entries
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ftpd/logwtmp.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/libexec/ftpd/logwtmp.c b/libexec/ftpd/logwtmp.c
index d40840c..d08bdba 100644
--- a/libexec/ftpd/logwtmp.c
+++ b/libexec/ftpd/logwtmp.c
@@ -37,10 +37,13 @@ static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
#include <sys/types.h>
-#include <sys/time.h>
#include <sys/stat.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
#include <fcntl.h>
+#include <time.h>
+#include <netdb.h>
#include <utmp.h>
#include <unistd.h>
#include <stdio.h>
@@ -61,6 +64,18 @@ logwtmp(line, name, host)
struct utmp ut;
struct stat buf;
+ if (strlen(host) > UT_HOSTSIZE) {
+ struct hostent *hp = gethostbyname(host);
+
+ if (hp != NULL) {
+ struct in_addr in;
+
+ memmove(&in, hp->h_addr, sizeof(in));
+ host = inet_ntoa(in);
+ } else
+ host = "invalid hostname";
+ }
+
if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
return;
if (fstat(fd, &buf) == 0) {
OpenPOWER on IntegriCloud