1 /* 2 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 #pragma ident "%Z%%M% %I% %E% SMI" 7 8 /* 9 * Copyright 1993 by OpenVision Technologies, Inc. 10 * 11 * Permission to use, copy, modify, distribute, and sell this software 12 * and its documentation for any purpose is hereby granted without fee, 13 * provided that the above copyright notice appears in all copies and 14 * that both that copyright notice and this permission notice appear in 15 * supporting documentation, and that the name of OpenVision not be used 16 * in advertising or publicity pertaining to distribution of the software 17 * without specific, written prior permission. OpenVision makes no 18 * representations about the suitability of this software for any 19 * purpose. It is provided "as is" without express or implied warranty. 20 * 21 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 22 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 23 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR 24 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 25 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 26 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 27 * PERFORMANCE OF THIS SOFTWARE. 28 */ 29 30 #include <gssapiP_krb5.h> 31 32 /* 33 * $Id: process_context_token.c,v 1.10 1996/07/22 20:34:23 marc Exp $ 34 */ 35 36 OM_uint32 37 krb5_gss_process_context_token(ct, minor_status, context_handle, 38 token_buffer) 39 void *ct; 40 OM_uint32 *minor_status; 41 gss_ctx_id_t context_handle; 42 gss_buffer_t token_buffer; 43 { 44 krb5_context context; 45 krb5_gss_ctx_id_rec *ctx; 46 OM_uint32 majerr; 47 48 /* Solaris Kerberos: for MT safety, we avoid the use of a default 49 * context via kg_get_context() */ 50 #if 0 51 if (GSS_ERROR(kg_get_context(minor_status, &context))) 52 return(GSS_S_FAILURE); 53 #endif 54 55 mutex_lock(&krb5_mutex); 56 context = ct; 57 58 /* validate the context handle */ 59 if (! kg_validate_ctx_id(context_handle)) { 60 *minor_status = (OM_uint32) G_VALIDATE_FAILED; 61 mutex_unlock(&krb5_mutex); 62 return(GSS_S_NO_CONTEXT); 63 } 64 65 ctx = (krb5_gss_ctx_id_rec *) context_handle; 66 67 if (! ctx->established) { 68 *minor_status = KG_CTX_INCOMPLETE; 69 mutex_unlock(&krb5_mutex); 70 return(GSS_S_NO_CONTEXT); 71 } 72 73 /* "unseal" the token */ 74 75 if (GSS_ERROR(majerr = kg_unseal(context, minor_status, (gss_ctx_id_t)ctx, 76 token_buffer, 77 GSS_C_NO_BUFFER, NULL, NULL, 78 KG_TOK_DEL_CTX))) { 79 mutex_unlock(&krb5_mutex); 80 return(majerr); 81 } 82 83 /* that's it. delete the context */ 84 majerr = krb5_gss_delete_sec_context_no_lock(context, minor_status, 85 &context_handle, GSS_C_NO_BUFFER); 86 87 mutex_unlock(&krb5_mutex); 88 return(majerr); 89 } 90