1diff -ru nss-3.16-orig/nss/cmd/shlibsign/shlibsign.c nss-3.16/nss/cmd/shlibsign/shlibsign.c
2--- nss-3.16-orig/nss/cmd/shlibsign/shlibsign.c 2014-03-14 21:31:59.000000000 +0100
3+++ nss-3.16/nss/cmd/shlibsign/shlibsign.c 2014-04-22 14:50:31.340743655 +0200
4@@ -852,6 +852,8 @@
5 libname = PR_GetLibraryName(NULL, "softokn3");
6 assert(libname != NULL);
7 lib = PR_LoadLibrary(libname);
8+ if (!lib)
9+ lib = PR_LoadLibrary(NIX_NSS_LIBDIR"libsoftokn3.so");
10 assert(lib != NULL);
11 PR_FreeLibraryName(libname);
12
13Only in nss-3.16/nss/cmd/shlibsign: shlibsign.c.orig
14diff -ru nss-3.16-orig/nss/coreconf/config.mk nss-3.16/nss/coreconf/config.mk
15--- nss-3.16-orig/nss/coreconf/config.mk 2014-03-14 21:31:59.000000000 +0100
16+++ nss-3.16/nss/coreconf/config.mk 2014-04-22 14:50:51.302731097 +0200
17@@ -188,3 +188,6 @@
18
19 # Hide old, deprecated, TLS cipher suite names when building NSS
20 DEFINES += -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES
21+
22+# Nix specific stuff.
23+DEFINES += -DNIX_NSS_LIBDIR=\"$(out)/lib/\"
24diff -ru nss-3.16-orig/nss/lib/pk11wrap/pk11load.c nss-3.16/nss/lib/pk11wrap/pk11load.c
25--- nss-3.16-orig/nss/lib/pk11wrap/pk11load.c 2014-03-14 21:31:59.000000000 +0100
26+++ nss-3.16/nss/lib/pk11wrap/pk11load.c 2014-04-22 14:50:22.164749330 +0200
27@@ -406,6 +406,13 @@
28 * unload the library if anything goes wrong from here on out...
29 */
30 library = PR_LoadLibrary(mod->dllName);
31+ if ((library == NULL) &&
32+ !rindex(mod->dllName, PR_GetDirectorySeparator())) {
33+ library = PORT_LoadLibraryFromOrigin(my_shlib_name,
34+ (PRFuncPtr) &softoken_LoadDSO,
35+ mod->dllName);
36+ }
37+
38 mod->library = (void *)library;
39
40 if (library == NULL) {
41diff -ru nss-3.16-orig/nss/lib/util/secload.c nss-3.16/nss/lib/util/secload.c
42--- nss-3.16-orig/nss/lib/util/secload.c 2014-03-14 21:31:59.000000000 +0100
43+++ nss-3.16/nss/lib/util/secload.c 2014-04-22 14:50:31.342743654 +0200
44@@ -69,9 +69,14 @@
45
46 /* Remove the trailing filename from referencePath and add the new one */
47 c = strrchr(referencePath, PR_GetDirectorySeparator());
48+ if (!c) { /* referencePath doesn't contain a / means that dladdr gave us argv[0]
49+ * and program was called from $PATH. Hack to get libs from NIX_NSS_LIBDIR */
50+ referencePath = NIX_NSS_LIBDIR;
51+ c = &referencePath[sizeof(NIX_NSS_LIBDIR) - 1]; /* last / */
52+ }
53 if (c) {
54 size_t referencePathSize = 1 + c - referencePath;
55- fullName = (char*) PORT_Alloc(strlen(name) + referencePathSize + 1);
56+ fullName = (char*) PORT_Alloc(strlen(name) + referencePathSize + 5);
57 if (fullName) {
58 memcpy(fullName, referencePath, referencePathSize);
59 strcpy(fullName + referencePathSize, name);
60@@ -81,6 +86,11 @@
61 #endif
62 libSpec.type = PR_LibSpec_Pathname;
63 libSpec.value.pathname = fullName;
64+ if ((referencePathSize >= 4) &&
65+ (strncmp(fullName + referencePathSize - 4, "bin", 3) == 0)) {
66+ memcpy(fullName + referencePathSize -4, "lib", 3);
67+ }
68+ strcpy(fullName + referencePathSize, name);
69 dlh = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL
70 #ifdef PR_LD_ALT_SEARCH_PATH
71 /* allow library's dependencies to be found in the same directory
72@@ -88,6 +98,10 @@
73 | PR_LD_ALT_SEARCH_PATH
74 #endif
75 );
76+ if (! dlh) {
77+ strcpy(fullName + referencePathSize, name);
78+ dlh = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL);
79+ }
80 PORT_Free(fullName);
81 }
82 }