[comp.bugs.4bsd] Shadow passwords prevent some programs from recompiling

sms@wlv.imsd.contel.com (Steven M. Schultz(Y)) (05/19/89)

Subject: Shadow passwords prevent compilation of several 4.3BSD programs
Index:	{bin,usr.bin,ucb}/{ls.c,find/find.c,ucb/finger.c} 4.3BSD

Description:
	After installing the shadow password package on a 4.3BSD system,
	the symbol __pw_stayopen is undefined when recompiling 'ls',
	'find' and 'finger' because _pw_stayopen is no longer a global
	but is instead static in libc/gen/getpwent.c.

Repeat-By:
	Install the shadow password package.  Recompile 'ls', 'find' or
	'finger'.  Note the undefined symbol.

Fix:
	Use a setpassent(1) call instead of explicitly setting _pw_stayopen.
	These patches appear to do the trick.

*** bin/ls.c.old	Tue May 16 21:08:30 1989
--- bin/ls.c	Tue May 16 21:09:07 1989
***************
*** 621,627 ****
  getname(uid)
  	uid_t uid;
  {
- 	extern int _pw_stayopen;
  	static struct ncache {
  		uid_t	uid;
  		char	name[NMAX+1];
--- 621,626 ----
***************
*** 629,635 ****
  	register struct passwd *pw;
  	register struct ncache *cp;
  
! 	_pw_stayopen = 1;
  	cp = c_uid + (uid & CAMASK);
  	if (cp->uid == uid && *cp->name)
  		return(cp->name);
--- 628,634 ----
  	register struct passwd *pw;
  	register struct ncache *cp;
  
! 	setpassent(1);
  	cp = c_uid + (uid & CAMASK);
  	if (cp->uid == uid && *cp->name)
  		return(cp->name);
*** usr.bin/find/find.c.old	Tue May 16 22:46:46 1989
--- usr.bin/find/find.c	Tue May 16 22:47:14 1989
***************
*** 964,972 ****
  	register struct passwd *pw;
  	struct passwd *getpwent();
  	register int cp;
- 	extern int _pw_stayopen;
  
! 	_pw_stayopen = 1;
  
  #if	(((NUID) & ((NUID) - 1)) != 0)
  	cp = uid % (NUID);
--- 964,971 ----
  	register struct passwd *pw;
  	struct passwd *getpwent();
  	register int cp;
  
! 	setpassent(1);
  
  #if	(((NUID) & ((NUID) - 1)) != 0)
  	cp = uid % (NUID);
***************
*** 1038,1046 ****
  	register struct passwd *pw;
  	struct passwd *getpwnam();
  #ifndef	NO_PW_STAYOPEN
- 	extern int _pw_stayopen;
  
! 	_pw_stayopen = 1;
  #endif
  
  	pw = getpwnam(username);
--- 1037,1044 ----
  	register struct passwd *pw;
  	struct passwd *getpwnam();
  #ifndef	NO_PW_STAYOPEN
  
! 	setpassent(1);
  #endif
  
  	pw = getpwnam(username);
*** ucb/finger.c.old	Tue May 16 20:21:19 1989
--- ucb/finger.c	Tue May 16 20:27:37 1989
***************
*** 195,204 ****
  		exit(2);
  	}
  	if (unquick) {
! 		extern _pw_stayopen;
! 
! 		setpwent();
! 		_pw_stayopen = 1;
  		fwopen();
  	}
  	while (read(uf, (char *)&user, sizeof user) == sizeof user) {
--- 195,201 ----
  		exit(2);
  	}
  	if (unquick) {
! 		setpassent(1);
  		fwopen();
  	}
  	while (read(uf, (char *)&user, sizeof user) == sizeof user) {
***************
*** 273,281 ****
  	if (unquick) {
  		setpwent();
  		if (!match) {
! 			extern _pw_stayopen;
! 
! 			_pw_stayopen = 1;
  			for (p = person1; p != 0; p = p->link)
  				if (pw = getpwnam(p->name))
  					p->pwd = pwdcopy(pw);
--- 270,276 ----
  	if (unquick) {
  		setpwent();
  		if (!match) {
! 			setpassent(1);
  			for (p = person1; p != 0; p = p->link)
  				if (pw = getpwnam(p->name))
  					p->pwd = pwdcopy(pw);