From owner-freebsd-bugs@FreeBSD.ORG Thu Apr 17 12:40:01 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3F2AA4D1 for ; Thu, 17 Apr 2014 12:40:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1BB92169D for ; Thu, 17 Apr 2014 12:40:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s3HCe0A6048790 for ; Thu, 17 Apr 2014 12:40:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s3HCe0WP048789; Thu, 17 Apr 2014 12:40:00 GMT (envelope-from gnats) Resent-Date: Thu, 17 Apr 2014 12:40:00 GMT Resent-Message-Id: <201404171240.s3HCe0WP048789@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Zombie Man Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BC7B0EC for ; Thu, 17 Apr 2014 12:30:14 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A967E1580 for ; Thu, 17 Apr 2014 12:30:14 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s3HCUDQm095604 for ; Thu, 17 Apr 2014 12:30:13 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s3HCU4Sm089340; Thu, 17 Apr 2014 12:30:04 GMT (envelope-from nobody) Message-Id: <201404171230.s3HCU4Sm089340@cgiserv.freebsd.org> Date: Thu, 17 Apr 2014 12:30:04 GMT From: Zombie Man To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: bin/188726: Add "NoReverseDNS" feature X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Apr 2014 12:40:01 -0000 >Number: 188726 >Category: bin >Synopsis: Add "NoReverseDNS" feature >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Apr 17 12:40:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Zombie Man >Release: FreeBSD 9.1-RELEASE >Organization: >Environment: >Description: For some reason (for exammple, in home networks), DNS is not available or improperly configured this can result in ftpd blocking ("stalling") until the libc resolver code times out. Using NoReverseDNS (-N command line option) will solve this problem. >How-To-Repeat: >Fix: patch file attached Patch attached with submission follows: Index: extern.h =================================================================== --- extern.h (revision 264526) +++ extern.h (working copy) @@ -97,6 +97,7 @@ extern int type; extern char *typenames[]; /* defined in included from ftpd.c */ extern int usedefault; +extern int NoReverseDNS; struct sockaddr_in; struct sockaddr_in6; Index: ftpd.8 =================================================================== --- ftpd.8 (revision 264526) +++ ftpd.8 (working copy) @@ -36,7 +36,7 @@ .Nd Internet File Transfer Protocol server .Sh SYNOPSIS .Nm -.Op Fl 468ADdEhMmOoRrSUvW +.Op Fl 468ADdEhMmNOoRrSUvW .Op Fl l Op Fl l .Op Fl a Ar address .Op Fl P Ar port @@ -133,6 +133,9 @@ existing files if allowed by file system permissions. By default, anonymous users cannot modify existing files; in particular, files to upload will be created under a unique name. +.It Fl N +Disable reverse DNS lookup for clients (useful for home LAN's without DNS). +All client addresses logged in dotted form. .It Fl O Put server in write-only mode for anonymous users only. RETR is disabled for anonymous users, preventing anonymous downloads. Index: ftpd.c =================================================================== --- ftpd.c (revision 264526) +++ ftpd.c (working copy) @@ -140,6 +140,7 @@ int noguestretr = 0; /* RETR command is disabled for anon users. */ int noguestmkd = 0; /* MKD command is disabled for anon users. */ int noguestmod = 1; /* anon users may not modify existing files. */ +int NoReverseDNS; /* 0 = do reverse DNS lookup for clients */ off_t file_size; off_t byte_count; @@ -301,7 +302,7 @@ openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); while ((ch = getopt(argc, argv, - "468a:AdDEhlmMoOp:P:rRSt:T:u:UvW")) != -1) { + "468a:AdDEhlmMNoOp:P:rRSt:T:u:UvW")) != -1) { switch (ch) { case '4': family = (family == AF_INET6) ? AF_UNSPEC : AF_INET; @@ -351,6 +352,10 @@ noguestmkd = 1; break; + case 'N': + NoReverseDNS = 1; + break; + case 'o': noretr = 1; break; @@ -2715,11 +2720,16 @@ { char who_name[NI_MAXHOST]; - realhostname_sa(remotehost, sizeof(remotehost) - 1, who, who->sa_len); - remotehost[sizeof(remotehost) - 1] = 0; - if (getnameinfo(who, who->sa_len, - who_name, sizeof(who_name) - 1, NULL, 0, NI_NUMERICHOST)) - *who_name = 0; + if (NoReverseDNS) { + if (getnameinfo(who, who->sa_len, remotehost, sizeof(remotehost)-1, NULL, 0, NI_NUMERICHOST)) + *remotehost = 0; + } + else + realhostname_sa(remotehost, sizeof(remotehost)-1, who, who->sa_len); + remotehost[sizeof(remotehost)-1] = 0; + + if (getnameinfo(who, who->sa_len, who_name, sizeof(who_name)-1, NULL, 0, NI_NUMERICHOST)) + *who_name = 0; who_name[sizeof(who_name) - 1] = 0; #ifdef SETPROCTITLE Index: logwtmp.c =================================================================== --- logwtmp.c (revision 264526) +++ logwtmp.c (working copy) @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -60,9 +61,12 @@ /* Log in. */ ut.ut_type = USER_PROCESS; (void)strncpy(ut.ut_user, user, sizeof(ut.ut_user)); - if (addr != NULL) - realhostname_sa(ut.ut_host, sizeof(ut.ut_host), - addr, addr->sa_len); + if (addr != NULL) { + if (NoReverseDNS) + getnameinfo(addr, addr->sa_len, ut.ut_host, sizeof(ut.ut_host)-1, NULL, 0, NI_NUMERICHOST); + else + realhostname_sa(ut.ut_host, sizeof(ut.ut_host), addr, addr->sa_len); + } } else { /* Log out. */ ut.ut_type = DEAD_PROCESS; >Release-Note: >Audit-Trail: >Unformatted: