From ambrisko@whistle.com  Fri Jan  3 13:45:07 1997
Received: from whistle.com (s205m131.whistle.com [207.76.205.131])
          by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id NAA16202
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 3 Jan 1997 13:45:07 -0800 (PST)
Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id NAA23240 for <FreeBSD-gnats-submit@freebsd.org>; Fri, 3 Jan 1997 13:44:36 -0800 (PST)
Received: from crab.whistle.com(207.76.205.112) by whistle.com via smap (V1.3)
	id sma023236; Fri Jan  3 13:44:14 1997
Received: (from ambrisko@localhost) by crab.whistle.com (8.8.3/8.6.12) id NAA27357; Fri, 3 Jan 1997 13:43:13 -0800 (PST)
Message-Id: <199701032143.NAA27357@crab.whistle.com>
Date: Fri, 3 Jan 1997 13:43:13 -0800 (PST)
From: Doug Ambrisko <ambrisko@whistle.com>
Reply-To: ambrisko@whistle.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: libc ignores "domain" in /etc/services
X-Send-Pr-Version: 3.2

>Number:         2366
>Category:       bin
>Synopsis:       libc does not consult /etc/services to figure out the dns port
>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:   Fri Jan  3 13:50:01 PST 1997
>Closed-Date:    Sun Apr 26 12:43:04 PDT 1998
>Last-Modified:  Sun Apr 26 12:43:40 PDT 1998
>Originator:     Doug Ambrisko
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
Whistle.
>Environment:

	

>Description:

	

libc does not use getservbyname to figure out the dns port to connect to.
Instead it just uses a #defined number.  The attached change makes libc
look for "domain" in /etc/services and uses the defined port number if
getservbyname fails.

>How-To-Repeat:

	

>Fix:
	
	

--- lib/libc/net/res_init.c.orig        Fri Jan  3 13:32:27 1997
+++ lib/libc/net/res_init.c     Fri Jan  3 13:09:58 1997
@@ -74,6 +74,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#include <netdb.h>
 
 static void res_setoptions __P((char *, char *));
 
@@ -120,6 +121,7 @@
 	int nserv = 0;    /* number of nameserver records read from file */
 	int haveenv = 0;
 	int havesearch = 0;
+	struct servent *sp;
 #ifdef RESOLVSORT
 	int nsort = 0;
 	char *net;
@@ -167,7 +169,12 @@
 	_res.nsaddr.sin_addr.s_addr = INADDR_ANY;
 #endif
 	_res.nsaddr.sin_family = AF_INET;
-	_res.nsaddr.sin_port = htons(NAMESERVER_PORT);
+      	sp = getservbyname("domain", "tcp");
+	if (sp){ 
+	  _res.nsaddr.sin_port = sp->s_port;
+	}else{
+	  _res.nsaddr.sin_port = htons(NAMESERVER_PORT);
+	}
 	_res.nscount = 1;
 	_res.ndots = 1;
 	_res.pfcode = 0;
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: gpalmer 
Responsible-Changed-When: Fri Jan 3 15:54:45 PST 1997 
Responsible-Changed-Why:  
Misfiled PR 
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Sun Apr 26 12:43:04 PDT 1998 
State-Changed-Why:  
I don't, and pst don't think this is a good idea. 
>Unformatted:
Doug Ambrisko
