call gssEapCanonicalizeOid, gssEapInternalizeOid is no longer public
[mech_eap.orig] / util_cred.c
index c74cd24..a2a01ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, JANET(UK)
+ * Copyright (c) 2011, JANET(UK)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -111,7 +111,7 @@ OM_uint32
 gssEapAcquireCred(OM_uint32 *minor,
                   const gss_name_t desiredName,
                   const gss_buffer_t password,
-                  OM_uint32 timeReq,
+                  OM_uint32 timeReq GSSEAP_UNUSED,
                   const gss_OID_set desiredMechs,
                   int credUsage,
                   gss_cred_id_t *pCred,
@@ -120,6 +120,9 @@ gssEapAcquireCred(OM_uint32 *minor,
 {
     OM_uint32 major, tmpMinor;
     gss_cred_id_t cred;
+#ifdef GSSEAP_DEBUG
+    gss_buffer_desc envPassword;
+#endif
 
     /* XXX TODO validate with changed set_cred_option API */
     *pCred = GSS_C_NO_CREDENTIAL;
@@ -181,7 +184,13 @@ gssEapAcquireCred(OM_uint32 *minor,
         }
 
         if (nameBuf.length != 0) {
-            major = gssEapImportName(minor, &nameBuf, nameType, &cred->name);
+            gss_OID mech = GSS_C_NO_OID;
+
+            if (cred->mechanisms != GSS_C_NO_OID_SET &&
+                cred->mechanisms->count == 1)
+                mech = &cred->mechanisms->elements[0];
+
+            major = gssEapImportName(minor, &nameBuf, nameType, mech, &cred->name);
             if (GSS_ERROR(major))
                 goto cleanup;
         }
@@ -189,6 +198,15 @@ gssEapAcquireCred(OM_uint32 *minor,
         cred->flags |= CRED_FLAG_DEFAULT_IDENTITY;
     }
 
+#ifdef GSSEAP_DEBUG
+    if (password == GSS_C_NO_BUFFER &&
+        (envPassword.value = getenv("GSSEAP_CREDS")) != NULL) {
+        envPassword.length = strlen((char *)envPassword.value);
+        major = duplicateBuffer(minor, &envPassword, &cred->password);
+        if (GSS_ERROR(major))
+            goto cleanup;
+    } else
+#endif /* GSSEAP_DEBUG */
     if (password != GSS_C_NO_BUFFER) {
         major = duplicateBuffer(minor, password, &cred->password);
         if (GSS_ERROR(major))