contrib: bluray: Add an explicit path to find shared libraries
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Mon, 7 Jan 2019 18:43:17 +0000 (19:43 +0100)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Mon, 7 Jan 2019 18:47:37 +0000 (19:47 +0100)
This is needed because runtime hardening does not automatically look
for libraries outside of the own application bundle anymore.

contrib/src/bluray/0001-library-paths-Explicitly-add-usr-local-lib.patch [new file with mode: 0644]
contrib/src/bluray/rules.mak

diff --git a/contrib/src/bluray/0001-library-paths-Explicitly-add-usr-local-lib.patch b/contrib/src/bluray/0001-library-paths-Explicitly-add-usr-local-lib.patch
new file mode 100644 (file)
index 0000000..a3323d4
--- /dev/null
@@ -0,0 +1,34 @@
+From bbf867237c7fa326b5467afaad08f18a56a79935 Mon Sep 17 00:00:00 2001
+From: David Fuhrmann <dfuhrmann@videolan.org>
+Date: Mon, 7 Jan 2019 19:30:56 +0100
+Subject: [PATCH] library paths: Explicitly add /usr/local/lib
+
+Hardened runtime prevents the program to load any libraries outside
+of the application bundle by default. Specifically, it also ignores
+DYLD_FALLBACK_PATH which would contain /usr/local/lib.
+To allow usage of a library outside of the application bundle, add
+/usr/local/lib explicitly.
+---
+ src/file/dl_posix.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/file/dl_posix.c b/src/file/dl_posix.c
+index b97f12fe..49813856 100644
+--- a/src/file/dl_posix.c
++++ b/src/file/dl_posix.c
+@@ -69,10 +69,11 @@ void *dl_dlopen(const char *path, const char *version)
+        @loader_path     - location of current library/binary (ex. libbluray.dylib)
+        @executable_path - location of running binary (ex. /Applications/Some.app/Contents/MacOS)
+        @rpath           - search rpaths of running binary (man install_name_path)
++       /usr/local/lib/  - explicitly added path, as runtime hardened programs ignore DYLD_FALLBACK_PATH now
+     */
+     static const char *search_paths[] = {"", "@loader_path/lib/", "@loader_path/", "@executable_path/",
+                                          "@executable_path/lib/", "@executable_path/../lib/",
+-                                         "@executable_path/../Resources/", "@rpath/", NULL};
++                                         "@executable_path/../Resources/", "@rpath/", "/usr/local/lib/", NULL};
+     version = NULL;
+ #else
+     static const char ext[] = ".so";
+-- 
+2.17.2 (Apple Git-113)
+
index 67937b2..4211c38 100644 (file)
@@ -51,6 +51,7 @@ bluray: libbluray-$(BLURAY_VERSION).tar.bz2 .sum-bluray
        $(APPLY) $(SRC)/bluray/0001-Implement-dl_get_path-for-darwin-macOS.patch
        $(APPLY) $(SRC)/bluray/0001-keep-on-with-menuless-user-selected-streams-between-.patch
        $(APPLY) $(SRC)/bluray/0001-install-bdjo_data-header.patch
+       $(APPLY) $(SRC)/bluray/0001-library-paths-Explicitly-add-usr-local-lib.patch
        $(call pkg_static,"src/libbluray.pc.in")
        $(MOVE)