- group *gr;
- if ((gr = getgrgid(getgid())) != NULL)
- return wxString(gr->gr_name, wxConvLibc);
+
+static wxString wxTarUserName(int uid)
+{
+ struct passwd *ppw;
+
+#ifdef HAVE_GETPWUID_R
+#if defined HAVE_SYSCONF && defined _SC_GETPW_R_SIZE_MAX
+ long pwsize = sysconf(_SC_GETPW_R_SIZE_MAX);
+ size_t bufsize(wxMin(wxMax(1024l, pwsize), 32768l));
+#else
+ size_t bufsize = 1024;
+#endif
+ wxCharBuffer buf(bufsize);
+ struct passwd pw;
+
+ if (getpwuid_r(uid, &pw, buf.data(), bufsize, &ppw) == 0)
+ return wxString(pw.pw_name, wxConvLibc);
+#else
+ if ((ppw = getpwuid(uid)) != NULL)
+ return wxString(ppw->pw_name, wxConvLibc);