summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-06-17 14:49:02 +0000
committerache <ache@FreeBSD.org>1996-06-17 14:49:02 +0000
commitaba2bff439b6d99def06b8e2338b3e0060281808 (patch)
tree18ff27c688aa2a77370986f783fd9116e0c261aa /lib
parent69a59390f6f5cb1fb7af353751e765e2db5a5cdf (diff)
downloadFreeBSD-src-aba2bff439b6d99def06b8e2338b3e0060281808.zip
FreeBSD-src-aba2bff439b6d99def06b8e2338b3e0060281808.tar.gz
If hostname > UT_HOSTSIZE, use its numeric address instead to keep
valid entries into utmp and wtmp
Diffstat (limited to 'lib')
-rw-r--r--lib/libutil/logwtmp.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/libutil/logwtmp.c b/lib/libutil/logwtmp.c
index f4a6408..a19e651 100644
--- a/lib/libutil/logwtmp.c
+++ b/lib/libutil/logwtmp.c
@@ -37,12 +37,16 @@ static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93";
#include <sys/types.h>
#include <sys/file.h>
-#include <sys/time.h>
#include <sys/stat.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <libutil.h>
+#include <netdb.h>
+#include <string.h>
+#include <time.h>
#include <unistd.h>
#include <utmp.h>
-#include <libutil.h>
void
logwtmp(line, name, host)
@@ -51,8 +55,18 @@ logwtmp(line, name, host)
struct utmp ut;
struct stat buf;
int fd;
- time_t time();
- char *strncpy();
+
+ 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 = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
return;
OpenPOWER on IntegriCloud