X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=moonshot%2Fmech_eap%2Futil_cred.c;h=11dcfeb71a384979d73ae55a04d3f1eeba7b0805;hb=55de26d432636a95fb0dc025fa77f8bda6aca71a;hp=4c8c8c7ec7b3c93536608e4e2bed8fbb8480a2f3;hpb=410bcd9d406a112740e5db4a73d788d66c8b62bc;p=moonshot.git diff --git a/moonshot/mech_eap/util_cred.c b/moonshot/mech_eap/util_cred.c index 4c8c8c7..11dcfeb 100644 --- a/moonshot/mech_eap/util_cred.c +++ b/moonshot/mech_eap/util_cred.c @@ -36,7 +36,11 @@ #include "gssapiP_eap.h" +#ifdef WIN32 +#include +#else #include +#endif OM_uint32 gssEapAllocCred(OM_uint32 *minor, gss_cred_id_t *pCred) @@ -53,7 +57,7 @@ gssEapAllocCred(OM_uint32 *minor, gss_cred_id_t *pCred) } if (GSSEAP_MUTEX_INIT(&cred->mutex) != 0) { - *minor = errno; + *minor = GSSEAP_GET_LAST_ERROR(); gssEapReleaseCred(&tmpMinor, &cred); return GSS_S_FAILURE; } @@ -127,10 +131,13 @@ readStaticIdentityFile(OM_uint32 *minor, { OM_uint32 major, tmpMinor; FILE *fp = NULL; - char pwbuf[BUFSIZ], buf[BUFSIZ]; + char buf[BUFSIZ]; char *ccacheName; - struct passwd *pw = NULL, pwd; int i = 0; +#ifndef WIN32 + struct passwd *pw = NULL, pwd; + char pwbuf[BUFSIZ]; +#endif defaultIdentity->length = 0; defaultIdentity->value = NULL; @@ -142,14 +149,30 @@ readStaticIdentityFile(OM_uint32 *minor, ccacheName = getenv("GSSEAP_IDENTITY"); if (ccacheName == NULL) { +#ifdef WIN32 + TCHAR szPath[MAX_PATH]; + + if (!SUCCEEDED(SHGetFolderPath(NULL, + CSIDL_APPDATA, /* |CSIDL_FLAG_CREATE */ + NULL, /* User access token */ + 0, + szPath))) { + major = GSS_S_CRED_UNAVAIL; + *minor = GetLastError(); + goto cleanup; + } + + snprintf(buf, sizeof(buf), "%s/.gss_eap_id", szPath); +#else if (getpwuid_r(getuid(), &pwd, pwbuf, sizeof(pwbuf), &pw) != 0 || pw == NULL || pw->pw_dir == NULL) { major = GSS_S_CRED_UNAVAIL; - *minor = errno; + *minor = GSSEAP_GET_LAST_ERROR(); goto cleanup; } snprintf(buf, sizeof(buf), "%s/.gss_eap_id", pw->pw_dir); +#endif /* WIN32 */ ccacheName = buf; }