strange nfs/yp/filec bug (patch included)

Craig Leres leres at helios.ee.lbl.gov
Tue Feb 28 15:03:23 AEST 1989


The csh file completion problem Tom Gorodecki mentions was recently
discussed by Alexander Dupuy. The problem is that the yp code in
gethostbyname() and friends is broken; unless setpwent() is used to
specify that lots of accesses are going to occur, the connection to the yp
server should be closed after every use.

Appended are context diffs to the 3.5 csh which result from the change
Alexander Dupuy suggests. One other problem of this type is also
corrected. Source indicates that 4.0 suffers from this bug.

		Craig
------
RCS file: RCS/sh.c,v
retrieving revision 1.1
diff -c -r1.1 sh.c
*** /tmp/,RCSt1a00437	Wed Jan 11 20:31:20 1989
--- sh.c	Wed Jan 11 20:21:11 1989
***************
*** 883,889 ****
  	char *home;
  {
  	register struct passwd *pp = getpwnam(home);
! 
  	if (pp == 0)
  		return (1);
  	(void) strcpy(home, pp->pw_dir);
--- 883,892 ----
  	char *home;
  {
  	register struct passwd *pp = getpwnam(home);
! 	char name[256];
! 	
! 	getdomainname(name, sizeof(name));
! 	yp_unbind(name);
  	if (pp == 0)
  		return (1);
  	(void) strcpy(home, pp->pw_dir);

RCS file: RCS/sh.file.c,v
retrieving revision 1.1
diff -c -r1.1 sh.file.c
*** /tmp/,RCSt1a00442	Wed Jan 11 20:31:24 1989
--- sh.file.c	Wed Jan 11 20:21:56 1989
***************
*** 296,302 ****
--- 296,306 ----
  	if (person[0] == '\0')
  		(void) strcpy(new, value("home"));
  	else {
+ 		char name[256];
+ 		
  		pw = getpwnam(person);
+ 		getdomainname(name, sizeof(name));
+ 		yp_unbind(name);
  		if (pw == NULL)
  			return (NULL);
  		(void) strcpy(new, pw->pw_dir);
***************
*** 379,385 ****
  	register struct direct *dirp;

  	if (looking_for_lognames) {
! 		if ((pw = getpwent ()) == NULL)
  			return (NULL);
  		return (pw->pw_name);
  	}
--- 383,393 ----
  	register struct direct *dirp;

  	if (looking_for_lognames) {
! 		char name[256];
! 		pw = getpwent ();
! 		getdomainname(name, sizeof(name));
! 		yp_unbind(name);
! 		if (pw == NULL)
  			return (NULL);
  		return (pw->pw_name);
  	}



More information about the Comp.sys.sun mailing list