From: Ken Raeburn Date: Fri, 4 Jun 2004 20:29:22 +0000 (+0000) Subject: * kuserok.c (krb5_kuserok): Handle draft POSIX versions of getpwnam_r X-Git-Tag: krb5-1.4-beta1~363 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ef0cef40abae03d70812cef6d4451c1fa9d782c7;p=krb5.git * kuserok.c (krb5_kuserok): Handle draft POSIX versions of getpwnam_r git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16409 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index a0d649655..07ab6ee09 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,8 @@ +2004-06-04 Ken Raeburn + + * kuserok.c (krb5_kuserok): Handle draft POSIX versions of + getpwnam_r. + 2004-06-02 Tom Yu * an_to_ln.c (do_replacement): Patch from Bill Dodd to fix missing diff --git a/src/lib/krb5/os/kuserok.c b/src/lib/krb5/os/kuserok.c index bc4f82412..b87b528d1 100644 --- a/src/lib/krb5/os/kuserok.c +++ b/src/lib/krb5/os/kuserok.c @@ -74,9 +74,22 @@ krb5_kuserok(krb5_context context, krb5_principal principal, const char *luser) int gobble; /* no account => no access */ - if ((pwd = getpwnam(luser)) == NULL) { +#ifdef HAVE_GETPWNAM_R + char pwbuf[BUFSIZ]; + struct passwd pwx; +#if !defined(GETPWNAM_R_4_ARGS) + /* POSIX */ + if (getpwnam_r(luser, &pwx, pwbuf, sizeof(pwbuf), &pwd) != 0) + pwd = NULL; +#else + /* draft POSIX */ + pwd = getpwnam_r(luser, &pwx, pwbuf, sizeof(pwbuf)); +#endif +#else + pwd = getpwnam(luser); +#endif + if (pwd == NULL) return(FALSE); - } (void) strncpy(pbuf, pwd->pw_dir, sizeof(pbuf) - 1); pbuf[sizeof(pbuf) - 1] = '\0'; (void) strncat(pbuf, "/.k5login", sizeof(pbuf) - 1 - strlen(pbuf));