Bug 1627911 - Try loading GPGME library from /usr/local/lib or /opt/local/lib. r=kaie a=wsmwk
authorKai Engert <kaie@kuix.de>
Tue, 09 Jun 2020 10:27:53 +0200
changeset 39398 a894f36fc41ae6e5c067ed699ebf71b612e2d46e
parent 39397 2f809d3fe53bb2fc7eed975af9560df429f8e72b
child 39399 4ecb5ad3fd50d02c80d97841f55d2bbb1ba91180
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
reviewerskaie, wsmwk
bugs1627911
Bug 1627911 - Try loading GPGME library from /usr/local/lib or /opt/local/lib. r=kaie a=wsmwk
mail/extensions/openpgp/content/modules/GPGMELib.jsm
--- a/mail/extensions/openpgp/content/modules/GPGMELib.jsm
+++ b/mail/extensions/openpgp/content/modules/GPGMELib.jsm
@@ -4,16 +4,19 @@
 
 const EXPORTED_SYMBOLS = ["GPGMELibLoader"];
 
 var { ctypes } = ChromeUtils.import("resource://gre/modules/ctypes.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
 var abi = ctypes.default_abi;
 
+// Default libary paths to look for on macOS
+const ADDITIONAL_LIB_PATHS = ["/usr/local/lib", "/opt/local/lib"];
+
 // Open libgpgme. Determine the path to the chrome directory and look for it
 // there first. If not, fallback to searching the standard locations.
 var libgpgme, libgpgmePath;
 
 function tryLoadGPGME(name, suffix) {
   let filename = ctypes.libraryName(name) + suffix;
   let binPath = Services.dirsvc.get("XpcomLib", Ci.nsIFile).path;
   let binDir = OS.Path.dirname(binPath);
@@ -30,16 +33,32 @@ function tryLoadGPGME(name, suffix) {
     try {
       loadFromInfo = "system's standard library locations";
       // look in standard locations
       libgpgmePath = filename;
       libgpgme = ctypes.open(libgpgmePath);
     } catch (e) {}
   }
 
+  if (!libgpgme && Services.appinfo.OS !== "WINNT") {
+    // try specific additional directories
+
+    for (let tryPath of ADDITIONAL_LIB_PATHS) {
+      try {
+        loadFromInfo = "additional standard locations";
+        libgpgmePath = tryPath + "/" + filename;
+        libgpgme = ctypes.open(libgpgmePath);
+
+        if (libgpgme) {
+          break;
+        }
+      } catch (e) {}
+    }
+  }
+
   if (libgpgme) {
     console.debug(
       "Successfully loaded OpenPGP library " +
         filename +
         " from " +
         loadFromInfo
     );
   }