1178825Sdfr/* 2178825Sdfr * Copyright (c) 2004, PADL Software Pty Ltd. 3178825Sdfr * All rights reserved. 4178825Sdfr * 5178825Sdfr * Redistribution and use in source and binary forms, with or without 6178825Sdfr * modification, are permitted provided that the following conditions 7178825Sdfr * are met: 8178825Sdfr * 9178825Sdfr * 1. Redistributions of source code must retain the above copyright 10178825Sdfr * notice, this list of conditions and the following disclaimer. 11178825Sdfr * 12178825Sdfr * 2. Redistributions in binary form must reproduce the above copyright 13178825Sdfr * notice, this list of conditions and the following disclaimer in the 14178825Sdfr * documentation and/or other materials provided with the distribution. 15178825Sdfr * 16178825Sdfr * 3. Neither the name of PADL Software nor the names of its contributors 17178825Sdfr * may be used to endorse or promote products derived from this software 18178825Sdfr * without specific prior written permission. 19178825Sdfr * 20178825Sdfr * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND 21178825Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22178825Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23178825Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE 24178825Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25178825Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26178825Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27178825Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28178825Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29178825Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30178825Sdfr * SUCH DAMAGE. 31178825Sdfr */ 32178825Sdfr 33233294Sstas#include "gsskrb5_locl.h" 34178825Sdfr 35233294SstasOM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_cred_by_oid 36178825Sdfr (OM_uint32 * minor_status, 37178825Sdfr const gss_cred_id_t cred_handle, 38178825Sdfr const gss_OID desired_object, 39178825Sdfr gss_buffer_set_t *data_set) 40178825Sdfr{ 41178825Sdfr krb5_context context; 42178825Sdfr gsskrb5_cred cred = (gsskrb5_cred)cred_handle; 43178825Sdfr krb5_error_code ret; 44178825Sdfr gss_buffer_desc buffer; 45178825Sdfr char *str; 46178825Sdfr 47178825Sdfr GSSAPI_KRB5_INIT (&context); 48178825Sdfr 49178825Sdfr if (gss_oid_equal(desired_object, GSS_KRB5_COPY_CCACHE_X) == 0) { 50178825Sdfr *minor_status = EINVAL; 51178825Sdfr return GSS_S_FAILURE; 52178825Sdfr } 53178825Sdfr 54178825Sdfr HEIMDAL_MUTEX_lock(&cred->cred_id_mutex); 55178825Sdfr 56178825Sdfr if (cred->ccache == NULL) { 57178825Sdfr HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex); 58178825Sdfr *minor_status = EINVAL; 59178825Sdfr return GSS_S_FAILURE; 60178825Sdfr } 61178825Sdfr 62178825Sdfr ret = krb5_cc_get_full_name(context, cred->ccache, &str); 63178825Sdfr HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex); 64178825Sdfr if (ret) { 65178825Sdfr *minor_status = ret; 66178825Sdfr return GSS_S_FAILURE; 67178825Sdfr } 68178825Sdfr 69178825Sdfr buffer.value = str; 70178825Sdfr buffer.length = strlen(str); 71178825Sdfr 72178825Sdfr ret = gss_add_buffer_set_member(minor_status, &buffer, data_set); 73178825Sdfr if (ret != GSS_S_COMPLETE) 74178825Sdfr _gsskrb5_clear_status (); 75178825Sdfr 76178825Sdfr free(str); 77178825Sdfr 78178825Sdfr *minor_status = 0; 79178825Sdfr return GSS_S_COMPLETE; 80178825Sdfr} 81178825Sdfr 82