Index: libexec/ftpd/extern.h =================================================================== RCS file: /home/ncvs/src/libexec/ftpd/extern.h,v retrieving revision 1.16 diff -u -r1.16 extern.h --- libexec/ftpd/extern.h 9 Jul 2001 17:46:24 -0000 1.16 +++ libexec/ftpd/extern.h 28 Jan 2002 14:27:44 -0000 @@ -34,13 +34,16 @@ * $FreeBSD: src/libexec/ftpd/extern.h,v 1.16 2001/07/09 17:46:24 markm Exp $ */ +#include +#include + void blkfree __P((char **)); char **copyblk __P((char **)); void cwd __P((char *)); void delete __P((char *)); void dologout __P((int)); void fatalerror __P((char *)); -void ftpd_logwtmp __P((char *, char *, char *)); +void ftpd_logwtmp __P((char *, char *, struct sockaddr *addr)); int ftpd_pclose __P((FILE *)); FILE *ftpd_popen __P((char *, char *)); char *getline __P((char *, int, FILE *)); Index: libexec/ftpd/ftpd.c =================================================================== RCS file: /home/ncvs/src/libexec/ftpd/ftpd.c,v retrieving revision 1.94 diff -u -r1.94 ftpd.c --- libexec/ftpd/ftpd.c 21 Jan 2002 19:07:15 -0000 1.94 +++ libexec/ftpd/ftpd.c 28 Jan 2002 14:27:45 -0000 @@ -1057,7 +1057,7 @@ (void) seteuid((uid_t)0); if (logged_in) - ftpd_logwtmp(ttyline, "", ""); + ftpd_logwtmp(ttyline, "", NULL); pw = NULL; #ifdef LOGIN_CAP setusercontext(NULL, getpwuid(0), (uid_t)0, @@ -1339,7 +1339,7 @@ #endif /* open wtmp before chroot */ - ftpd_logwtmp(ttyline, pw->pw_name, remotehost); + ftpd_logwtmp(ttyline, pw->pw_name, (struct sockaddr *)&his_addr); logged_in = 1; if (guest && stats && statfd < 0) @@ -2377,7 +2377,7 @@ if (logged_in) { (void) seteuid((uid_t)0); - ftpd_logwtmp(ttyline, "", ""); + ftpd_logwtmp(ttyline, "", NULL); } /* beware of flushing buffers after a SIGPIPE */ _exit(status); Index: libexec/ftpd/logwtmp.c =================================================================== RCS file: /home/ncvs/src/libexec/ftpd/logwtmp.c,v retrieving revision 1.9 diff -u -r1.9 logwtmp.c --- libexec/ftpd/logwtmp.c 27 Jan 2000 09:28:21 -0000 1.9 +++ libexec/ftpd/logwtmp.c 28 Jan 2002 14:27:45 -0000 @@ -52,6 +52,7 @@ #include #include #include +#include #include "extern.h" static int fd = -1; @@ -62,31 +63,18 @@ * after login, but before logout). */ void -ftpd_logwtmp(line, name, host) - char *line, *name, *host; +ftpd_logwtmp(line, name, addr) + char *line, *name; + struct sockaddr *addr; { struct utmp ut; struct stat buf; + char host[UT_HOSTSIZE]; - if (strlen(host) > UT_HOSTSIZE) { - struct addrinfo hints, *res; - int error; - static char hostbuf[BUFSIZ]; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - error = getaddrinfo(host, NULL, &hints, &res); - if (error) - host = "invalid hostname"; - else { - getnameinfo(res->ai_addr, res->ai_addrlen, - hostbuf, sizeof(hostbuf), NULL, 0, - NI_NUMERICHOST); - host = hostbuf; - if (strlen(host) > UT_HOSTSIZE) - host[UT_HOSTSIZE] = '\0'; - } - } + if (addr == NULL) + host[0] = '\0'; + else + realhostname_sa(host, sizeof(host), addr, addr->sa_len); if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) return;