diff options
author | Toomas Soome <tsoome@me.com> | 2020-02-08 20:24:21 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2020-03-18 19:36:25 +0200 |
commit | 97b5374547d500fded52d886ceba8a9962af0527 (patch) | |
tree | 58133eb5538d122ed076707c9abe35530356cc0c /usr/src/lib/libbc/libc/gen/common/getusershell.c | |
parent | 20d3bf629e3e91ea61dee8153d5bc47daeab26b0 (diff) | |
download | illumos-joyent-97b5374547d500fded52d886ceba8a9962af0527.tar.gz |
12292 retire libbc
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Reviewed by: Alexander Eremin <aeremin@tintri.com>
Approved by: Garrett D'Amore <garrett@damore.org>
Diffstat (limited to 'usr/src/lib/libbc/libc/gen/common/getusershell.c')
-rw-r--r-- | usr/src/lib/libbc/libc/gen/common/getusershell.c | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/usr/src/lib/libbc/libc/gen/common/getusershell.c b/usr/src/lib/libbc/libc/gen/common/getusershell.c deleted file mode 100644 index f164bea8e4..0000000000 --- a/usr/src/lib/libbc/libc/gen/common/getusershell.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/param.h> -#include <sys/file.h> -#include <sys/stat.h> -#include <ctype.h> -#include <stdio.h> -#include <malloc.h> - -#define SHELLS "/etc/shells" - -/* - * Do not add local shells here. They should be added in /etc/shells - */ -static char *okshells[] = - { "/bin/sh", "/bin/csh", "/usr/bin/sh", "/usr/bin/csh", 0 }; - -static char **shells, *strings; -static char **curshell; - -static char **initshells(void); - -/* - * Get a list of shells from SHELLS, if it exists. - */ -char * -getusershell(void) -{ - char *ret; - - if (curshell == NULL) - curshell = initshells(); - ret = *curshell; - if (ret != NULL) - curshell++; - return (ret); -} - -void -endusershell(void) -{ - - if (shells != NULL) - free((char *)shells); - shells = NULL; - if (strings != NULL) - free(strings); - strings = NULL; - curshell = NULL; -} - -void -setusershell(void) -{ - - curshell = initshells(); -} - -static char ** -initshells(void) -{ - char **sp, *cp; - FILE *fp; - struct stat statb; - - if (shells != NULL) - free((char *)shells); - shells = NULL; - if (strings != NULL) - free(strings); - strings = NULL; - if ((fp = fopen(SHELLS, "r")) == (FILE *)0) - return (okshells); - if (fstat(fileno(fp), &statb) == -1) { - (void)fclose(fp); - return (okshells); - } - if ((strings = malloc((unsigned)statb.st_size + 1)) == NULL) { - (void)fclose(fp); - return (okshells); - } - shells = (char **)calloc((unsigned)statb.st_size / 3, sizeof (char *)); - if (shells == NULL) { - (void)fclose(fp); - free(strings); - strings = NULL; - return (okshells); - } - sp = shells; - cp = strings; - while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) { - while (*cp != '#' && *cp != '/' && *cp != '\0') - cp++; - if (*cp == '#' || *cp == '\0') - continue; - *sp++ = cp; - while (!isspace(*cp) && *cp != '#' && *cp != '\0') - cp++; - *cp++ = '\0'; - } - *sp = (char *)0; - (void)fclose(fp); - return (shells); -} |