From: Ken Raeburn Date: Thu, 3 Jun 2004 02:19:23 +0000 (+0000) Subject: Closer to thread-safe.. X-Git-Tag: krb5-1.4-beta1~372 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c2e54c9119d773c9a92897e80206695fa9f6a0e0;p=krb5.git Closer to thread-safe.. * 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 --- diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index 83e3bb865..c9ee1cd4a 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,9 @@ +2004-06-02 Ken Raeburn + + * 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 * configure.in: When generating prtest, use AC_CONFIG_FILES diff --git a/src/util/profile/configure.in b/src/util/profile/configure.in index cfe717c10..f8576ea55 100644 --- a/src/util/profile/configure.in +++ b/src/util/profile/configure.in @@ -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 diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c index 12771d234..c0cbbbddf 100644 --- a/src/util/profile/prof_file.c +++ b/src/util/profile/prof_file.c @@ -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; }