From fec9712b151ad31b053fe700cb0f809b9715407c Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
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/native/common/JarUtil.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 src/native/common/JarUtil.c

(limited to 'src/native')

diff --git a/src/native/common/JarUtil.c b/src/native/common/JarUtil.c
new file mode 100644
index 0000000..c918f77
--- /dev/null
+++ b/src/native/common/JarUtil.c
@@ -0,0 +1,39 @@
+#include <jni.h>
+
+#include <assert.h>
+
+#include "com_jogamp_common_util_JarUtil.h"
+
+#if defined(__APPLE__)
+    #include <sys/xattr.h>
+    static const char kQuarantineAttrName[] = "com.apple.quarantine";
+#endif
+
+/*
+ * Class:     com_jogamp_common_util_JarUtil
+ * Method:    fixNativeLibAttribs
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_jogamp_common_util_JarUtil_fixNativeLibAttribs
+  (JNIEnv *env, jclass _unused, jstring fname) {
+  const char* _UTF8fname = NULL;
+  int status = 0;
+  if (fname != NULL) {
+    if (fname != NULL) {
+      _UTF8fname = (*env)->GetStringUTFChars(env, fname, (jboolean*)NULL);
+    if (_UTF8fname == NULL) {
+      (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"),
+                       "Failed to get UTF-8 chars for argument \"fname\" in native dispatcher for \"removexattr\"");
+      return 0;
+    }
+    }
+  }
+#if defined(__APPLE__)
+  status = removexattr(_UTF8fname, kQuarantineAttrName, 0);
+#endif
+  if (fname != NULL) {
+    (*env)->ReleaseStringUTFChars(env, fname, _UTF8fname);
+  }
+  return 0 == status ? JNI_TRUE : JNI_FALSE;
+}
+
-- 
cgit v1.2.3