From: Mike Hommey <mh@glandium.org>
Date: Tue, 23 Mar 2010 17:04:10 +0100
Subject: Resolve GRE directory symbolic link

https://bugzilla.mozilla.org/show_bug.cgi?id=530196
https://bugzilla.mozilla.org/show_bug.cgi?id=550659
---
 xulrunner/stub/nsXULStub.cpp |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/xulrunner/stub/nsXULStub.cpp b/xulrunner/stub/nsXULStub.cpp
index 17b96e4..143c1b2 100644
--- a/xulrunner/stub/nsXULStub.cpp
+++ b/xulrunner/stub/nsXULStub.cpp
@@ -430,6 +430,16 @@ main(int argc, char **argv)
       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);
