From owner-freebsd-bugs Mon Apr 22 9: 2:14 2002 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 CF49337B422 for ; Mon, 22 Apr 2002 09:02:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3MFo2R61350; Mon, 22 Apr 2002 08:50:02 -0700 (PDT) (envelope-from gnats) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) by hub.freebsd.org (Postfix) with ESMTP id DA19637B405 for ; Mon, 22 Apr 2002 08:43:55 -0700 (PDT) Received: (from marck@localhost) by woozle.rinet.ru (8.11.6/8.11.6) id g3MEqDw40708; Mon, 22 Apr 2002 18:52:13 +0400 (MSD) (envelope-from marck) Message-Id: <200204221452.g3MEqDw40708@woozle.rinet.ru> Date: Mon, 22 Apr 2002 18:52:13 +0400 (MSD) From: Dmitry Morozovsky Reply-To: Dmitry Morozovsky To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/37343: portmap TCP binds strangeness 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: 37343 >Category: bin >Synopsis: portmap TCP binds strangeness >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 22 08:50:02 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Dmitry Morozovsky >Release: FreeBSD 4-STABLE i386 >Organization: Cronyx Plus LLC (RiNet ISP) >Environment: System: FreeBSD 4-STABLE >Description: when portmap(8) running with -h option, it binds to TCP socket with INADDR_ANY address, which seems incorrect. however, direct hack to bind to tcp sockets in for loop as UDP binds do does not work (possibly because of looking to only the last socket bound, but I did not dig into this issue deeply) In vast majority cases, there is only one -h option, so TCP bind may be restricted to this address. >How-To-Repeat: portmap -h a.b.c.d netstat -an | grep 111 >Fix: Really dirty hack. Index: portmap.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/portmap/Attic/portmap.c,v retrieving revision 1.10.2.2 diff -u -r1.10.2.2 portmap.c --- portmap.c 2002/02/21 11:27:30 1.10.2.2 +++ portmap.c 2002/04/22 14:51:20 @@ -119,6 +119,7 @@ int sock, c; char **hosts = NULL; int nhosts = 0; + int nhosts2 = 0; struct sockaddr_in addr; int len = sizeof(struct sockaddr_in); register struct pmaplist *pml; @@ -166,6 +167,7 @@ else hosts[nhosts - 1] = "127.0.0.1"; + nhosts2 = nhosts; /* * Add UDP socket(s) - bind to specific IPs if asked to */ @@ -202,8 +204,15 @@ /* * Add TCP socket + * XXX dirty hack: bind only to the first address if -h is specified */ addr.sin_addr.s_addr = 0; + if (nhosts2 > 1) { + if (inet_aton(hosts[0], &addr.sin_addr) < 0) { + syslog(LOG_ERR, "bad IP address: %s", hosts[nhosts]); + exit(1); + } + } if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { syslog(LOG_ERR, "cannot create tcp socket: %m"); exit(1); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message