[comp.sys.sun] strange nfs/yp/filec bug

tom@sun.com (Tom Gorodecki) (01/11/89)

A Strange behavior on sun3 (3.5SunOS ) with NFS/YP server sun4/280
(4.0SunOS).  Look at the following script, done on sun3:

/ 1% echo ~shmuel                          /* An user with a         */
/users/tesec/shmuel                        /* home directory on NFS */ 

/ 2% df /users/tesec
Filesystem            kbytes    used   avail capacity  Mounted on
tasu70:/ud70/tesec     532959  441935   37728    92%    /users/tesec

/ 3% ls ~shmuel                            /* there are few files */
bin		docs		mail		reports
man	        general	

/ 4%set filec                              /* turn the filec ON */

/ 6%ls ~shmue^[               /* ls ~shmuel using the filec. */
			      /* It make the completion fine, */
			      /* but ... NO FILES            */
/ 7%

If i change the "ls" command with "rm" , it will only recognize the
subdirectory of ~shmuel and stuck on regular files.

[[ Known bug.  Standard output gets trashed when you ask for filename
expansion on a user's home directory (~shu^[" for example), thus no
output.  Fixed in 4.0.1 (we don't have a 4.0 system, so I can't check
that).  --wnl ]]

Tom.
-- 
Gorodecki Tom.  National Semiconductor (IC)
6 Maskit st. P.O.B. 3007, Herzlia B,  46 104, Israel
UUCP:  {hplabs,pyramid,sun,decwrl}!nsc!taux01!tom
domain:  tom%taux01@nsc.com

leres@helios.ee.lbl.gov (Craig Leres) (02/28/89)

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);
  	}

lee@doc.cs.unm.edu (Lee Ward) (03/11/89)

In article <8901120433.AA00448@helios.ee.lbl.gov> leres@helios.ee.lbl.gov (Craig Leres) writes:
>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...

It's worse than that. A better fix is to go into
.../src/lib/libc/yp/yp_bind.c and get rid of the function newborn() and
all calls to it. The routines that worry about inherited file descriptors
take care to make sure that what they think is the connection to the
binder, in fact is. If not, they will rebind. So, newborn() is redundant.
This way you don't have to keep rebinding in the shell as well.

	--Lee (Ward)