* kuserok.c (krb5_kuserok): Handle draft POSIX versions of getpwnam_r
authorKen Raeburn <raeburn@mit.edu>
Fri, 4 Jun 2004 20:29:22 +0000 (20:29 +0000)
committerKen Raeburn <raeburn@mit.edu>
Fri, 4 Jun 2004 20:29:22 +0000 (20:29 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16409 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/ChangeLog
src/lib/krb5/os/kuserok.c

index a0d6496551082d6acea0e598a4c45dd64fb32ad2..07ab6ee095a06d1f59eaa7a4ead20c41a4ef40ec 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-04  Ken Raeburn  <raeburn@mit.edu>
+
+       * kuserok.c (krb5_kuserok): Handle draft POSIX versions of
+       getpwnam_r.
+
 2004-06-02  Tom Yu  <tlyu@mit.edu>
 
        * an_to_ln.c (do_replacement): Patch from Bill Dodd to fix missing
index bc4f82412677c10d243dbdad4671ef1a5798bf7f..b87b528d10360b7e1f09469d43946a7d42b397f9 100644 (file)
@@ -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));