/* vim:set ts=4 sw=2 sts=2 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// We define GSS_C_NT_HOSTBASED_SERVICE explicitly since it may be referenced // by by a different name depending on the implementation of gss but always // has the same value
if (!libPath.IsEmpty()) {
LOG(("Attempting to load user specified library [%s]\n", libPath.get()));
gssNativeImp = false; #ifdef XP_WIN
lib = LoadLibraryWithFlags(libPathU.get()); #else
lib = LoadLibraryWithFlags(libPath.get()); #endif
} else { #ifdef XP_WIN # ifdef _WIN64
constexpr auto kLibName = u"gssapi64.dll"_ns; # else
constexpr auto kLibName = u"gssapi32.dll"_ns; # endif
lib = LoadLibraryWithFlags(kLibName.get()); #elifdefined(__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.
*/
for (size_t i = 0; i < std::size(verLibNames) && !lib; ++i) {
lib = PR_LoadLibrary(verLibNames[i]);
/* The CITI libgssapi library calls exit() during * initialization if it's not correctly configured. Try to * ensure that we never use this library for our GSSAPI * support, as its just a wrapper library, anyway. * See Bugzilla #325433
*/ if (lib && PR_FindFunctionSymbol(lib, "internal_krb5_gss_initialize") &&
PR_FindFunctionSymbol(lib, "gssd_pname_to_uid")) {
LOG(("CITI libgssapi found, which calls exit(). Skipping\n"));
PR_UnloadLibrary(lib);
lib = nullptr;
}
}
for (size_t i = 0; i < std::size(libNames) && !lib; ++i) { char* libName = PR_GetLibraryName(nullptr, libNames[i]); if (libName) {
lib = PR_LoadLibrary(libName);
PR_FreeLibraryName(libName);
if (!lib) {
LOG(("Fail to load gssapi library\n")); return NS_ERROR_FAILURE;
}
LOG(("Attempting to load gss functions\n"));
for (auto& gssFunc : gssFuncs) {
gssFunc.func = PR_FindFunctionSymbol(lib, gssFunc.str); if (!gssFunc.func) {
LOG(("Fail to load %s function from gssapi library\n", gssFunc.str));
PR_UnloadLibrary(lib); return NS_ERROR_FAILURE;
}
} #ifdef XP_MACOSX if (gssNativeImp && !(KLCacheHasValidTicketsPtr = PR_FindFunctionSymbol(
lib, "KLCacheHasValidTickets"))) {
LOG(("Fail to load KLCacheHasValidTickets function from gssapi library\n"));
PR_UnloadLibrary(lib); return NS_ERROR_FAILURE;
} #endif
gssLibrary = lib; return NS_OK;
}
// Generate proper GSSAPI error messages from the major and // minor status codes. void LogGssError(OM_uint32 maj_stat, OM_uint32 min_stat, constchar* prefix) { if (!MOZ_LOG_TEST(gNegotiateLog, LogLevel::Debug)) { return;
}
// if the type is kerberos we accept it as default // and exit
if (package == PACKAGE_TYPE_KERBEROS) return;
// Now, look at the list of supported mechanisms, // if SPNEGO is found, then use it. // Otherwise, set the desired mechanism to // GSS_C_NO_OID and let the system try to use // the default mechanism. // // Using Kerberos directly (instead of negotiating // with SPNEGO) may work in some cases depending // on how smart the server side is.
majstat = gss_indicate_mechs_ptr(&minstat, &mech_set); if (GSS_ERROR(majstat)) return;
if (mech_set) { for (i = 0; i < mech_set->count; i++) {
item = &mech_set->elements[i]; if (item->length == gss_spnego_mech_oid_desc.length &&
!memcmp(item->elements, gss_spnego_mech_oid_desc.elements,
item->length)) { // ok, we found it
mMechOID = &gss_spnego_mech_oid_desc; break;
}
}
gss_release_oid_set_ptr(&minstat, &mech_set);
}
}
if (inToken) {
input_token.length = inTokenLen;
input_token.value = (void*)inToken;
in_token_ptr = &input_token;
} elseif (mCtx != GSS_C_NO_CONTEXT) { // If there is no input token, then we are starting a new // authentication sequence. If we have already initialized our // security context, then we're in trouble because it means that the // first sequence failed. We need to bail or else we might end up in // an infinite loop.
LOG(("Cannot restart authentication sequence!")); return NS_ERROR_UNEXPECTED;
}
#ifdefined(XP_MACOSX) // Suppress Kerberos prompts to get credentials. See bug 240643. // We can only use Mac OS X specific kerb functions if we are using // the native lib
KLBoolean found; bool doingMailTask = mServiceName.Find("imap@") ||
mServiceName.Find("pop@") ||
mServiceName.Find("smtp@") || mServiceName.Find("ldap@");
if (GSS_ERROR(major_status)) {
LogGssError(major_status, minor_status, "gss_init_sec_context() failed");
Reset();
rv = NS_ERROR_FAILURE; goto end;
} if (major_status == GSS_S_COMPLETE) { // Mark ourselves as being complete, so that if we're called again // we know to start afresh.
mComplete = true;
} elseif (major_status == GSS_S_CONTINUE_NEEDED) { // // The important thing is that we do NOT reset the // context here because it will be needed on the // next call. //
}
/* it is not possible for output_token.length to be zero */
*outToken = moz_xmemdup(output_token.value, output_token.length);
gss_release_buffer_ptr(&minor_status, &output_token);
return NS_OK;
}
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.