From 733651ae26e4d340969941676fdd3021a1de16d2 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 12 Sep 2011 13:32:34 +1000 Subject: [PATCH] merge a few Win32 build fixes --- configure.ac | 2 ++ mech_eap/gssapiP_eap.h | 9 +++++++++ mech_eap/inquire_cred_by_oid.c | 9 +++++++-- mech_eap/set_sec_context_option.c | 10 ++++++++-- mech_eap/util.h | 35 +++++++++++++++++++++++++++++++++-- 5 files changed, 59 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index ccf5832..161b554 100644 --- a/configure.ac +++ b/configure.ac @@ -9,6 +9,8 @@ LT_INIT([dlopen disable-static]) AC_PROG_CC AC_PROG_CXX AC_CONFIG_HEADERS([config.h]) +AC_CHECK_HEADERS(stdarg.h stdio.h stdint.h sys/param.h) +AC_REPLACE_FUNCS(vasprintf) AC_GNU_SOURCE dnl Check if we're on Solaris and set CFLAGS accordingly diff --git a/mech_eap/gssapiP_eap.h b/mech_eap/gssapiP_eap.h index d62738f..4eaa664 100644 --- a/mech_eap/gssapiP_eap.h +++ b/mech_eap/gssapiP_eap.h @@ -42,11 +42,19 @@ #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_STDLIB_H #include +#endif +#ifdef HAVE_STDARG_H #include +#endif #include +#ifdef HAVE_SYS_PARAM_H #include +#endif /* GSS headers */ #include @@ -66,6 +74,7 @@ typedef const gss_OID_desc *gss_const_OID; #include /* EAP headers */ +#include #include #include #include diff --git a/mech_eap/inquire_cred_by_oid.c b/mech_eap/inquire_cred_by_oid.c index 3898f8c..2ad34ed 100644 --- a/mech_eap/inquire_cred_by_oid.c +++ b/mech_eap/inquire_cred_by_oid.c @@ -36,22 +36,25 @@ #include "gssapiP_eap.h" +#if 0 static struct { gss_OID_desc oid; OM_uint32 (*inquire)(OM_uint32 *, const gss_cred_id_t, const gss_OID, gss_buffer_set_t *); } inquireCredOps[] = { }; +#endif OM_uint32 GSSAPI_CALLCONV gss_inquire_cred_by_oid(OM_uint32 *minor, const gss_cred_id_t cred_handle, - const gss_OID desired_object, + const gss_OID desired_object GSSEAP_UNUSED, gss_buffer_set_t *data_set) { OM_uint32 major; +#if 0 int i; - +#endif *data_set = GSS_C_NO_BUFFER_SET; if (cred_handle == GSS_C_NO_CREDENTIAL) { @@ -64,6 +67,7 @@ gss_inquire_cred_by_oid(OM_uint32 *minor, major = GSS_S_UNAVAILABLE; *minor = GSSEAP_BAD_CRED_OPTION; +#if 0 for (i = 0; i < sizeof(inquireCredOps) / sizeof(inquireCredOps[0]); i++) { if (oidEqual(&inquireCredOps[i].oid, desired_object)) { major = (*inquireCredOps[i].inquire)(minor, cred_handle, @@ -71,6 +75,7 @@ gss_inquire_cred_by_oid(OM_uint32 *minor, break; } } +#endif GSSEAP_MUTEX_UNLOCK(&cred_handle->mutex); diff --git a/mech_eap/set_sec_context_option.c b/mech_eap/set_sec_context_option.c index 118d2d2..f9fa3a6 100644 --- a/mech_eap/set_sec_context_option.c +++ b/mech_eap/set_sec_context_option.c @@ -36,22 +36,26 @@ #include "gssapiP_eap.h" +#if 0 static struct { gss_OID_desc oid; OM_uint32 (*setOption)(OM_uint32 *, gss_ctx_id_t *pCtx, const gss_OID, const gss_buffer_t); } setCtxOps[] = { }; +#endif OM_uint32 GSSAPI_CALLCONV gss_set_sec_context_option(OM_uint32 *minor, gss_ctx_id_t *pCtx, - const gss_OID desired_object, - const gss_buffer_t value) + const gss_OID desired_object GSSEAP_UNUSED, + const gss_buffer_t value GSSEAP_UNUSED) { OM_uint32 major; gss_ctx_id_t ctx; +#if 0 int i; +#endif major = GSS_S_UNAVAILABLE; *minor = GSSEAP_BAD_CONTEXT_OPTION; @@ -64,6 +68,7 @@ gss_set_sec_context_option(OM_uint32 *minor, if (ctx != GSS_C_NO_CONTEXT) GSSEAP_MUTEX_LOCK(&ctx->mutex); +#if 0 for (i = 0; i < sizeof(setCtxOps) / sizeof(setCtxOps[0]); i++) { if (oidEqual(&setCtxOps[i].oid, desired_object)) { major = (*setCtxOps[i].setOption)(minor, &ctx, @@ -71,6 +76,7 @@ gss_set_sec_context_option(OM_uint32 *minor, break; } } +#endif if (pCtx != NULL && *pCtx == NULL) *pCtx = ctx; diff --git a/mech_eap/util.h b/mech_eap/util.h index a27209f..04fa4b9 100644 --- a/mech_eap/util.h +++ b/mech_eap/util.h @@ -61,12 +61,22 @@ #ifndef _UTIL_H_ #define _UTIL_H_ 1 +#ifdef HAVE_SYS_PARAM_H #include +#endif +#ifdef HAVE_STDINT_H +#include +#endif #include #include #include +#ifdef WIN32 +#define inline __inline +#define snprintf _snprintf +#endif + #ifdef __cplusplus extern "C" { #endif @@ -75,7 +85,7 @@ extern "C" { #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) #endif -#if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +#if !defined(WIN32) && (!(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))) #define GSSEAP_UNUSED __attribute__ ((__unused__)) #else #define GSSEAP_UNUSED @@ -748,8 +758,13 @@ verifyTokenHeader(OM_uint32 *minor, #define GSSAPI_CALLCONV KRB5_CALLCONV #endif +#ifdef WIN32 +#define GSSEAP_CONSTRUCTOR +#define GSSEAP_DESTRUCTOR +#else #define GSSEAP_CONSTRUCTOR __attribute__((constructor)) #define GSSEAP_DESTRUCTOR __attribute__((destructor)) +#endif #define GSSEAP_NOT_IMPLEMENTED do { \ assert(0 && "not implemented"); \ @@ -757,10 +772,24 @@ verifyTokenHeader(OM_uint32 *minor, return GSS_S_FAILURE; \ } while (0) +#ifdef WIN32 + +#include + +#define GSSEAP_MUTEX CRITICAL_SECTION + +#define GSSEAP_MUTEX_INIT(m) (InitializeCriticalSection((m)), 0) +#define GSSEAP_MUTEX_DESTROY(m) DeleteCriticalSection((m)) +#define GSSEAP_MUTEX_LOCK(m) EnterCriticalSection((m)) +#define GSSEAP_MUTEX_UNLOCK(m) LeaveCriticalSection((m)) + +/* XXX yet to implement thread-local wrappers */ + +#else + #include #define GSSEAP_MUTEX pthread_mutex_t -#define GSSEAP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER #define GSSEAP_MUTEX_INIT(m) pthread_mutex_init((m), NULL) #define GSSEAP_MUTEX_DESTROY(m) pthread_mutex_destroy((m)) @@ -776,6 +805,8 @@ verifyTokenHeader(OM_uint32 *minor, #define GSSEAP_ONCE(o, i) pthread_once((o), (i)) #define GSSEAP_ONCE_INITIALIZER PTHREAD_ONCE_INIT +#endif /* WIN32 */ + /* Helper functions */ static inline void store_uint16_be(uint16_t val, void *vp) -- 2.1.4