about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/nss/85_security_load_3.85+.patch
blob: bc3f48e66744936dd3b8e36644b7b7b739e38671 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
diff --git nss/cmd/shlibsign/shlibsign.c nss/cmd/shlibsign/shlibsign.c
index ad8f3b84e..74676d039 100644
--- nss/cmd/shlibsign/shlibsign.c
+++ nss/cmd/shlibsign/shlibsign.c
@@ -875,6 +875,8 @@ main(int argc, char **argv)
         goto cleanup;
     }
     lib = PR_LoadLibrary(libname);
+    if (!lib)
+        lib = PR_LoadLibrary(NIX_NSS_LIBDIR"libsoftokn3.so");
     assert(lib != NULL);
     if (!lib) {
         PR_fprintf(PR_STDERR, "loading softokn3 failed");
diff --git nss/lib/pk11wrap/pk11load.c nss/lib/pk11wrap/pk11load.c
index 119c8c512..720d39ccc 100644
--- nss/lib/pk11wrap/pk11load.c
+++ nss/lib/pk11wrap/pk11load.c
@@ -486,6 +486,15 @@ secmod_LoadPKCS11Module(SECMODModule *mod, SECMODModule **oldModule)
 #else
         library = PR_LoadLibrary(mod->dllName);
 #endif // defined(_WIN32)
+#ifndef NSS_STATIC_SOFTOKEN
+        if ((library == NULL) &&
+            !rindex(mod->dllName, PR_GetDirectorySeparator())) {
+            library = PORT_LoadLibraryFromOrigin(my_shlib_name,
+                (PRFuncPtr) &softoken_LoadDSO,
+                mod->dllName);
+        }
+#endif
+
         mod->library = (void *)library;
 
         if (library == NULL) {
diff --git nss/lib/util/secload.c nss/lib/util/secload.c
index 1cebae4e2..9194bb761 100644
--- nss/lib/util/secload.c
+++ nss/lib/util/secload.c
@@ -70,9 +70,14 @@ loader_LoadLibInReferenceDir(const char* referencePath, const char* name)
 
     /* 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 @@ loader_LoadLibInReferenceDir(const char* referencePath, const char* name)
 #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 @@ loader_LoadLibInReferenceDir(const char* referencePath, const char* name)
                                                        | 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);
         }
     }