From d1ea8d9ea716bf6ceef4606abdc91c9f24e61886 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Mon, 22 May 2000 09:11:59 +0000 Subject: [PATCH] make aix part work git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8280 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/roken/getusershell.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/roken/getusershell.c b/lib/roken/getusershell.c index 6c0908144..347fd25f7 100644 --- a/lib/roken/getusershell.c +++ b/lib/roken/getusershell.c @@ -41,6 +41,7 @@ RCSID("$Id$"); #include #include +#include #ifdef HAVE_PATHS_H #include #endif @@ -55,6 +56,7 @@ RCSID("$Id$"); #endif #ifdef HAVE_USERSEC_H +struct aud_rec; #include #endif #ifdef HAVE_USERCONF_H @@ -120,35 +122,37 @@ static char ** initshells() { char **sp, *cp; -#ifndef HAVE_GETCONFATTR +#ifdef HAVE_GETCONFATTR + char *tmp; + int nsh; +#else FILE *fp; #endif struct stat statb; - if (shells != NULL) - free(shells); + free(shells); shells = NULL; - if (strings != NULL) - free(strings); + free(strings); strings = NULL; #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) return okshells; - if(getconfattr(SC_SYS_LOGIN, SC_SHELLS, &cp, SEC_LIST) != 0) { - free(shells); - shells = NULL; - return okshells; - } - strings = strdup(cp); + + strings = malloc(cp - tmp); if(strings == NULL) { free(shells); shells = NULL; 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; - } #else if ((fp = fopen(_PATH_SHELLS, "r")) == NULL) return (okshells);