From nobody  Fri Nov 14 20:24:42 1997
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.7/8.8.7) id UAA28485;
          Fri, 14 Nov 1997 20:24:42 -0800 (PST)
          (envelope-from nobody)
Message-Id: <199711150424.UAA28485@hub.freebsd.org>
Date: Fri, 14 Nov 1997 20:24:42 -0800 (PST)
From: pavlin@catarina.usc.edu
To: freebsd-gnats-submit@freebsd.org
Subject: ipfw(8) IP address resolving problem if only /etc/hosts used
X-Send-Pr-Version: www-1.0

>Number:         5047
>Category:       bin
>Synopsis:       ipfw(8) IP address resolving problem if only /etc/hosts used
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 14 20:30:00 PST 1997
>Closed-Date:    Fri Jun 4 04:22:19 PDT 1999
>Last-Modified:  Fri Jun  4 04:25:48 PDT 1999
>Originator:     Pavlin Ivanov Radoslavov
>Release:        2.2.1
>Organization:
University of Southern California, Dept. of CS
>Environment:
FreeBSD fbsd14.usc.edu 2.2.1-RELEASE FreeBSD 2.2.1-RELEASE #0: Mon Sep  1 23:11:02 PDT 1997     pim@fbsd14.usc.edu:/usr/home/local/pim/sys/compile/FBSD  i386

>Description:
If only /etc/hosts is used to resolve hosts names, ipfw does not accept
IP addresses, only hosts names.
>How-To-Repeat:
1. Recompile the kernel with IP firewall enabled
(options         IPFIREWALL) and reboot

2. Comment out "bind" and "nis", and uncomment "hosts" in /etc/host.conf

3. Execute the following three lines (from the console!):

/sbin/ipfw -f flush
/sbin/ipfw add 65000 pass all from any to any
/sbin/ipfw add 1000 pass all from 127.0.0.1 to 127.0.0.1




>Fix:
Apply the following patch to /usr/src/sbin/ipfw/ipfw.c

--- ipfw.c      Wed Mar  5 04:30:08 1997
+++ ipfw-new.c  Fri Nov 14 19:56:13 1997
@@ -386,8 +386,13 @@
 {
        struct hostent *he = gethostbyname(host);
 
-       if (!he)
-               return(-1);
+       if (!he) {
+               u_long host_addr;
+               host_addr = inet_addr(host);
+               he = gethostbyaddr((char *)&host_addr, sizeof(u_long), AF_INET);
+               if (!he) 
+                       return(-1);
+       }
 
        *ipaddr = *(struct in_addr *)he->h_addr_list[0];
 

>Release-Note:
>Audit-Trail:

From: Bill Fenner <fenner@parc.xerox.com>
To: freebsd-gnats-submit@freebsd.org
Cc:  Subject: Re: bin/5047: ipfw(8) IP address resolving problem if only /etc/hosts used
Date: Sat, 15 Nov 1997 14:22:58 PST

 Perhaps the real solution is to copy the code from gethostbydns.c which
 returns a fake hostent if the input looks like a parsable address into
 gethostbyname2(), so that gethostbyname()'s behavior is consistent no
 matter what the contents of /etc/host.conf .
 
   Bill
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Fri Jun 4 04:22:19 PDT 1999 
State-Changed-Why:  
Fixed in -current (ipfw.c,v 1.69) 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Fri Jun 4 04:22:19 PDT 1999 
Responsible-Changed-Why:  
So I remember to MFC. 
>Unformatted:
