From 1c1171ff7fd5e6f2f080c565dfd316a7cba2bb37 Mon Sep 17 00:00:00 2001 From: "mark%moxienet.com" Date: Fri, 26 May 2006 17:56:18 +0000 Subject: [PATCH] 339238 Java doesn't work when MRJPlugin.plugin is a symbolic link. CFBundleCopyExecutableURL doesn't return a proper URL for bundles whose roots are referred to by symlink. Resolve bundle paths when they are symbolic links. r=josh sr=darin git-svn-id: svn://10.0.0.236/trunk@198465 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/base/src/nsPluginHostImpl.cpp | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 0555c418287..3c5ae427ec2 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -4386,18 +4386,33 @@ nsPluginHostImpl::FindPluginEnabledForExtension(const char* aExtension, #include #include -inline PRBool is_directory(const char* path) +static inline PRBool is_directory(const char* path) { struct stat sb; - if (stat(path, &sb) == 0 && (sb.st_mode & S_IFDIR)) { - return PR_TRUE; - } - return PR_FALSE; + return ::stat(path, &sb) == 0 && S_ISDIR(sb.st_mode); +} + +static inline PRBool is_symbolic_link(const char* path) +{ + struct stat sb; + return ::lstat(path, &sb) == 0 && S_ISLNK(sb.st_mode); } static int open_executable(const char* path) { int fd = 0; + char resolvedPath[PATH_MAX] = "\0"; + + // If the root of the bundle as referred to by path is a symbolic link, + // CFBundleCopyExecutableURL will not return an absolute URL, but will + // instead only return the executable name, such as "MRJPlugin". Work + // around that by always using a fully-resolved absolute pathname. + if (is_symbolic_link(path)) { + path = realpath(path, resolvedPath); + if (!path) + return fd; + } + // if this is a directory, it must be a bundle, so get the true path using CFBundle... if (is_directory(path)) { CFBundleRef bundle = NULL;