diff options
author | Brian Somers <brian@FreeBSD.org> | 1999-04-06 23:06:00 +0000 |
---|---|---|
committer | Brian Somers <brian@FreeBSD.org> | 1999-04-06 23:06:00 +0000 |
commit | 32af26a50132167c86aa90413bade77884184c9e (patch) | |
tree | 334abe3472979b7ccd4ff27f55f4041b862cf9e3 /libexec/tftpd | |
parent | 595f220e045c18ca1604d6bf293763b5e71f6c0b (diff) | |
download | src-32af26a50132167c86aa90413bade77884184c9e.tar.gz src-32af26a50132167c86aa90413bade77884184c9e.zip |
Use realhostname() rather than various combinations of
gethostbyaddr() & gethostbyname().
Remove brokeness in ftpd for hosts of MAXHOSTNAMELEN length.
Notes
Notes:
svn path=/head/; revision=45393
Diffstat (limited to 'libexec/tftpd')
-rw-r--r-- | libexec/tftpd/Makefile | 4 | ||||
-rw-r--r-- | libexec/tftpd/tftpd.c | 25 |
2 files changed, 10 insertions, 19 deletions
diff --git a/libexec/tftpd/Makefile b/libexec/tftpd/Makefile index b7c600c41955..301a0d736ae6 100644 --- a/libexec/tftpd/Makefile +++ b/libexec/tftpd/Makefile @@ -1,8 +1,10 @@ # @(#)Makefile 8.1 (Berkeley) 6/4/93 -# $Id$ +# $Id: Makefile,v 1.5 1997/02/22 14:22:35 peter Exp $ PROG= tftpd SRCS= tftpd.c tftpsubs.c +DPADD= ${LIBUTIL} +LDADD= -lutil MAN8= tftpd.8 CFLAGS+=-I${.CURDIR}/../../usr.bin/tftp .PATH: ${.CURDIR}/../../usr.bin/tftp diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index d0499c9b19ce..f1f8a9a78098 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); -} |