Path: blob/main/crypto/heimdal/lib/gssapi/krb5/inquire_cred_by_oid.c
34923 views
/*1* Copyright (c) 2004, PADL Software Pty Ltd.2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7*8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10*11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* 3. Neither the name of PADL Software nor the names of its contributors16* may be used to endorse or promote products derived from this software17* without specific prior written permission.18*19* THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND20* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22* ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE23* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL24* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS25* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT27* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF29* SUCH DAMAGE.30*/3132#include "gsskrb5_locl.h"3334OM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_cred_by_oid35(OM_uint32 * minor_status,36const gss_cred_id_t cred_handle,37const gss_OID desired_object,38gss_buffer_set_t *data_set)39{40krb5_context context;41gsskrb5_cred cred = (gsskrb5_cred)cred_handle;42krb5_error_code ret;43gss_buffer_desc buffer;44char *str;4546GSSAPI_KRB5_INIT (&context);4748if (gss_oid_equal(desired_object, GSS_KRB5_COPY_CCACHE_X) == 0) {49*minor_status = EINVAL;50return GSS_S_FAILURE;51}5253HEIMDAL_MUTEX_lock(&cred->cred_id_mutex);5455if (cred->ccache == NULL) {56HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex);57*minor_status = EINVAL;58return GSS_S_FAILURE;59}6061ret = krb5_cc_get_full_name(context, cred->ccache, &str);62HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex);63if (ret) {64*minor_status = ret;65return GSS_S_FAILURE;66}6768buffer.value = str;69buffer.length = strlen(str);7071ret = gss_add_buffer_set_member(minor_status, &buffer, data_set);72if (ret != GSS_S_COMPLETE)73_gsskrb5_clear_status ();7475free(str);7677*minor_status = 0;78return GSS_S_COMPLETE;79}80818283