office-gobmx/external/nss/macos-dlopen.patch.0
Stephan Bergmann a3ca9b88b4 tdf#127619: external/nss: Load smime3 lib with a path on macOS
A plain dlopen("libsmime3.dylib",...) would search (among other places)
DYLD_FALLBACK_LIBRARY_PATH, which when unset defaults to a set of paths
including /usr/local/lib (so would erroneously find Homebrew's
/usr/local/lib/libsmime3.dylib instead of LO's
LibreOffice.app/Contents/Frameworks/libsmime3.dylib next to the calling
LibreOffice.app/Contents/Frameworks/libnspr4.dylib).

At least macOS 10.15.2 supports a "@loader_path/" prefix in dlopen, to find the
requested library next to the calling code, so use that as a quick fix.  (Should
that turn out to be problematic, there is PORT_LoadLibraryFromOrigin in
workdir/UnpackedTarball/nss/nss/lib/util/secload.c that might be useful in a
more elaborate fix.)

Change-Id: I8688606017a4b32a2dd55740f67b8fdb36fc5435
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86966
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-01-17 12:56:29 +01:00

25 lines
1 KiB
Text

--- nspr/pr/src/linking/prlink.c
+++ nspr/pr/src/linking/prlink.c
@@ -793,7 +793,7 @@
/* ensure the file exists if it contains a slash character i.e. path */
/* DARWIN's dlopen ignores the provided path and checks for the */
/* plain filename in DYLD_LIBRARY_PATH */
- if (strchr(name, PR_DIRECTORY_SEPARATOR) == NULL ||
+ if (strchr(name, PR_DIRECTORY_SEPARATOR) == NULL || strncmp(name, "@loader_path/", 13) == 0 ||
PR_Access(name, PR_ACCESS_EXISTS) == PR_SUCCESS) {
h = dlopen(name, dl_flags);
}
--- nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_httpcertstore.c
+++ nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_httpcertstore.c
@@ -224,7 +224,11 @@
static PRStatus PR_CALLBACK pkix_getDecodeFunction(void)
{
pkix_decodeFunc.smimeLib =
+#if defined DARWIN
+ PR_LoadLibrary("@loader_path/" SHLIB_PREFIX"smime3."SHLIB_SUFFIX);
+#else
PR_LoadLibrary(SHLIB_PREFIX"smime3."SHLIB_SUFFIX);
+#endif
if (pkix_decodeFunc.smimeLib == NULL) {
return PR_FAILURE;
}