diff options
author | brian <brian@FreeBSD.org> | 1999-04-06 23:06:00 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-04-06 23:06:00 +0000 |
commit | a77173a7cd162a0aa47a96361a70cd43d178b4f6 (patch) | |
tree | 745fbd61bf8b21361a25b2cd0184e45153a0211c /libexec/fingerd | |
parent | cf0ba219f719b19bf1fc5862d698b2713d849705 (diff) | |
download | FreeBSD-src-a77173a7cd162a0aa47a96361a70cd43d178b4f6.zip FreeBSD-src-a77173a7cd162a0aa47a96361a70cd43d178b4f6.tar.gz |
Use realhostname() rather than various combinations of
gethostbyaddr() & gethostbyname().
Remove brokeness in ftpd for hosts of MAXHOSTNAMELEN length.
Diffstat (limited to 'libexec/fingerd')
-rw-r--r-- | libexec/fingerd/fingerd.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/libexec/fingerd/fingerd.c b/libexec/fingerd/fingerd.c index 5626a21..088077c 100644 --- a/libexec/fingerd/fingerd.c +++ b/libexec/fingerd/fingerd.c @@ -42,10 +42,10 @@ static const char copyright[] = static char sccsid[] = "@(#)fingerd.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id: fingerd.c,v 1.10 1997/11/20 07:26:04 charnier Exp $"; + "$Id: fingerd.c,v 1.11 1998/05/15 03:23:28 jb Exp $"; #endif /* not lint */ -#include <sys/types.h> +#include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> @@ -70,11 +70,11 @@ main(argc, argv) register FILE *fp; register int ch; register char *lp; - struct hostent *hp; struct sockaddr_in sin; int p[2], logging, secure, sval; #define ENTRIES 50 char **ap, *av[ENTRIES + 1], **comp, line[1024], *prog; + char rhost[MAXHOSTNAMELEN + 1]; prog = _PATH_FINGER; logging = secure = 0; @@ -130,12 +130,8 @@ main(argc, argv) sval = sizeof(sin); if (getpeername(0, (struct sockaddr *)&sin, &sval) < 0) logerr("getpeername: %s", strerror(errno)); - if (hp = gethostbyaddr((char *)&sin.sin_addr.s_addr, - sizeof(sin.sin_addr.s_addr), AF_INET)) - lp = hp->h_name; - else - lp = inet_ntoa(sin.sin_addr); - syslog(LOG_NOTICE, "query from %s: `%s'", lp, t); + realhostname(rhost, sizeof rhost - 1, &sin.sin_addr); + syslog(LOG_NOTICE, "query from %s: `%s'", rhost, t); } comp = &av[1]; |