Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsAuthGSSAPI.cpp File Reference
#include "prlink.h"
#include "nsCOMPtr.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIServiceManager.h"
#include "nsNativeCharsetUtils.h"
#include "nsAuthGSSAPI.h"

Go to the source code of this file.

Defines

#define gssFuncItems   NS_ARRAY_LENGTH(gssFuncStr)
#define gss_display_status_ptr   ((gss_display_status_type)*gssFunPtr[0])
#define gss_init_sec_context_ptr   ((gss_init_sec_context_type)*gssFunPtr[1])
#define gss_indicate_mechs_ptr   ((gss_indicate_mechs_type)*gssFunPtr[2])
#define gss_release_oid_set_ptr   ((gss_release_oid_set_type)*gssFunPtr[3])
#define gss_delete_sec_context_ptr   ((gss_delete_sec_context_type)*gssFunPtr[4])
#define gss_import_name_ptr   ((gss_import_name_type)*gssFunPtr[5])
#define gss_release_buffer_ptr   ((gss_release_buffer_type)*gssFunPtr[6])
#define gss_release_name_ptr   ((gss_release_name_type)*gssFunPtr[7])
#define gss_wrap_ptr   ((gss_wrap_type)*gssFunPtr[8])
#define gss_unwrap_ptr   ((gss_unwrap_type)*gssFunPtr[9])
#define LogGssError(x, y, z)

Functions

static nsresult gssInit ()

Variables

static gss_OID_desc gss_c_nt_hostbased_service
static const char kNegotiateAuthGssLib [] = "network.negotiate-auth.gsslib"
static const char kNegotiateAuthNativeImp [] = "network.negotiate-auth.using-native-gsslib"
static const char * gssFuncStr []
static PRFuncPtr gssFunPtr [gssFuncItems]
static PRBool gssNativeImp = PR_TRUE
static PRBool gssFunInit = PR_FALSE

Define Documentation

Definition at line 112 of file nsAuthGSSAPI.cpp.

Definition at line 108 of file nsAuthGSSAPI.cpp.

Definition at line 113 of file nsAuthGSSAPI.cpp.

Definition at line 110 of file nsAuthGSSAPI.cpp.

Definition at line 109 of file nsAuthGSSAPI.cpp.

Definition at line 114 of file nsAuthGSSAPI.cpp.

Definition at line 115 of file nsAuthGSSAPI.cpp.

Definition at line 111 of file nsAuthGSSAPI.cpp.

#define gss_unwrap_ptr   ((gss_unwrap_type)*gssFunPtr[9])

Definition at line 117 of file nsAuthGSSAPI.cpp.

#define gss_wrap_ptr   ((gss_wrap_type)*gssFunPtr[8])

Definition at line 116 of file nsAuthGSSAPI.cpp.

Definition at line 102 of file nsAuthGSSAPI.cpp.

#define LogGssError (   x,
  y,
 
)

Definition at line 275 of file nsAuthGSSAPI.cpp.


Function Documentation

static nsresult gssInit ( ) [static]

Definition at line 126 of file nsAuthGSSAPI.cpp.

{
    nsXPIDLCString libPath;
    nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
    if (prefs) {
        prefs->GetCharPref(kNegotiateAuthGssLib, getter_Copies(libPath)); 
        prefs->GetBoolPref(kNegotiateAuthNativeImp, &gssNativeImp); 
    }

    PRLibrary *lib = NULL;

    if (!libPath.IsEmpty()) {
        LOG(("Attempting to load user specified library [%s]\n", libPath.get()));
        gssNativeImp = PR_FALSE;
        lib = PR_LoadLibrary(libPath.get());
    }
    else {
#ifdef XP_WIN
        char *libName = PR_GetLibraryName(NULL, "gssapi32");
        if (libName) {
            lib = PR_LoadLibrary("gssapi32");
            PR_FreeLibraryName(libName);
        }
#else
        
        const char *const libNames[] = {
            "gss",
            "gssapi_krb5",
            "gssapi"
        };
        
        const char *const verLibNames[] = {
            "libgssapi_krb5.so.2", /* MIT - FC, Suse10, Debian */
            "libgssapi.so.4",      /* Heimdal - Suse10, MDK */
            "libgssapi.so.1"       /* Heimdal - Suse9, CITI - FC, MDK, Suse10*/
        };

        for (size_t i = 0; i < NS_ARRAY_LENGTH(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 = NULL;
            }
        }

        for (size_t i = 0; i < NS_ARRAY_LENGTH(libNames) && !lib; ++i) {
            char *libName = PR_GetLibraryName(NULL, libNames[i]);
            if (libName) {
                lib = PR_LoadLibrary(libName);
                PR_FreeLibraryName(libName);

                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 = NULL;
                } 
            }
        }
#endif
    }
    
    if (!lib) {
        LOG(("Fail to load gssapi library\n"));
        return NS_ERROR_FAILURE;
    }

    LOG(("Attempting to load gss functions\n"));

    for (size_t i = 0; i < gssFuncItems; ++i) {
        gssFunPtr[i] = PR_FindFunctionSymbol(lib, gssFuncStr[i]);
        if (!gssFunPtr[i]) {
            LOG(("Fail to load %s function from gssapi library\n", gssFuncStr[i]));
            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

    gssFunInit = PR_TRUE;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
 
    { 10, (void *) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04" }

Definition at line 81 of file nsAuthGSSAPI.cpp.

const char* gssFuncStr[] [static]
Initial value:
 {
    "gss_display_status", 
    "gss_init_sec_context", 
    "gss_indicate_mechs",
    "gss_release_oid_set",
    "gss_delete_sec_context",
    "gss_import_name",
    "gss_release_buffer",
    "gss_release_name",
    "gss_wrap",
    "gss_unwrap"
}

Definition at line 89 of file nsAuthGSSAPI.cpp.

Definition at line 106 of file nsAuthGSSAPI.cpp.

Definition at line 104 of file nsAuthGSSAPI.cpp.

Definition at line 105 of file nsAuthGSSAPI.cpp.

const char kNegotiateAuthGssLib[] = "network.negotiate-auth.gsslib" [static]

Definition at line 84 of file nsAuthGSSAPI.cpp.

const char kNegotiateAuthNativeImp[] = "network.negotiate-auth.using-native-gsslib" [static]

Definition at line 86 of file nsAuthGSSAPI.cpp.