Bug 1442275 - Stop using PR_LoadLibrary in GSSAPI. r=mayhemer
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sun, 25 Feb 2018 01:32:37 +0900
changeset 472889 26a288cf0e0b871a95f0fa08cecb669fa32f776e
parent 472888 af62a7677b23df7ea16511744b0c5095d7efc5de
child 472890 54978536db3ea3892035a52a32ee691de8f7e708
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1442275
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1442275 - Stop using PR_LoadLibrary in GSSAPI. r=mayhemer MozReview-Commit-ID: 756qF1thw7A
extensions/auth/nsAuthGSSAPI.cpp
--- a/extensions/auth/nsAuthGSSAPI.cpp
+++ b/extensions/auth/nsAuthGSSAPI.cpp
@@ -12,23 +12,23 @@
 // Also described here:
 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsecure/html/http-sso-1.asp
 //
 //
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/IntegerPrintfMacros.h"
 
-#include "prlink.h"
 #include "nsCOMPtr.h"
 #include "nsIPrefService.h"
-#include "nsIPrefBranch.h"
 #include "nsIServiceManager.h"
 #include "nsMemory.h"
 #include "nsNativeCharsetUtils.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/SharedLibrary.h"
 #include "mozilla/Telemetry.h"
 
 #include "nsAuthGSSAPI.h"
 
 #ifdef XP_MACOSX
 #include <Kerberos/Kerberos.h>
 #endif
 
@@ -98,43 +98,46 @@ static PRLibrary* gssLibrary = nullptr;
 static PRFuncPtr KLCacheHasValidTicketsPtr;
 #define KLCacheHasValidTickets_ptr \
         ((KLCacheHasValidTickets_type)*KLCacheHasValidTicketsPtr)
 #endif
 
 static nsresult
 gssInit()
 {
+#ifdef XP_WIN
+    nsAutoString libPathU;
+    Preferences::GetString(kNegotiateAuthGssLib, libPathU);
+    NS_ConvertUTF16toUTF8 libPath(libPathU);
+#else
     nsAutoCString libPath;
-    nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
-    if (prefs) {
-        prefs->GetCharPref(kNegotiateAuthGssLib, libPath);
-        prefs->GetBoolPref(kNegotiateAuthNativeImp, &gssNativeImp);
-    }
+    Preferences::GetCString(kNegotiateAuthGssLib, libPath);
+#endif
+    gssNativeImp = Preferences::GetBool(kNegotiateAuthNativeImp);
 
     PRLibrary *lib = nullptr;
 
     if (!libPath.IsEmpty()) {
         LOG(("Attempting to load user specified library [%s]\n", libPath.get()));
         gssNativeImp = false;
-        lib = PR_LoadLibrary(libPath.get());
+#ifdef XP_WIN
+        lib = LoadLibraryWithFlags(libPathU.get());
+#else
+        lib = LoadLibraryWithFlags(libPath.get());
+#endif
     }
     else {
 #ifdef XP_WIN
         #ifdef _WIN64
-        static const char *kLibName = "gssapi64";
+        NS_NAMED_LITERAL_STRING(kLibName, "gssapi64.dll");
         #else
-        static const char *kLibName = "gssapi32";
+        NS_NAMED_LITERAL_STRING(kLibName, "gssapi32.dll");
         #endif
 
-        char *libName = PR_GetLibraryName(nullptr, kLibName);
-        if (libName) {
-            lib = PR_LoadLibrary(kLibName);
-            PR_FreeLibraryName(libName);
-        }
+        lib = LoadLibraryWithFlags(kLibName.get());
 #elif defined(__OpenBSD__)
         /* OpenBSD doesn't register inter-library dependencies in basesystem
          * libs therefor we need to load all the libraries gssapi depends on,
          * in the correct order and with LD_GLOBAL for GSSAPI auth to work
          * fine.
          */
 
         const char *const verLibNames[] = {