From fec9712b151ad31b053fe700cb0f809b9715407c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 23 Oct 2013 16:48:42 +0200 Subject: Fix Bug 865: Safari >= 6.1 [OSX]: May employ xattr on 'com.apple.quarantine' on 'PluginProcess.app' - IOUtil.getTempDir(..): Don't test executable caps on OSX for java_io_tmpdir - JarUtil.extract(..): Issue native fixNativeLibAttribs(..) on OSX for native library files, i.e. remove xattr 'com.apple.quarantine' --- src/java/com/jogamp/common/util/JarUtil.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/java/com/jogamp/common/util/JarUtil.java') diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java index 5411d66..b5f8850 100644 --- a/src/java/com/jogamp/common/util/JarUtil.java +++ b/src/java/com/jogamp/common/util/JarUtil.java @@ -47,6 +47,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import com.jogamp.common.os.NativeLibrary; +import com.jogamp.common.os.Platform; import jogamp.common.Debug; @@ -632,6 +633,7 @@ public class JarUtil { if (isNativeLib && ( isRootEntry || !nativeLibMap.containsKey(libBaseName) ) ) { nativeLibMap.put(libBaseName, destFile.getAbsolutePath()); addedAsNativeLib = true; + fixNativeLibAttribs(destFile); } } if (DEBUG) { @@ -642,6 +644,32 @@ public class JarUtil { return num; } + /** + * Mitigate file permission issues of native library files, i.e.: + * + */ + private final static void fixNativeLibAttribs(File file) { + // We tolerate UnsatisfiedLinkError (and derived) to solve the chicken and egg problem + // of loading gluegen's native library. + // On Safari(OSX), Bug 865, we simply hope the destination folder is executable. + if( Platform.OSType.MACOS == Platform.getOSType() ) { + final String fileAbsPath = file.getAbsolutePath(); + try { + fixNativeLibAttribs(fileAbsPath); + if( DEBUG ) { + System.err.println("JarUtil.fixNativeLibAttribs: "+fileAbsPath+" - OK"); + } + } catch (Throwable t) { + if( DEBUG ) { + System.err.println("JarUtil.fixNativeLibAttribs: "+fileAbsPath+" - "+t.getClass().getSimpleName()+": "+t.getMessage()); + } + } + } + } + private native static boolean fixNativeLibAttribs(String fname); + /** * Validate the certificates for each native Lib in the jar file. * Throws an IOException if any certificate is not valid. -- cgit v1.2.3