File virtualbox-ose-sudo-tmpdir.diff of Package virtualbox-ose

--- src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcConfig.cpp
+++ src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcConfig.cpp
@@ -44,6 +44,10 @@
 #include "prenv.h"
 #include "plstr.h"
 
+#include <sys/types.h>
+#include <pwd.h>
+#include <unistd.h>
+
 #if defined(XP_OS2) && !defined(XP_OS2_NATIVEIPC)
 #ifdef VBOX
 static const char kDefaultSocketPrefix[] = "\\socket\\vbox-";
@@ -60,6 +64,16 @@
 static const char kDefaultSocketSuffix[] = "-ipc/ipcd";
 #endif
 
+const char * IPC_GetUsername(void)
+{
+    struct passwd * pw_struct;
+    pw_struct = getpwuid(getuid());
+    if (!pw_struct) {
+        return NULL;
+    }
+    return pw_struct->pw_name;
+}
+
 void IPC_GetDefaultSocketPath(char *buf, PRUint32 bufLen)
 {
     const char *logName;
@@ -71,12 +85,15 @@
 
     logName = PR_GetEnv("VBOX_IPC_SOCKETID");
     if (!logName || !logName[0]) {
-        logName = PR_GetEnv("LOGNAME");
-        if (!logName || !logName[0]) {
-            logName = PR_GetEnv("USER");
+        logName = IPC_GetUsername();
+        if (!logName) {
+            logName = PR_GetEnv("LOGNAME");
             if (!logName || !logName[0]) {
-                LOG(("could not determine username from environment\n"));
-                goto end;
+                logName = PR_GetEnv("USER");
+                if (!logName || !logName[0]) {
+                    LOG(("could not determine username from environment\n"));
+                    goto end;
+                }
             }
         }
     }
openSUSE Build Service is sponsored by