rendered paste body--- safe_mode.c.old 2007-01-10 04:22:08.000000000 +0000
+++ safe_mode.c 2007-01-10 05:54:30.686444344 +0000
@@ -228,12 +228,32 @@
return SG(request_info).current_user;
#else
struct passwd *pwd;
+#ifdef HAVE_GETPWUID_R
+ struct passwd _pw;
+ struct passwd *retpwptr = NULL;
+ int pwbuflen;
+ char *pwbuf;
+ int ret;
+ pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
+ pwbuf = emalloc(pwbuflen);
+ ret = getpwuid_r(pstat->st_uid, &_pw, pwbuf, pwbuflen, &retpwptr);
+ if (0 != ret) {
+ efree(pwbuf);
+ return "";
+ }
+ pwd = &_pw;
+#else
if ((pwd=getpwuid(pstat->st_uid))==NULL) {
return "";
}
+#endif
+
SG(request_info).current_user_length = strlen(pwd->pw_name);
SG(request_info).current_user = estrndup(pwd->pw_name, SG(request_info).current_user_length);
+#ifdef HAVE_GETPWUID_R
+ efree(pwbuf);
+#endif
return SG(request_info).current_user;
#endif
}