Closer to thread-safe..
authorKen Raeburn <raeburn@mit.edu>
Thu, 3 Jun 2004 02:19:23 +0000 (02:19 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 3 Jun 2004 02:19:23 +0000 (02:19 +0000)
* configure.in: Check for getpwuid_r.
* prof_file.c (profile_open_file) [HAVE_PWD_H && HAVE_GETPWUID_R]: Use
getpwuid_r if available.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16395 dc483132-0cff-0310-8789-dd5450dbe970

src/util/profile/ChangeLog
src/util/profile/configure.in
src/util/profile/prof_file.c

index 83e3bb8652a0a6f4b595ad2529a8268e11e9dce8..c9ee1cd4abc81c59c0698ae6d45228c1f70230d7 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-02  Ken Raeburn  <raeburn@mit.edu>
+
+       * configure.in: Check for getpwuid_r.
+       * prof_file.c (profile_open_file) [HAVE_PWD_H && HAVE_GETPWUID_R]:
+       Use getpwuid_r if available.
+
 2004-05-24  Ezra Peisach  <epeisach@mit.edu>
 
        * configure.in: When generating prtest, use AC_CONFIG_FILES
index cfe717c10434a1ec2e75b0596c500701a8a53152..f8576ea55efb5044126a13b5cd61c463951689f5 100644 (file)
@@ -5,7 +5,7 @@ AC_CHECK_SIZEOF(short)
 AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_HEADERS(unistd.h stdlib.h pwd.h)
-AC_CHECK_FUNCS(stat access strdup)
+AC_CHECK_FUNCS(stat access strdup getpwuid_r)
 AC_PROG_AWK
 KRB5_BUILD_LIBOBJS
 KRB5_BUILD_PROGRAM
index 12771d234e1e5e7895a162534b57170a5a7cb30e..c0cbbbddf9c5eb19d590537f288ee9235858a64e 100644 (file)
@@ -144,9 +144,19 @@ errcode_t profile_open_file(const_profile_filespec_t filespec,
                if (home_env == NULL) {
                    uid_t uid;
                    struct passwd *pw;
+#ifdef HAVE_GETPWUID_R
+                   struct passwd pwx;
+                   char pwbuf[BUFSIZ];
+#endif
 
                    uid = getuid();
+#ifdef HAVE_GETPWUID_R
+                   if (getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf), &pw) != 0)
+                       /* Probably already null, but let's make sure.  */
+                       pw = NULL;
+#else
                    pw = getpwuid(uid);
+#endif
                    if (pw != NULL && pw->pw_dir[0] != 0)
                        home_env = pw->pw_dir;
                }