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/tftpd/tftpd.c | |
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/tftpd/tftpd.c')
-rw-r--r-- | libexec/tftpd/tftpd.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index d0499c9..f1f8a9a 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)tftpd.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id: tftpd.c,v 1.11 1998/04/12 11:15:54 phk Exp $"; + "$Id: tftpd.c,v 1.12 1998/10/30 16:17:39 dg Exp $"; #endif /* not lint */ /* @@ -65,6 +65,7 @@ static const char rcsid[] = #include <ctype.h> #include <errno.h> #include <fcntl.h> +#include <libutil.h> #include <netdb.h> #include <pwd.h> #include <setjmp.h> @@ -108,7 +109,6 @@ static int logging; static char *errtomsg __P((int)); static void nak __P((int)); -static char *verifyhost __P((struct sockaddr_in *)); int main(argc, argv) @@ -325,8 +325,11 @@ again: } ecode = (*pf->f_validate)(&filename, tp->th_opcode); if (logging) { - syslog(LOG_INFO, "%s: %s request for %s: %s", - verifyhost(&from), + char host[MAXHOSTNAMELEN + 1]; + + realhostname(host, sizeof host - 1, &from.sin_addr); + host[sizeof host - 1] = '\0'; + syslog(LOG_INFO, "%s: %s request for %s: %s", host, tp->th_opcode == WRQ ? "write" : "read", filename, errtomsg(ecode)); } @@ -670,17 +673,3 @@ nak(error) if (send(peer, buf, length, 0) != length) syslog(LOG_ERR, "nak: %m"); } - -static char * -verifyhost(fromp) - struct sockaddr_in *fromp; -{ - struct hostent *hp; - - hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof (fromp->sin_addr), - fromp->sin_family); - if (hp) - return hp->h_name; - else - return inet_ntoa(fromp->sin_addr); -} |