Bug 530196: Using a symlinked greDir fails to launch application from nsXULStub [r=bsmedberg]
authorMark Finkle <mfinkle@mozilla.com>
Mon, 23 Nov 2009 22:17:06 -0500
changeset 35213 41c1b69b3ed34231dc93b1da9b526aa83fe1ddb7
parent 35212 8ca9facea08d92cb948824988225c8f14c4e0c4b
child 35214 ae44b06ea87685fca7ebb060f6b30a52214c7d05
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs530196
milestone1.9.3a1pre
Bug 530196: Using a symlinked greDir fails to launch application from nsXULStub [r=bsmedberg]
xulrunner/stub/nsXULStub.cpp
--- a/xulrunner/stub/nsXULStub.cpp
+++ b/xulrunner/stub/nsXULStub.cpp
@@ -413,17 +413,26 @@ main(int argc, char **argv)
       // XXXbsmedberg: Do something much smarter here: notify the
       // user/offer to download/?
 
       Output(PR_FALSE,
              "Could not find compatible GRE between version %s and %s.\n",
              range.lower, range.upper);
       return 1;
     }
+#ifdef XP_UNIX
+    // Using a symlinked greDir will fail during startup. Not sure why, but if
+    // we resolve the symlink, everything works as expected.
+    char resolved_greDir[MAXPATHLEN] = "";  
+    if (realpath(greDir, resolved_greDir) && *resolved_greDir) {
+      strncpy(greDir, resolved_greDir, MAXPATHLEN);
+    }
+#endif
   }
+
 #ifdef XP_OS2
   // On OS/2 we need to set BEGINLIBPATH to be able to find XULRunner DLLs
   strcpy(tmpPath, greDir);
   lastSlash = strrchr(tmpPath, PATH_SEPARATOR_CHAR);
   if (lastSlash) {
     *lastSlash = '\0';
   }
   DosSetExtLIBPATH(tmpPath, BEGIN_LIBPATH);