Fixes for Heimdal (macOS) builds from Stefan.
[mech_eap.git] / mech_eap / acquire_cred_with_password.c
index 5904616..8e08358 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "gssapiP_eap.h"
 
-OM_uint32
+OM_uint32 GSSAPI_CALLCONV
 gssspi_acquire_cred_with_password(OM_uint32 *minor,
                                   const gss_name_t desired_name,
                                   const gss_buffer_t password,
@@ -47,14 +47,21 @@ gssspi_acquire_cred_with_password(OM_uint32 *minor,
                                   gss_OID_set *actual_mechs,
                                   OM_uint32 *time_rec)
 {
-    return gssEapAcquireCred(minor,
-                             desired_name,
-                             &gssEapPasswordCredType,
-                             password,
-                             time_req,
-                             desired_mechs,
-                             cred_usage,
-                             output_cred_handle,
-                             actual_mechs,
-                             time_rec);
+    OM_uint32 major, tmpMinor;
+
+    major = gssEapAcquireCred(minor, desired_name,
+                              time_req, desired_mechs, cred_usage,
+                              output_cred_handle, actual_mechs, time_rec);
+    if (GSS_ERROR(major))
+        goto cleanup;
+
+    major = gssEapSetCredPassword(minor, *output_cred_handle, password);
+    if (GSS_ERROR(major))
+        goto cleanup;
+
+cleanup:
+    if (GSS_ERROR(major))
+        gssEapReleaseCred(&tmpMinor, output_cred_handle);
+
+    return major;
 }