-: 0:Source:g_exp_sec_context.c -: 0:Graph:/var/tsitkova/Sources/v10/trunk/src/lib/gssapi/mechglue/g_exp_sec_context.so.gcno -: 0:Data:/var/tsitkova/Sources/v10/trunk/src/lib/gssapi/mechglue/g_exp_sec_context.so.gcda -: 0:Runs:1069 -: 0:Programs:1 -: 1:/* #pragma ident "@(#)g_exp_sec_context.c 1.14 04/02/23 SMI" */ -: 2: -: 3:/* -: 4: * Copyright 1996 by Sun Microsystems, Inc. -: 5: * -: 6: * Permission to use, copy, modify, distribute, and sell this software -: 7: * and its documentation for any purpose is hereby granted without fee, -: 8: * provided that the above copyright notice appears in all copies and -: 9: * that both that copyright notice and this permission notice appear in -: 10: * supporting documentation, and that the name of Sun Microsystems not be used -: 11: * in advertising or publicity pertaining to distribution of the software -: 12: * without specific, written prior permission. Sun Microsystems makes no -: 13: * representations about the suitability of this software for any -: 14: * purpose. It is provided "as is" without express or implied warranty. -: 15: * -: 16: * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -: 17: * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -: 18: * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -: 19: * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -: 20: * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -: 21: * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -: 22: * PERFORMANCE OF THIS SOFTWARE. -: 23: */ -: 24: -: 25:/* -: 26: * glue routine for gss_export_sec_context -: 27: */ -: 28:#ifndef LEAN_CLIENT -: 29: -: 30:#include "mglueP.h" -: 31:#include -: 32:#include -: 33:#ifdef HAVE_STDLIB_H -: 34:#include -: 35:#endif -: 36:#include -: 37: -: 38:static OM_uint32 #####: 39:val_exp_sec_ctx_args( -: 40: OM_uint32 *minor_status, -: 41: gss_ctx_id_t *context_handle, -: 42: gss_buffer_t interprocess_token) -: 43:{ -: 44: -: 45: /* Initialize outputs. */ -: 46: #####: 47: if (minor_status != NULL) #####: 48: *minor_status = 0; -: 49: #####: 50: if (interprocess_token != GSS_C_NO_BUFFER) { #####: 51: interprocess_token->length = 0; #####: 52: interprocess_token->value = NULL; -: 53: } -: 54: -: 55: /* Validate arguments. */ -: 56: #####: 57: if (minor_status == NULL) #####: 58: return (GSS_S_CALL_INACCESSIBLE_WRITE); -: 59: #####: 60: if (context_handle == NULL || *context_handle == GSS_C_NO_CONTEXT) #####: 61: return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); -: 62: #####: 63: if (interprocess_token == GSS_C_NO_BUFFER) #####: 64: return (GSS_S_CALL_INACCESSIBLE_WRITE); -: 65: #####: 66: return (GSS_S_COMPLETE); -: 67:} -: 68: -: 69: -: 70:OM_uint32 KRB5_CALLCONV #####: 71:gss_export_sec_context(minor_status, -: 72: context_handle, -: 73: interprocess_token) -: 74: -: 75:OM_uint32 * minor_status; -: 76:gss_ctx_id_t * context_handle; -: 77:gss_buffer_t interprocess_token; -: 78: -: 79:{ -: 80: OM_uint32 status; -: 81: OM_uint32 length; -: 82: gss_union_ctx_id_t ctx; -: 83: gss_mechanism mech; -: 84: gss_buffer_desc token; -: 85: char *buf; -: 86: #####: 87: status = val_exp_sec_ctx_args(minor_status, -: 88: context_handle, interprocess_token); #####: 89: if (status != GSS_S_COMPLETE) #####: 90: return (status); -: 91: -: 92: /* -: 93: * select the approprate underlying mechanism routine and -: 94: * call it. -: 95: */ -: 96: #####: 97: ctx = (gss_union_ctx_id_t) *context_handle; #####: 98: mech = gssint_get_mechanism (ctx->mech_type); #####: 99: if (!mech) #####: 100: return GSS_S_BAD_MECH; #####: 101: if (!mech->gss_export_sec_context) #####: 102: return (GSS_S_UNAVAILABLE); -: 103: #####: 104: status = mech->gss_export_sec_context(minor_status, -: 105: &ctx->internal_ctx_id, &token); #####: 106: if (status != GSS_S_COMPLETE) { #####: 107: map_error(minor_status, mech); #####: 108: return (status); -: 109: } -: 110: #####: 111: length = token.length + 4 + ctx->mech_type->length; #####: 112: interprocess_token->length = length; #####: 113: interprocess_token->value = malloc(length); #####: 114: if (interprocess_token->value == 0) { #####: 115: (void) gss_release_buffer(minor_status, &token); #####: 116: return (GSS_S_FAILURE); -: 117: } #####: 118: buf = interprocess_token->value; #####: 119: length = ctx->mech_type->length; #####: 120: buf[3] = (unsigned char) (length & 0xFF); #####: 121: length >>= 8; #####: 122: buf[2] = (unsigned char) (length & 0xFF); #####: 123: length >>= 8; #####: 124: buf[1] = (unsigned char) (length & 0xFF); #####: 125: length >>= 8; #####: 126: buf[0] = (unsigned char) (length & 0xFF); #####: 127: memcpy(buf+4, ctx->mech_type->elements, (size_t) ctx->mech_type->length); #####: 128: memcpy(buf+4+ctx->mech_type->length, token.value, token.length); -: 129: #####: 130: (void) gss_release_buffer(minor_status, &token); -: 131: #####: 132: free(ctx->mech_type->elements); #####: 133: free(ctx->mech_type); #####: 134: free(ctx); #####: 135: *context_handle = 0; -: 136: #####: 137: return(GSS_S_COMPLETE); -: 138:} -: 139:#endif /*LEAN_CLIENT */