Date: Mon, 22 Apr 2002 18:52:13 +0400 (MSD) From: Dmitry Morozovsky <marck@rinet.ru> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/37343: portmap TCP binds strangeness Message-ID: <200204221452.g3MEqDw40708@woozle.rinet.ru>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204221452.g3MEqDw40708>