make aix part work

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8280 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2000-05-22 09:11:59 +00:00
parent fc2957b4a7
commit d1ea8d9ea7

View File

@@ -41,6 +41,7 @@ RCSID("$Id$");
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#ifdef HAVE_PATHS_H #ifdef HAVE_PATHS_H
#include <paths.h> #include <paths.h>
#endif #endif
@@ -55,6 +56,7 @@ RCSID("$Id$");
#endif #endif
#ifdef HAVE_USERSEC_H #ifdef HAVE_USERSEC_H
struct aud_rec;
#include <usersec.h> #include <usersec.h>
#endif #endif
#ifdef HAVE_USERCONF_H #ifdef HAVE_USERCONF_H
@@ -120,35 +122,37 @@ static char **
initshells() initshells()
{ {
char **sp, *cp; char **sp, *cp;
#ifndef HAVE_GETCONFATTR #ifdef HAVE_GETCONFATTR
char *tmp;
int nsh;
#else
FILE *fp; FILE *fp;
#endif #endif
struct stat statb; struct stat statb;
if (shells != NULL) free(shells);
free(shells);
shells = NULL; shells = NULL;
if (strings != NULL) free(strings);
free(strings);
strings = NULL; strings = NULL;
#ifdef HAVE_GETCONFATTR #ifdef HAVE_GETCONFATTR
shells = calloc(47, sizeof(*shells)); if(getconfattr(SC_SYS_LOGIN, SC_SHELLS, &tmp, SEC_LIST) != 0)
return okshells;
for(cp = tmp, nsh = 0; *cp; cp += strlen(cp) + 1, nsh++);
shells = calloc(nsh + 1, sizeof(*shells));
if(shells == NULL) if(shells == NULL)
return okshells; return okshells;
if(getconfattr(SC_SYS_LOGIN, SC_SHELLS, &cp, SEC_LIST) != 0) {
free(shells); strings = malloc(cp - tmp);
shells = NULL;
return okshells;
}
strings = strdup(cp);
if(strings == NULL) { if(strings == NULL) {
free(shells); free(shells);
shells = NULL; shells = NULL;
return okshells; return okshells;
} }
for(sp = shells, cp = strings; cp; cp += strlen(cp) + 1, sp++) { memcpy(strings, tmp, cp - tmp);
for(sp = shells, cp = strings; *cp; cp += strlen(cp) + 1, sp++)
*sp = cp; *sp = cp;
}
#else #else
if ((fp = fopen(_PATH_SHELLS, "r")) == NULL) if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
return (okshells); return (okshells);