xref: /onnv-gate/usr/src/lib/gss_mechs/mech_krb5/mech/compare_name.c (revision 5053:532e59d6bffd)
10Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
20Sstevel@tonic-gate 
30Sstevel@tonic-gate /*
40Sstevel@tonic-gate  * Copyright 1993 by OpenVision Technologies, Inc.
5*5053Sgtb  *
60Sstevel@tonic-gate  * Permission to use, copy, modify, distribute, and sell this software
70Sstevel@tonic-gate  * and its documentation for any purpose is hereby granted without fee,
80Sstevel@tonic-gate  * provided that the above copyright notice appears in all copies and
90Sstevel@tonic-gate  * that both that copyright notice and this permission notice appear in
100Sstevel@tonic-gate  * supporting documentation, and that the name of OpenVision not be used
110Sstevel@tonic-gate  * in advertising or publicity pertaining to distribution of the software
120Sstevel@tonic-gate  * without specific, written prior permission. OpenVision makes no
130Sstevel@tonic-gate  * representations about the suitability of this software for any
140Sstevel@tonic-gate  * purpose.  It is provided "as is" without express or implied warranty.
15*5053Sgtb  *
160Sstevel@tonic-gate  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
170Sstevel@tonic-gate  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
180Sstevel@tonic-gate  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
190Sstevel@tonic-gate  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
200Sstevel@tonic-gate  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
210Sstevel@tonic-gate  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
220Sstevel@tonic-gate  * PERFORMANCE OF THIS SOFTWARE.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate /*
26*5053Sgtb  * $Id: compare_name.c 18015 2006-05-17 05:26:12Z raeburn $
270Sstevel@tonic-gate  */
280Sstevel@tonic-gate 
29*5053Sgtb #include "gssapiP_krb5.h"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate OM_uint32
krb5_gss_compare_name(minor_status,name1,name2,name_equal)32*5053Sgtb krb5_gss_compare_name(minor_status, name1, name2, name_equal)
330Sstevel@tonic-gate      OM_uint32 *minor_status;
340Sstevel@tonic-gate      gss_name_t name1;
350Sstevel@tonic-gate      gss_name_t name2;
360Sstevel@tonic-gate      int *name_equal;
37*5053Sgtb {
380Sstevel@tonic-gate    krb5_context context;
39*5053Sgtb    krb5_error_code code;
400Sstevel@tonic-gate 
410Sstevel@tonic-gate    if (! kg_validate_name(name1)) {
420Sstevel@tonic-gate       *minor_status = (OM_uint32) G_VALIDATE_FAILED;
430Sstevel@tonic-gate       return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_BAD_NAME);
440Sstevel@tonic-gate    }
450Sstevel@tonic-gate 
460Sstevel@tonic-gate    if (! kg_validate_name(name2)) {
470Sstevel@tonic-gate       *minor_status = (OM_uint32) G_VALIDATE_FAILED;
480Sstevel@tonic-gate       return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_BAD_NAME);
490Sstevel@tonic-gate    }
500Sstevel@tonic-gate 
51*5053Sgtb    code = krb5_gss_init_context(&context);
52*5053Sgtb    if (code) {
53*5053Sgtb        *minor_status = code;
54*5053Sgtb        return GSS_S_FAILURE;
55*5053Sgtb    }
56*5053Sgtb 
570Sstevel@tonic-gate    *minor_status = 0;
580Sstevel@tonic-gate    *name_equal = krb5_principal_compare(context, (krb5_principal) name1,
590Sstevel@tonic-gate 					(krb5_principal) name2);
60*5053Sgtb    krb5_free_context(context);
610Sstevel@tonic-gate    return(GSS_S_COMPLETE);
620Sstevel@tonic-gate }
63