🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Steve Hubert Tue, 28 Oct 1986 01:56
getusershell(3) 4.3
#1719
Author: Steve Hubert
Date: Tue, 28 Oct 1986 01:56
63 lines
2087 bytes
Subject: getusershell() is buggy
Index:	lib/libc/gen/getusershell.c 4.3BSD

Description:
	Getusershell(3) does not handle comments correctly.  Setusershell(3)
	does not work at all.
Repeat-By:
	Run the following program with the default version of /etc/shells.
	Notice that the first shell printed out is /passwd.  This comes
	from one of the leading comments in the file /etc/shells.  Also notice
	that setusershell() does not rewind the shells file so nothing is
	printed out in the second loop.

main() {
	char *cp, *getusershell();

	for (cp = getusershell(); cp; cp = getusershell())
		printf("%s\n", cp);
	setusershell();
	for (cp = getusershell(); cp; cp = getusershell())
		printf("%s\n", cp);
}

Fix:
	There was a fix posted as 4573@brl-smoke.ARPA to netnews.
	That fix (as received at my site) was obviously incorrect since
	it didn't work and it contained a line of code that looked like:

	while (!isspace(*cp) != '/' && *cp != '\0')

	Here is a context diff (to the original getusershell.c) to fix
	the problem.

*** getusershell.c.old	Mon Oct 27 17:17:05 1986
--- getusershell.c.new	Mon Oct 27 17:17:05 1986
***************
*** 58,64 ****
  setusershell()
  {
  
! 	shells = initshells();
  }
  
  static char **
--- 58,64 ----
  setusershell()
  {
  
! 	endusershell();
  }
  
  static char **
***************
*** 96,101 ****
--- 96,103 ----
  	sp = shells;
  	cp = strings;
  	while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
+ 		if (*cp == '#')
+ 			continue;
  		while (*cp != '/' && *cp != '\0')
  			cp++;
  		if (*cp == '\0')
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads