From andre.albsmeier@mchp.siemens.de  Wed Jan 24 07:20:20 2001
Return-Path: <andre.albsmeier@mchp.siemens.de>
Received: from goliath.siemens.de (goliath.siemens.de [194.138.37.131])
	by hub.freebsd.org (Postfix) with ESMTP id 48EDE37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Jan 2001 07:20:19 -0800 (PST)
Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14])
	by goliath.siemens.de (8.11.0/8.11.0) with ESMTP id f0OFKHC21903
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Jan 2001 16:20:18 +0100 (MET)
Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.42.7])
	by mail1.siemens.de (8.11.0/8.11.0) with ESMTP id f0OFKHG29410
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Jan 2001 16:20:17 +0100 (MET)
Received: (from localhost)
	by curry.mchp.siemens.de (8.11.1/8.11.1) id f0OFKH657787
	for FreeBSD-gnats-submit@freebsd.org; Wed, 24 Jan 2001 16:20:17 +0100 (CET)
Message-Id: <200101241520.f0OFKH826314@curry.mchp.siemens.de>
Date: Wed, 24 Jan 2001 16:20:17 +0100 (CET)
From: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] make inetd log hostnames when specifying -l twice
X-Send-Pr-Version: 3.2

>Number:         24610
>Category:       bin
>Synopsis:       [PATCH] make inetd log hostnames when specifying -l twice
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 24 07:30:01 PST 2001
>Closed-Date:    Tue May 8 01:31:37 PDT 2001
>Last-Modified:  Tue May 08 01:32:07 PDT 2001
>Originator:     Andre Albsmeier
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
>Environment:

All FreeBSD versions.

>Description:

When specifying -l inetd logs the IP address of succesful connections.
With this patch, the hostname is logged instead of the IP address
when -l is specified twice.

>How-To-Repeat:

run inetd -l and watch /var/log/messages while connecting to an
inetd service.

>Fix:

The patch implements the above suggestion in inetd.c and documents
it in inetd.8. The fact that a (possibly time consuming) DNS lookup
can be needed has been documented as well.

--- usr.sbin/inetd/inetd.c.ORI	Wed Jan 24 11:32:17 2001
+++ usr.sbin/inetd/inetd.c	Wed Jan 24 15:49:24 2001
@@ -310,7 +310,7 @@
 			options |= SO_DEBUG;
 			break;
 		case 'l':
-			log = 1;
+			log++;
 			break;
 		case 'R':
 			getvalue(optarg, &toomany,
@@ -566,7 +566,7 @@
 						  peer.sa_len,
 						  pname, sizeof(pname),
 						  NULL, 0, 
-						  NI_NUMERICHOST|
+						  (log > 1 ? 0 : NI_NUMERICHOST) |
 						  NI_WITHSCOPEID);
 				      pnm = pname;
 				    }
@@ -575,7 +575,7 @@
 						peer.sa_len,
 						pname, sizeof(pname),
 						NULL, 0, 
-						NI_NUMERICHOST|
+						(log > 1 ? 0 : NI_NUMERICHOST) |
 						NI_WITHSCOPEID);
 				    pnm = pname;
 			    }
--- usr.sbin/inetd/inetd.8.ORI	Wed Jan 24 15:49:53 2001
+++ usr.sbin/inetd/inetd.8	Wed Jan 24 15:54:29 2001
@@ -79,7 +79,9 @@
 .It Fl d
 Turn on debugging.
 .It Fl l
-Turn on logging of successful connections.
+Turn on logging of successful connections. If specified twice,
+the address is converted into a name which could result in a
+(possibly time consuming) DNS lookup.
 .It Fl w
 Turn on TCP Wrapping for external services.
 See the

>Release-Note:
>Audit-Trail:

From: David Malone <dwmalone@maths.tcd.ie>
To: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/24610: [PATCH] make inetd log hostnames when specifying -l twice
Date: Wed, 24 Jan 2001 19:11:43 +0000

 On Wed, Jan 24, 2001 at 04:20:17PM +0100, Andre Albsmeier wrote:
 
 > >Description:
 > 
 > When specifying -l inetd logs the IP address of succesful connections.
 > With this patch, the hostname is logged instead of the IP address
 > when -l is specified twice.
 
 I didn't want to do this because it means looking up a hostname in
 inetd before forking - this can block for some time, which would
 prevent inetd from starting any more services.
 
 You can already look up host names and log them by turning on
 wrappers with -Ww. If you don't want to do restrict the services
 available then you can do something like:
 
 ALL: UNKNOWN : severity local0.info : allow
 ALL: ALL : severity local0.info : allow
 
 The "UNKNOWN" should force tcpd to look up the host name - otherwise
 it won't bother.
 
 	David.
 

From: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
To: David Malone <dwmalone@maths.tcd.ie>
Cc: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>,
	FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/24610: [PATCH] make inetd log hostnames when specifying -l twice
Date: Wed, 24 Jan 2001 21:34:39 +0100

 On Wed, 24-Jan-2001 at 19:11:43 +0000, David Malone wrote:
 > On Wed, Jan 24, 2001 at 04:20:17PM +0100, Andre Albsmeier wrote:
 > 
 > > >Description:
 > > 
 > > When specifying -l inetd logs the IP address of succesful connections.
 > > With this patch, the hostname is logged instead of the IP address
 > > when -l is specified twice.
 > 
 > I didn't want to do this because it means looking up a hostname in
 > inetd before forking - this can block for some time, which would
 > prevent inetd from starting any more services.
 
 Sure, that's why I mentioned it in the man page (maybe this needs
 more clarification).
 
 However, on nets isolated behind firewalls where only certain
 hosts can connect to inetd at all and where fast DNS lookups
 are normal it might be quite useful. And the feature has to be
 turned on explicitely by specifying -l twice.
 
 > 
 > You can already look up host names and log them by turning on
 > wrappers with -Ww. If you don't want to do restrict the services
 > available then you can do something like:
 > 
 > ALL: UNKNOWN : severity local0.info : allow
 > ALL: ALL : severity local0.info : allow
 > 
 > The "UNKNOWN" should force tcpd to look up the host name - otherwise
 > it won't bother.
 > 
 > 	David.
 
State-Changed-From-To: open->feedback 
State-Changed-By: dwmalone 
State-Changed-When: Mon May 7 11:34:22 PDT 2001 
State-Changed-Why:  
I'd like to close this PR because the effect of the patch can 
be produced using hosts.allow. Does this sound OK Andre, or 
am I missing something? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=24610 
State-Changed-From-To: feedback->closed 
State-Changed-By: dwmalone 
State-Changed-When: Tue May 8 01:31:37 PDT 2001 
State-Changed-Why:  
hosts.allow seem to have what's needed here. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=24610 
>Unformatted:
