nixpkgs/pkgs/development/libraries/nss/85_security_load.patch
2016-11-15 16:58:45 +01:00

82 lines
3.7 KiB
Diff

diff -ru -x '*~' nss-3.27.1-orig/nss/cmd/shlibsign/shlibsign.c nss-3.27.1/nss/cmd/shlibsign/shlibsign.c
--- nss-3.27.1-orig/nss/cmd/shlibsign/shlibsign.c 2016-10-03 16:55:58.000000000 +0200
+++ nss-3.27.1/nss/cmd/shlibsign/shlibsign.c 2016-11-15 16:28:07.308117900 +0100
@@ -871,6 +871,8 @@
libname = PR_GetLibraryName(NULL, "softokn3");
assert(libname != NULL);
lib = PR_LoadLibrary(libname);
+ if (!lib)
+ lib = PR_LoadLibrary(NIX_NSS_LIBDIR"libsoftokn3.so");
assert(lib != NULL);
PR_FreeLibraryName(libname);
diff -ru -x '*~' nss-3.27.1-orig/nss/coreconf/config.mk nss-3.27.1/nss/coreconf/config.mk
--- nss-3.27.1-orig/nss/coreconf/config.mk 2016-10-03 16:55:58.000000000 +0200
+++ nss-3.27.1/nss/coreconf/config.mk 2016-11-15 16:28:07.308117900 +0100
@@ -217,3 +217,6 @@
ifdef NSS_NO_PKCS11_BYPASS
DEFINES += -DNO_PKCS11_BYPASS
endif
+
+# Nix specific stuff.
+DEFINES += -DNIX_NSS_LIBDIR=\"$(out)/lib/\"
diff -ru -x '*~' nss-3.27.1-orig/nss/lib/pk11wrap/pk11load.c nss-3.27.1/nss/lib/pk11wrap/pk11load.c
--- nss-3.27.1-orig/nss/lib/pk11wrap/pk11load.c 2016-10-03 16:55:58.000000000 +0200
+++ nss-3.27.1/nss/lib/pk11wrap/pk11load.c 2016-11-15 16:28:07.308117900 +0100
@@ -429,6 +429,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,
+ (PRFuncPtr) &softoken_LoadDSO,
+ mod->dllName);
+ }
+
mod->library = (void *)library;
if (library == NULL) {
diff -ru -x '*~' nss-3.27.1-orig/nss/lib/util/secload.c nss-3.27.1/nss/lib/util/secload.c
--- nss-3.27.1-orig/nss/lib/util/secload.c 2016-10-03 16:55:58.000000000 +0200
+++ nss-3.27.1/nss/lib/util/secload.c 2016-11-15 16:29:50.482259746 +0100
@@ -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]
+ * and program was called from $PATH. Hack to get libs from NIX_NSS_LIBDIR */
+ referencePath = NIX_NSS_LIBDIR;
+ c = (char*) &referencePath[sizeof(NIX_NSS_LIBDIR) - 1]; /* last / */
+ }
if (c) {
size_t referencePathSize = 1 + c - referencePath;
- fullName = (char*)PORT_Alloc(strlen(name) + referencePathSize + 1);
+ fullName = (char*) PORT_Alloc(strlen(name) + referencePathSize + 5);
if (fullName) {
memcpy(fullName, referencePath, referencePathSize);
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);
+ }
+ strcpy(fullName + referencePathSize, name);
dlh = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL
#ifdef PR_LD_ALT_SEARCH_PATH
/* 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);
}
}