* Copyright (c) 1985 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)getusershell.c 5.5 (Berkeley) 7/21/88";
#endif /* LIBC_SCCS and not lint */
#define SHELLS "/etc/shells"
* Do not add local shells here. They should be added in /etc/shells
static char *okshells
[] =
{ "/bin/sh", "/bin/csh", 0 };
static char **shells
, *strings
;
static char **curshell
= NULL
;
extern char **initshells();
* Get a list of shells from SHELLS, if it exists.
extern char *malloc(), *calloc();
if ((fp
= fopen(SHELLS
, "r")) == (FILE *)0)
if (fstat(fileno(fp
), &statb
) == -1) {
if ((strings
= malloc((unsigned)statb
.st_size
)) == NULL
) {
shells
= (char **)calloc((unsigned)statb
.st_size
/ 3, sizeof (char *));
while (fgets(cp
, MAXPATHLEN
+ 1, fp
) != NULL
) {
while (*cp
!= '#' && *cp
!= '/' && *cp
!= '\0')
if (*cp
== '#' || *cp
== '\0')
while (!isspace(*cp
) && *cp
!= '#' && *cp
!= '\0')