summaryrefslogtreecommitdiffstats
path: root/libexec/telnetd/telnetd.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-04-06 00:29:41 +0000
committerbrian <brian@FreeBSD.org>1999-04-06 00:29:41 +0000
commit5aa9166dbaaf321f72899bccee8068258c7ff45c (patch)
treee7994516bc5308c46cb0297b9724c0525e41a296 /libexec/telnetd/telnetd.c
parentf882950e9c335f86dcdeb14c3764dba78d46bcc0 (diff)
downloadFreeBSD-src-5aa9166dbaaf321f72899bccee8068258c7ff45c.zip
FreeBSD-src-5aa9166dbaaf321f72899bccee8068258c7ff45c.tar.gz
After receiving a connection and doing a reverse
lookup on the incoming IP, do a forward lookup on the result and make sure that the IP is in the resulting list. If it's not, put the IP number in utmp/wtmp instead of the rogue name. Stolen from: rlogind Suggested by: sef
Diffstat (limited to 'libexec/telnetd/telnetd.c')
-rw-r--r--libexec/telnetd/telnetd.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c
index 37564e3..c825eab 100644
--- a/libexec/telnetd/telnetd.c
+++ b/libexec/telnetd/telnetd.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)telnetd.c 8.2 (Berkeley) 12/15/93";
#endif
static const char rcsid[] =
- "$Id: telnetd.c,v 1.14 1998/04/26 06:51:36 phk Exp $";
+ "$Id: telnetd.c,v 1.15 1998/12/16 06:04:29 peter Exp $";
#endif /* not lint */
#include "telnetd.h"
@@ -821,7 +821,23 @@ doit(who)
Please contact your net administrator");
} else if (hp &&
(strlen(hp->h_name) <= ((utmp_len < 0) ? -utmp_len : utmp_len))) {
- host = hp->h_name;
+ strncpy(remote_host_name, hp->h_name,
+ sizeof(remote_host_name)-1);
+ hp = gethostbyname(remote_host_name);
+ if (hp == NULL)
+ host = inet_ntoa(who->sin_addr);
+ else for (; ; hp->h_addr_list++) {
+ if (hp->h_addr_list[0] == NULL) {
+ /* End of list - ditch it */
+ host = inet_ntoa(who->sin_addr);
+ break;
+ }
+ if (!bcmp(hp->h_addr_list[0], (caddr_t)&who->sin_addr,
+ sizeof(who->sin_addr))) {
+ host = hp->h_name;
+ break; /* OK! */
+ }
+ }
} else {
host = inet_ntoa(who->sin_addr);
}
OpenPOWER on IntegriCloud