Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!sri-unix!hplabs!tektronix!uw-beaver!uw-june!entropy!hubert From: hubert@entropy.UUCP (Steve Hubert) Newsgroups: net.bugs.4bsd Subject: getusershell(3) 4.3 Message-ID: <398@entropy.UUCP> Date: Mon, 27-Oct-86 20:56:31 EST Article-I.D.: entropy.398 Posted: Mon Oct 27 20:56:31 1986 Date-Received: Tue, 28-Oct-86 19:09:09 EST Organization: UW MathStat, Seattle Lines: 63 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')