initshells for aix

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8279 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2000-05-22 07:22:03 +00:00
parent b281fa4f30
commit fc2957b4a7

View File

@@ -54,6 +54,13 @@ RCSID("$Id$");
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#ifdef HAVE_USERSEC_H
#include <usersec.h>
#endif
#ifdef HAVE_USERCONF_H
#include <userconf.h>
#endif
#ifndef _PATH_SHELLS #ifndef _PATH_SHELLS
#define _PATH_SHELLS "/etc/shells" #define _PATH_SHELLS "/etc/shells"
#endif #endif
@@ -94,7 +101,6 @@ getusershell()
void void
endusershell() endusershell()
{ {
if (shells != NULL) if (shells != NULL)
free(shells); free(shells);
shells = NULL; shells = NULL;
@@ -107,7 +113,6 @@ endusershell()
void void
setusershell() setusershell()
{ {
curshell = initshells(); curshell = initshells();
} }
@@ -115,7 +120,9 @@ static char **
initshells() initshells()
{ {
char **sp, *cp; char **sp, *cp;
#ifndef HAVE_GETCONFATTR
FILE *fp; FILE *fp;
#endif
struct stat statb; struct stat statb;
if (shells != NULL) if (shells != NULL)
@@ -124,6 +131,25 @@ initshells()
if (strings != NULL) if (strings != NULL)
free(strings); free(strings);
strings = NULL; strings = NULL;
#ifdef HAVE_GETCONFATTR
shells = calloc(47, sizeof(*shells));
if(shells == NULL)
return okshells;
if(getconfattr(SC_SYS_LOGIN, SC_SHELLS, &cp, SEC_LIST) != 0) {
free(shells);
shells = NULL;
return okshells;
}
strings = strdup(cp);
if(strings == NULL) {
free(shells);
shells = NULL;
return okshells;
}
for(sp = shells, cp = strings; cp; cp += strlen(cp) + 1, sp++) {
*sp = cp;
}
#else
if ((fp = fopen(_PATH_SHELLS, "r")) == NULL) if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
return (okshells); return (okshells);
if (fstat(fileno(fp), &statb) == -1) { if (fstat(fileno(fp), &statb) == -1) {
@@ -153,8 +179,9 @@ initshells()
cp++; cp++;
*cp++ = '\0'; *cp++ = '\0';
} }
*sp = NULL;
fclose(fp); fclose(fp);
#endif
*sp = NULL;
return (shells); return (shells);
} }
#endif /* HAVE_GETUSERSHELL */ #endif /* HAVE_GETUSERSHELL */