Subject: gethostbyname() problem in rshd
Index:	etc/rshd/rshd.c 2.11BSD,4.3BSD

Description:
	rshd can generate superfluous DNS queries.  If the network interface
	to the outside world is down or experiencing congestion then 'rshd'
	can take a long time to complete a function between two hosts for
	which information is available locally.

	The problem is that the call to gethostbyaddr() just a few lines
	earlier in the code returns a FQDN (Fully Qualified Domain Name)
	to which domain searching (RES_DNSRCH is frequently on by default)
	is then applied by the gethostbyname() routine.  This results in 
	queries for bogus hostnames until the domain search list is exhausted 
	and a query for the original name (in the local domain) is finally made.

Repeat-By:
	Probably the easiest way to see this is to turn on the debugging
	in the name servor with a SIGUSR1 and watch /usr/tmp/named.run.

	Alternatively, use 'nslookup' with RES_DEBUG turned on.

	Of course, a network failure to the outside world while trying to 
	use 'rsh' will show the problem too.

Fix:
	This is the same fix posted a couple years or so ago for 'rlogind'.
	4.3BSD and 2.11BSD rshd.c sources are identical, the same fix applies
	to both.  4.3Reno line numbers will differ but the same problem exists
	there also.
---------------------------------cut here----------------------------------
*** rshd.c.old	Tue Sep 19 18:33:06 1989
--- rshd.c	Thu May 14 15:43:56 1992
***************
*** 49,54 ****
--- 49,56 ----
  #include <pwd.h>
  #include <netdb.h>
  #include <syslog.h>
+ #include <arpa/nameser.h>
+ #include <resolv.h>
  #include "pathnames.h"
  
  int	errno;
***************
*** 236,241 ****
--- 238,246 ----
  		if (check_all || local_domain(hp->h_name)) {
  			strncpy(remotehost, hp->h_name, sizeof(remotehost) - 1);
  			remotehost[sizeof(remotehost) - 1] = 0;
+ #ifdef	RES_DNSRCH
+ 			_res.options &= ~RES_DNSRCH;
+ #endif
  			hp = gethostbyname(remotehost);
  			if (hp == NULL) {
  				syslog(LOG_INFO,
