diff options
Diffstat (limited to 'lib/dns/gssapictx.c')
| -rw-r--r-- | lib/dns/gssapictx.c | 40 | 
1 files changed, 28 insertions, 12 deletions
diff --git a/lib/dns/gssapictx.c b/lib/dns/gssapictx.c index a8c5900e6d14a..d4209d378a76e 100644 --- a/lib/dns/gssapictx.c +++ b/lib/dns/gssapictx.c @@ -1,5 +1,5 @@  /* - * Copyright (C) 2004-2012  Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2013  Internet Systems Consortium, Inc. ("ISC")   * Copyright (C) 2000, 2001  Internet Software Consortium.   *   * Permission to use, copy, modify, and/or distribute this software for any @@ -68,8 +68,12 @@   * always use one.  If we're not using our own SPNEGO implementation,   * we include SPNEGO's OID.   */ -#if defined(GSSAPI) +#ifdef GSSAPI +#ifdef WIN32 +#include <krb5/krb5.h> +#else  #include ISC_PLATFORM_KRB5HEADER +#endif  static unsigned char krb5_mech_oid_bytes[] = {  	0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x01, 0x02, 0x02 @@ -103,7 +107,7 @@ static gss_OID_set_desc mech_oid_set = {  #define GBUFFER_TO_REGION(gb, r) \  	do { \ -		(r).length = (gb).length; \ +	  (r).length = (unsigned int)(gb).length; \  		(r).base = (gb).value; \  	} while (0) @@ -252,12 +256,12 @@ dst_gssapi_acquirecred(dns_name_t *name, isc_boolean_t initiate,  		       gss_cred_id_t *cred)  {  #ifdef GSSAPI +	isc_result_t result;  	isc_buffer_t namebuf;  	gss_name_t gname;  	gss_buffer_desc gnamebuf;  	unsigned char array[DNS_NAME_MAXTEXT + 1];  	OM_uint32 gret, minor; -	gss_OID_set mechs;  	OM_uint32 lifetime;  	gss_cred_usage_t usage;  	char buf[1024]; @@ -304,16 +308,17 @@ dst_gssapi_acquirecred(dns_name_t *name, isc_boolean_t initiate,  		usage = GSS_C_ACCEPT;  	gret = gss_acquire_cred(&minor, gname, GSS_C_INDEFINITE, -				&mech_oid_set, -				usage, cred, &mechs, &lifetime); +				&mech_oid_set, usage, cred, NULL, &lifetime);  	if (gret != GSS_S_COMPLETE) {  		gss_log(3, "failed to acquire %s credentials for %s: %s",  			initiate ? "initiate" : "accept",  			(gname != NULL) ? (char *)gnamebuf.value : "?",  			gss_error_tostring(gret, minor, buf, sizeof(buf))); -		check_config((char *)array); -		return (ISC_R_FAILURE); +		if (gname != NULL) +			check_config((char *)array); +		result = ISC_R_FAILURE; +		goto cleanup;  	}  	gss_log(4, "acquired %s credentials for %s", @@ -321,8 +326,18 @@ dst_gssapi_acquirecred(dns_name_t *name, isc_boolean_t initiate,  		(gname != NULL) ? (char *)gnamebuf.value : "?");  	log_cred(*cred); +	result = ISC_R_SUCCESS; -	return (ISC_R_SUCCESS); +cleanup: +	if (gname != NULL) { +		gret = gss_release_name(&minor, &gname); +		if (gret != GSS_S_COMPLETE) +			gss_log(3, "failed gss_release_name: %s", +				gss_error_tostring(gret, minor, buf, +						   sizeof(buf))); +	} + +	return (result);  #else  	REQUIRE(cred != NULL && *cred == NULL); @@ -620,7 +635,6 @@ dst_gssapi_initctx(dns_name_t *name, isc_buffer_t *intoken,  		RETERR(isc_buffer_copyregion(outtoken, &r));  		(void)gss_release_buffer(&minor, &gouttoken);  	} -	(void)gss_release_name(&minor, &gname);  	if (gret == GSS_S_COMPLETE)  		result = ISC_R_SUCCESS; @@ -628,6 +642,7 @@ dst_gssapi_initctx(dns_name_t *name, isc_buffer_t *intoken,  		result = DNS_R_CONTINUE;   out: +	(void)gss_release_name(&minor, &gname);  	return (result);  #else  	UNUSED(name); @@ -669,7 +684,7 @@ dst_gssapi_acceptctx(gss_cred_id_t cred,  		context = *ctxout;  	if (gssapi_keytab != NULL) { -#ifdef ISC_PLATFORM_GSSAPI_KRB5_HEADER +#if defined(ISC_PLATFORM_GSSAPI_KRB5_HEADER) || defined(WIN32)  		gret = gsskrb5_register_acceptor_identity(gssapi_keytab);  		if (gret != GSS_S_COMPLETE) {  			gss_log(3, "failed " @@ -730,7 +745,8 @@ dst_gssapi_acceptctx(gss_cred_id_t cred,  	}  	if (gouttoken.length > 0U) { -		RETERR(isc_buffer_allocate(mctx, outtoken, gouttoken.length)); +		RETERR(isc_buffer_allocate(mctx, outtoken, +					   (unsigned int)gouttoken.length));  		GBUFFER_TO_REGION(gouttoken, r);  		RETERR(isc_buffer_copyregion(*outtoken, &r));  		(void)gss_release_buffer(&minor, &gouttoken);  | 
