Rex Dieter ace1f8
diff -up qt-everywhere-opensource-src-4.8.5/src/corelib/io/qfilesystemengine_unix.cpp.QTBUG-4862 qt-everywhere-opensource-src-4.8.5/src/corelib/io/qfilesystemengine_unix.cpp
Rex Dieter ace1f8
--- qt-everywhere-opensource-src-4.8.5/src/corelib/io/qfilesystemengine_unix.cpp.QTBUG-4862	2013-06-09 12:02:50.323221694 -0500
Rex Dieter ace1f8
+++ qt-everywhere-opensource-src-4.8.5/src/corelib/io/qfilesystemengine_unix.cpp	2013-06-09 12:38:53.140804742 -0500
Rex Dieter ace1f8
@@ -624,6 +624,25 @@ QString QFileSystemEngine::homePath()
0e5654
 {
0e5654
     QString home = QFile::decodeName(qgetenv("HOME"));
Rex Dieter ace1f8
     if (home.isEmpty())
0e5654
+    {
0e5654
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
0e5654
+        int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
0e5654
+        if (size_max == -1)
0e5654
+            size_max = 1024;
0e5654
+        QVarLengthArray<char, 1024> buf(size_max);
0e5654
+#endif
0e5654
+        struct passwd *pw = 0;
0e5654
+        uid_t user_id = getuid();
0e5654
+        pw = getpwuid(user_id);
0e5654
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
0e5654
+        struct passwd entry;
0e5654
+        getpwuid_r(user_id, &entry, buf.data(), buf.size(), &pw;;
0e5654
+#else
0e5654
+        pw = getpwuid(user_id);
0e5654
+#endif
0e5654
+        home = QFile::decodeName(QByteArray(pw->pw_dir));
0e5654
+    }
0e5654
+    if (home.isEmpty())
0e5654
         home = rootPath();
0e5654
     return QDir::cleanPath(home);
0e5654
 }