+2004-07-06 Ken Raeburn <raeburn@mit.edu>
+
+ * import_name.c [HAVE_GETPWUID_R]: Include stdio.h.
+ (krb5_gss_import_name) [HAVE_GETPWUID_R]: Use getpwuid_r instead
+ of getpwuid, for thread safety.
+
2004-06-17 Tom Yu <tlyu@mit.edu>
* ser_sctx.c (kg_ctx_size, kg_ctx_externalize):
#ifndef NO_PASSWORD
#include <pwd.h>
+#ifdef HAVE_GETPWUID_R
+#include <stdio.h>
+#endif
#endif
#ifdef HAVE_STRING_H
return(GSS_S_FAILURE);
}
} else {
+#ifndef NO_PASSWORD
+ uid_t uid;
+#ifdef HAVE_GETPWUID_R
+ struct passwd pwx;
+ char pwbuf[BUFSIZ];
+#endif
+#endif
+
stringrep = NULL;
if ((tmp =
stringrep = (char *) tmp;
#ifndef NO_PASSWORD
} else if (g_OID_equal(input_name_type, gss_nt_machine_uid_name)) {
- if ((pw = getpwuid(*((uid_t *) input_name_buffer->value))))
+ uid = *(uid_t *) input_name_buffer->value;
+ do_getpwuid:
+#ifndef HAVE_GETPWUID_R
+ pw = getpwuid(uid);
+#elif defined(GETPWUID_R_4_ARGS)
+ /* old POSIX drafts */
+ pw = getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf));
+#else
+ /* POSIX */
+ if (getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf), &pw) != 0)
+ pw = NULL;
+#endif
+ if (pw)
stringrep = pw->pw_name;
else
*minor_status = (OM_uint32) G_NOUSER;
} else if (g_OID_equal(input_name_type, gss_nt_string_uid_name)) {
- if ((pw = getpwuid((uid_t) atoi(tmp))))
- stringrep = pw->pw_name;
- else
- *minor_status = (OM_uint32) G_NOUSER;
+ uid = atoi(tmp);
+ goto do_getpwuid;
#endif
} else if (g_OID_equal(input_name_type, gss_nt_exported_name)) {
cp = tmp;