17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright 1993 by OpenVision Technologies, Inc.
3*55fea89dSDan Cross  *
47c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, distribute, and sell this software
57c478bd9Sstevel@tonic-gate  * and its documentation for any purpose is hereby granted without fee,
67c478bd9Sstevel@tonic-gate  * provided that the above copyright notice appears in all copies and
77c478bd9Sstevel@tonic-gate  * that both that copyright notice and this permission notice appear in
87c478bd9Sstevel@tonic-gate  * supporting documentation, and that the name of OpenVision not be used
97c478bd9Sstevel@tonic-gate  * in advertising or publicity pertaining to distribution of the software
107c478bd9Sstevel@tonic-gate  * without specific, written prior permission. OpenVision makes no
117c478bd9Sstevel@tonic-gate  * representations about the suitability of this software for any
127c478bd9Sstevel@tonic-gate  * purpose.  It is provided "as is" without express or implied warranty.
13*55fea89dSDan Cross  *
147c478bd9Sstevel@tonic-gate  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
157c478bd9Sstevel@tonic-gate  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
167c478bd9Sstevel@tonic-gate  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
177c478bd9Sstevel@tonic-gate  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
187c478bd9Sstevel@tonic-gate  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
197c478bd9Sstevel@tonic-gate  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
207c478bd9Sstevel@tonic-gate  * PERFORMANCE OF THIS SOFTWARE.
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate 
23ab9b2e15Sgtb #include "gssapiP_krb5.h"
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate OM_uint32
krb5_gss_display_name(minor_status,input_name,output_name_buffer,output_name_type)26*55fea89dSDan Cross krb5_gss_display_name(minor_status, input_name, output_name_buffer,
277c478bd9Sstevel@tonic-gate 		      output_name_type)
287c478bd9Sstevel@tonic-gate      OM_uint32 *minor_status;
297c478bd9Sstevel@tonic-gate      gss_name_t input_name;
307c478bd9Sstevel@tonic-gate      gss_buffer_t output_name_buffer;
317c478bd9Sstevel@tonic-gate      gss_OID *output_name_type;
327c478bd9Sstevel@tonic-gate {
33ab9b2e15Sgtb    krb5_context context;
347c478bd9Sstevel@tonic-gate    krb5_error_code code;
357c478bd9Sstevel@tonic-gate    char *str;
367c478bd9Sstevel@tonic-gate 
37ab9b2e15Sgtb    code = krb5_gss_init_context(&context);
38ab9b2e15Sgtb    if (code) {
39ab9b2e15Sgtb        *minor_status = code;
40ab9b2e15Sgtb        return GSS_S_FAILURE;
41ab9b2e15Sgtb    }
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate    output_name_buffer->length = 0;
447c478bd9Sstevel@tonic-gate    output_name_buffer->value = NULL;
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate    if (! kg_validate_name(input_name)) {
477c478bd9Sstevel@tonic-gate       *minor_status = (OM_uint32) G_VALIDATE_FAILED;
48ab9b2e15Sgtb       krb5_free_context(context);
497c478bd9Sstevel@tonic-gate       return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_BAD_NAME);
507c478bd9Sstevel@tonic-gate    }
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate    if ((code = krb5_unparse_name(context,
537c478bd9Sstevel@tonic-gate 				 (krb5_principal) input_name, &str))) {
547c478bd9Sstevel@tonic-gate       *minor_status = code;
555e01956fSGlenn Barry       save_error_info(*minor_status, context);
56ab9b2e15Sgtb       krb5_free_context(context);
577c478bd9Sstevel@tonic-gate       return(GSS_S_FAILURE);
587c478bd9Sstevel@tonic-gate    }
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate    if (! g_make_string_buffer(str, output_name_buffer)) {
61ab9b2e15Sgtb       krb5_free_unparsed_name(context, str);
62ab9b2e15Sgtb       krb5_free_context(context);
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate       *minor_status = (OM_uint32) G_BUFFER_ALLOC;
657c478bd9Sstevel@tonic-gate       return(GSS_S_FAILURE);
667c478bd9Sstevel@tonic-gate    }
677c478bd9Sstevel@tonic-gate 
68ab9b2e15Sgtb    krb5_free_unparsed_name(context, str);
69ab9b2e15Sgtb    krb5_free_context(context);
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate    *minor_status = 0;
727c478bd9Sstevel@tonic-gate    if (output_name_type)
737c478bd9Sstevel@tonic-gate       *output_name_type = (gss_OID) gss_nt_krb5_name;
747c478bd9Sstevel@tonic-gate    return(GSS_S_COMPLETE);
757c478bd9Sstevel@tonic-gate }
76