nixpkgs/pkgs/development/libraries/nss/85_security_load.patch

82 lines
3.7 KiB
Diff
Raw Normal View History

2017-01-24 13:49:14 +00:00
diff -ru -x '*~' -x '*.orig' -x '*.rej' nss/cmd/shlibsign/shlibsign.c nss/cmd/shlibsign/shlibsign.c
--- nss/cmd/shlibsign/shlibsign.c 2017-01-04 15:24:24.000000000 +0100
+++ nss/cmd/shlibsign/shlibsign.c 2017-01-24 14:43:31.030420852 +0100
@@ -875,6 +875,8 @@
goto cleanup;
}
lib = PR_LoadLibrary(libname);
+ if (!lib)
2014-04-22 13:54:36 +01:00
+ lib = PR_LoadLibrary(NIX_NSS_LIBDIR"libsoftokn3.so");
assert(lib != NULL);
2017-01-24 13:49:14 +00:00
if (!lib) {
PR_fprintf(PR_STDERR, "loading softokn3 failed");
diff -ru -x '*~' -x '*.orig' -x '*.rej' nss/coreconf/config.mk nss/coreconf/config.mk
--- nss/coreconf/config.mk 2017-01-04 15:24:24.000000000 +0100
+++ nss/coreconf/config.mk 2017-01-24 14:43:47.989432372 +0100
@@ -208,3 +208,6 @@
# exported symbols, which causes problem when NSS is built as part of Mozilla.
# So we add a NSS_SSL_ENABLE_ZLIB variable to allow Mozilla to turn this off.
NSS_SSL_ENABLE_ZLIB = 1
2014-04-22 13:54:36 +01:00
+
+# Nix specific stuff.
+DEFINES += -DNIX_NSS_LIBDIR=\"$(out)/lib/\"
2017-01-24 13:49:14 +00:00
diff -ru -x '*~' -x '*.orig' -x '*.rej' nss/lib/pk11wrap/pk11load.c nss/lib/pk11wrap/pk11load.c
--- nss/lib/pk11wrap/pk11load.c 2017-01-04 15:24:24.000000000 +0100
+++ nss/lib/pk11wrap/pk11load.c 2017-01-24 14:45:06.883485652 +0100
@@ -440,6 +440,13 @@
* unload the library if anything goes wrong from here on out...
*/
library = PR_LoadLibrary(mod->dllName);
+ if ((library == NULL) &&
+ !rindex(mod->dllName, PR_GetDirectorySeparator())) {
+ library = PORT_LoadLibraryFromOrigin(my_shlib_name,
2017-01-24 13:49:14 +00:00
+ (PRFuncPtr) &softoken_LoadDSO,
+ mod->dllName);
+ }
+
2017-01-24 13:49:14 +00:00
mod->library = (void *)library;
2017-01-24 13:49:14 +00:00
if (library == NULL) {
diff -ru -x '*~' -x '*.orig' -x '*.rej' nss/lib/util/secload.c nss/lib/util/secload.c
--- nss/lib/util/secload.c 2017-01-04 15:24:24.000000000 +0100
+++ nss/lib/util/secload.c 2017-01-24 14:43:31.030420852 +0100
2016-11-15 15:33:41 +00:00
@@ -70,9 +70,14 @@
/* Remove the trailing filename from referencePath and add the new one */
c = strrchr(referencePath, PR_GetDirectorySeparator());
+ if (!c) { /* referencePath doesn't contain a / means that dladdr gave us argv[0]
2014-04-22 13:54:36 +01:00
+ * and program was called from $PATH. Hack to get libs from NIX_NSS_LIBDIR */
+ referencePath = NIX_NSS_LIBDIR;
2015-12-16 15:18:42 +00:00
+ c = (char*) &referencePath[sizeof(NIX_NSS_LIBDIR) - 1]; /* last / */
+ }
if (c) {
size_t referencePathSize = 1 + c - referencePath;
2016-11-15 15:33:41 +00:00
- fullName = (char*)PORT_Alloc(strlen(name) + referencePathSize + 1);
+ fullName = (char*) PORT_Alloc(strlen(name) + referencePathSize + 5);
if (fullName) {
memcpy(fullName, referencePath, referencePathSize);
2016-11-15 15:33:41 +00:00
strcpy(fullName + referencePathSize, name);
@@ -82,6 +87,11 @@
#endif
libSpec.type = PR_LibSpec_Pathname;
libSpec.value.pathname = fullName;
+ if ((referencePathSize >= 4) &&
+ (strncmp(fullName + referencePathSize - 4, "bin", 3) == 0)) {
+ memcpy(fullName + referencePathSize -4, "lib", 3);
+ }
2014-04-22 13:54:36 +01:00
+ strcpy(fullName + referencePathSize, name);
dlh = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL
#ifdef PR_LD_ALT_SEARCH_PATH
2016-11-15 15:33:41 +00:00
/* allow library's dependencies to be found in the same directory
@@ -89,6 +99,10 @@
| PR_LD_ALT_SEARCH_PATH
#endif
);
+ if (! dlh) {
+ strcpy(fullName + referencePathSize, name);
+ dlh = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL);
+ }
PORT_Free(fullName);
}
}