[comp.bugs.4bsd.ucb-fixes] ARTICLE 4

bostic@OKEEFFE.BERKELEY.EDU.UUCP (03/20/87)

Subject: setusershell does not reset correctly
Index:	lib/libc/gen/getusershell.c 4.3BSD FIX

Description:
Calling setusershell does not properly reset to the beginning of
/etc/shells. In addition, comments are not handled properly.

Fix:
*** getusershell.c.5.2	Thu Mar  5 01:39:23 1987
--- getusershell.c.5.4	Thu Mar  5 01:39:34 1987
***************
*** 7,9 ****
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)getusershell.c	5.2 (Berkeley) 3/9/86";
  #endif LIBC_SCCS and not lint
--- 7,9 ----
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)getusershell.c	5.4 (Berkeley) 7/25/86";
  #endif LIBC_SCCS and not lint
***************
*** 24,27 ****
  
- static int inprogress;
  static char **shells, *strings;
  extern char **initshells();
--- 24,27 ----
  
  static char **shells, *strings;
+ static char **curshell = NULL;
  extern char **initshells();
***************
*** 35,43 ****
  	char *ret;
- 	static char **shells;
  
! 	if (!inprogress)
! 		shells = initshells();
! 	ret = *shells;
! 	if (*shells != NULL)
! 		shells++;
  	return (ret);
--- 35,42 ----
  	char *ret;
  
! 	if (curshell == NULL)
! 		curshell = initshells();
! 	ret = *curshell;
! 	if (ret != NULL)
! 		curshell++;
  	return (ret);

***************
*** 54,56 ****
  	strings = NULL;
! 	inprogress = 0;
  }
--- 53,55 ----
  	strings = NULL;
! 	curshell = NULL;
  }
***************
*** 60,62 ****
  
! 	shells = initshells();
  }
--- 59,61 ----
  
! 	curshell = initshells();
  }
***************
*** 71,73 ****
  
- 	inprogress = 1;
  	if (shells != NULL)
--- 70,71 ----
***************
*** 98,102 ****
  	while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
! 		while (*cp != '/' && *cp != '\0')
  			cp++;
! 		if (*cp == '\0')
  			continue;
--- 96,100 ----
  	while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
! 		while (*cp != '#' && *cp != '/' && *cp != '\0')
  			cp++;
! 		if (*cp == '#' || *cp == '\0')
  			continue;