* Copyright (c) 1985 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)getusershell.c 5.4 (Berkeley) %G%";
#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')