PR/36468: Andreas Wrede: ftpd(8) always logs hostnames. Add -n option to display

addresses.
This commit is contained in:
christos 2007-06-10 20:24:31 +00:00
parent 07186f02e2
commit b7c1cbea43
2 changed files with 18 additions and 9 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ftpd.8,v 1.77 2007/05/10 05:59:30 lukem Exp $
.\" $NetBSD: ftpd.8,v 1.78 2007/06/10 20:24:31 christos Exp $
.\"
.\" Copyright (c) 1997-2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -63,7 +63,7 @@
.\"
.\" @(#)ftpd.8 8.2 (Berkeley) 4/19/94
.\"
.Dd August 4, 2005
.Dd June 10, 2007
.Dt FTPD 8
.Os
.Sh NAME
@ -72,7 +72,7 @@
Internet File Transfer Protocol server
.Sh SYNOPSIS
.Nm
.Op Fl 46DdHlQqrsUuWwX
.Op Fl 46DdHlnQqrsUuWwX
.Op Fl a Ar anondir
.Op Fl C Ar user
.Op Fl c Ar confdir
@ -194,6 +194,8 @@ session is logged using syslog with a facility of
If this option is specified more than once, the retrieve (get), store (put),
append, delete, make directory, remove directory and rename operations and
their file name arguments are also logged.
.It Fl n
Don't attempt translation of IP addresses to hostnames.
.It Fl P Ar dataport
Use
.Ar dataport

View File

@ -1,4 +1,4 @@
/* $NetBSD: ftpd.c,v 1.179 2007/01/20 17:26:32 christos Exp $ */
/* $NetBSD: ftpd.c,v 1.180 2007/06/10 20:24:31 christos Exp $ */
/*
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@ -105,7 +105,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: ftpd.c,v 1.179 2007/01/20 17:26:32 christos Exp $");
__RCSID("$NetBSD: ftpd.c,v 1.180 2007/06/10 20:24:31 christos Exp $");
#endif
#endif /* not lint */
@ -192,6 +192,7 @@ int doutmp; /* update utmp file */
int dowtmp; /* update wtmp file */
int doxferlog; /* syslog/write wu-ftpd style xferlog entries */
int xferlogfd; /* fd to write wu-ftpd xferlog entries to */
int getnameopts; /* flags for use with getname() */
int dropprivs; /* if privileges should or have been dropped */
int mapped; /* IPv4 connection on AF_INET6 socket */
off_t file_size;
@ -309,6 +310,7 @@ main(int argc, char *argv[])
dowtmp = 1; /* default: DO log to wtmp */
doxferlog = 0; /* default: Do NOT syslog xferlog */
xferlogfd = -1; /* default: Do NOT write xferlog file */
getnameopts = 0; /* default: xlate addrs to name */
dropprivs = 0;
mapped = 0;
usedefault = 1;
@ -326,7 +328,7 @@ main(int argc, char *argv[])
openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP);
while ((ch = getopt(argc, argv,
"46a:c:C:Dde:h:HlL:P:qQrst:T:uUvV:wWX")) != -1) {
"46a:c:C:Dde:h:HlL:nP:qQrst:T:uUvV:wWX")) != -1) {
switch (ch) {
case '4':
af = AF_INET;
@ -380,6 +382,10 @@ main(int argc, char *argv[])
xferlogname = optarg;
break;
case 'n':
getnameopts = NI_NUMERICHOST;
break;
case 'P':
errno = 0;
p = NULL;
@ -651,8 +657,8 @@ main(int argc, char *argv[])
/* if the hostname hasn't been given, attempt to determine it */
if (hostname[0] == '\0') {
if (getnameinfo((struct sockaddr *)&ctrl_addr.si_su,
ctrl_addr.su_len, hostname, sizeof(hostname), NULL, 0, 0)
!= 0)
ctrl_addr.su_len, hostname, sizeof(hostname), NULL, 0,
getnameopts) != 0)
(void)gethostname(hostname, sizeof(hostname));
hostname[sizeof(hostname) - 1] = '\0';
}
@ -2784,7 +2790,8 @@ logremotehost(struct sockinet *who)
{
if (getnameinfo((struct sockaddr *)&who->si_su,
who->su_len, remotehost, sizeof(remotehost), NULL, 0, 0))
who->su_len, remotehost, sizeof(remotehost), NULL, 0,
getnameopts))
strlcpy(remotehost, "?", sizeof(remotehost));
#if HAVE_SETPROCTITLE