From owner-freebsd-bugs Fri Aug 31 6:20:10 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id EF77A37B408 for ; Fri, 31 Aug 2001 06:20:00 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f7VDK0I90954; Fri, 31 Aug 2001 06:20:00 -0700 (PDT) (envelope-from gnats) Received: from shaft.techsupport.co.uk (shaft.techsupport.co.uk [212.250.77.214]) by hub.freebsd.org (Postfix) with ESMTP id 7B59F37B403 for ; Fri, 31 Aug 2001 06:14:04 -0700 (PDT) Received: from rasputin by shaft.techsupport.co.uk with local (Exim 3.22 #1) id 15ckp2-0001vs-00 for FreeBSD-gnats-submit@freebsd.org; Fri, 31 Aug 2001 10:42:44 +0100 Message-Id: Date: Fri, 31 Aug 2001 10:42:44 +0100 From: Rasputin Reply-To: Rasputin To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/30235: /usr/sbin/portmap cannot listen to localhost UDP only (patch) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 30235 >Category: bin >Synopsis: /usr/sbin/portmap cannot listen to localhost UDP only (patch) >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Aug 31 06:20:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Rasputin >Release: FreeBSD 4.4-PRERELEASE i386 >Organization: SubMonkey.net >Environment: System: FreeBSD shaft.techsupport.co.uk 4.4-PRERELEASE FreeBSD 4.4-PRERELEASE #2: Wed Aug 8 17:59:16 BST 2001 setantae@shaft.techsupport.co.uk:/usr/obj/usr/src/sys/SHAFT i386 >Description: portmap(8) states that the -h commandline flag specifies specific IP addresses to listen on for UDP. It also states that 127.0.0.1 is added to the list automatically. This causes portmap to attmept to bind twice to 127.0.0.1 if given '-h 127.0.0.1', preventing it from starting. Without this flag, there is no way to bind only to localhost (omitting -h causes portmap to bind to INADDR_ANY). The folllowing patch brings portmap into line with its manpage (i.e the behaviour of tcp ports has not been changed) >How-To-Repeat: portmap -h 127.0.0.1 >Fix: --- portmap.c.orig Tue Apr 10 00:35:19 2001 +++ portmap.c Thu Aug 30 13:51:06 2001 @@ -159,12 +159,26 @@ * If no hosts were specified, just bind to INADDR_ANY. Otherwise * make sure 127.0.0.1 is added to the list. */ - ++nhosts; - hosts = realloc(hosts, nhosts * sizeof(char *)); - if (nhosts == 1) + if (nhosts == 0){ + ++nhosts; + hosts = realloc(hosts, nhosts * sizeof(char *)); hosts[0] = "0.0.0.0"; - else - hosts[nhosts - 1] = "127.0.0.1"; + } + else { + /* add localhost if not already there */ + + int n, lh_requested = 0; + + for(n=0;nRelease-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message