Path: blob/main/crypto/heimdal/lib/gssapi/krb5/inquire_context.c
34923 views
/*1* Copyright (c) 1997, 2003 Kungliga Tekniska Högskolan2* (Royal Institute of Technology, Stockholm, Sweden).3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8*9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* 3. Neither the name of the Institute nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#include "gsskrb5_locl.h"3435OM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_context (36OM_uint32 * minor_status,37const gss_ctx_id_t context_handle,38gss_name_t * src_name,39gss_name_t * targ_name,40OM_uint32 * lifetime_rec,41gss_OID * mech_type,42OM_uint32 * ctx_flags,43int * locally_initiated,44int * open_context45)46{47krb5_context context;48OM_uint32 ret;49gsskrb5_ctx ctx = (gsskrb5_ctx)context_handle;50gss_name_t name;5152if (src_name)53*src_name = GSS_C_NO_NAME;54if (targ_name)55*targ_name = GSS_C_NO_NAME;5657GSSAPI_KRB5_INIT (&context);5859HEIMDAL_MUTEX_lock(&ctx->ctx_id_mutex);6061if (src_name) {62name = (gss_name_t)ctx->source;63ret = _gsskrb5_duplicate_name (minor_status, name, src_name);64if (ret)65goto failed;66}6768if (targ_name) {69name = (gss_name_t)ctx->target;70ret = _gsskrb5_duplicate_name (minor_status, name, targ_name);71if (ret)72goto failed;73}7475if (lifetime_rec) {76ret = _gsskrb5_lifetime_left(minor_status,77context,78ctx->lifetime,79lifetime_rec);80if (ret)81goto failed;82}8384if (mech_type)85*mech_type = GSS_KRB5_MECHANISM;8687if (ctx_flags)88*ctx_flags = ctx->flags;8990if (locally_initiated)91*locally_initiated = ctx->more_flags & LOCAL;9293if (open_context)94*open_context = ctx->more_flags & OPEN;9596*minor_status = 0;9798HEIMDAL_MUTEX_unlock(&ctx->ctx_id_mutex);99return GSS_S_COMPLETE;100101failed:102if (src_name)103_gsskrb5_release_name(NULL, src_name);104if (targ_name)105_gsskrb5_release_name(NULL, targ_name);106107HEIMDAL_MUTEX_unlock(&ctx->ctx_id_mutex);108return ret;109}110111112