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 33178825Sdfr#include "krb5/gsskrb5_locl.h" 34178825Sdfr 35178825SdfrRCSID("$Id: inquire_cred_by_oid.c 19031 2006-11-13 18:02:57Z lha $"); 36178825Sdfr 37178825SdfrOM_uint32 _gsskrb5_inquire_cred_by_oid 38178825Sdfr (OM_uint32 * minor_status, 39178825Sdfr const gss_cred_id_t cred_handle, 40178825Sdfr const gss_OID desired_object, 41178825Sdfr gss_buffer_set_t *data_set) 42178825Sdfr{ 43178825Sdfr krb5_context context; 44178825Sdfr gsskrb5_cred cred = (gsskrb5_cred)cred_handle; 45178825Sdfr krb5_error_code ret; 46178825Sdfr gss_buffer_desc buffer; 47178825Sdfr char *str; 48178825Sdfr 49178825Sdfr GSSAPI_KRB5_INIT (&context); 50178825Sdfr 51178825Sdfr if (gss_oid_equal(desired_object, GSS_KRB5_COPY_CCACHE_X) == 0) { 52178825Sdfr *minor_status = EINVAL; 53178825Sdfr return GSS_S_FAILURE; 54178825Sdfr } 55178825Sdfr 56178825Sdfr HEIMDAL_MUTEX_lock(&cred->cred_id_mutex); 57178825Sdfr 58178825Sdfr if (cred->ccache == NULL) { 59178825Sdfr HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex); 60178825Sdfr *minor_status = EINVAL; 61178825Sdfr return GSS_S_FAILURE; 62178825Sdfr } 63178825Sdfr 64178825Sdfr ret = krb5_cc_get_full_name(context, cred->ccache, &str); 65178825Sdfr HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex); 66178825Sdfr if (ret) { 67178825Sdfr *minor_status = ret; 68178825Sdfr return GSS_S_FAILURE; 69178825Sdfr } 70178825Sdfr 71178825Sdfr buffer.value = str; 72178825Sdfr buffer.length = strlen(str); 73178825Sdfr 74178825Sdfr ret = gss_add_buffer_set_member(minor_status, &buffer, data_set); 75178825Sdfr if (ret != GSS_S_COMPLETE) 76178825Sdfr _gsskrb5_clear_status (); 77178825Sdfr 78178825Sdfr free(str); 79178825Sdfr 80178825Sdfr *minor_status = 0; 81178825Sdfr return GSS_S_COMPLETE; 82178825Sdfr} 83178825Sdfr 84