initshells for aix
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8279 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -54,6 +54,13 @@ RCSID("$Id$");
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USERSEC_H
|
||||
#include <usersec.h>
|
||||
#endif
|
||||
#ifdef HAVE_USERCONF_H
|
||||
#include <userconf.h>
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_SHELLS
|
||||
#define _PATH_SHELLS "/etc/shells"
|
||||
#endif
|
||||
@@ -94,7 +101,6 @@ getusershell()
|
||||
void
|
||||
endusershell()
|
||||
{
|
||||
|
||||
if (shells != NULL)
|
||||
free(shells);
|
||||
shells = NULL;
|
||||
@@ -107,7 +113,6 @@ endusershell()
|
||||
void
|
||||
setusershell()
|
||||
{
|
||||
|
||||
curshell = initshells();
|
||||
}
|
||||
|
||||
@@ -115,7 +120,9 @@ static char **
|
||||
initshells()
|
||||
{
|
||||
char **sp, *cp;
|
||||
#ifndef HAVE_GETCONFATTR
|
||||
FILE *fp;
|
||||
#endif
|
||||
struct stat statb;
|
||||
|
||||
if (shells != NULL)
|
||||
@@ -124,6 +131,25 @@ initshells()
|
||||
if (strings != NULL)
|
||||
free(strings);
|
||||
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)
|
||||
return (okshells);
|
||||
if (fstat(fileno(fp), &statb) == -1) {
|
||||
@@ -153,8 +179,9 @@ initshells()
|
||||
cp++;
|
||||
*cp++ = '\0';
|
||||
}
|
||||
*sp = NULL;
|
||||
fclose(fp);
|
||||
#endif
|
||||
*sp = NULL;
|
||||
return (shells);
|
||||
}
|
||||
#endif /* HAVE_GETUSERSHELL */
|
||||
|
Reference in New Issue
Block a user