xref: /onnv-gate/usr/src/lib/gss_mechs/mech_krb5/mech/inq_names.c (revision 7934:6aeeafc994de)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * lib/gssapi/krb5/inq_names.c
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * Copyright 1995 by the Massachusetts Institute of Technology.
50Sstevel@tonic-gate  * All Rights Reserved.
60Sstevel@tonic-gate  *
70Sstevel@tonic-gate  * Export of this software from the United States of America may
80Sstevel@tonic-gate  *   require a specific license from the United States Government.
90Sstevel@tonic-gate  *   It is the responsibility of any person or organization contemplating
100Sstevel@tonic-gate  *   export to obtain such a license before exporting.
110Sstevel@tonic-gate  *
120Sstevel@tonic-gate  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
130Sstevel@tonic-gate  * distribute this software and its documentation for any purpose and
140Sstevel@tonic-gate  * without fee is hereby granted, provided that the above copyright
150Sstevel@tonic-gate  * notice appear in all copies and that both that copyright notice and
160Sstevel@tonic-gate  * this permission notice appear in supporting documentation, and that
170Sstevel@tonic-gate  * the name of M.I.T. not be used in advertising or publicity pertaining
180Sstevel@tonic-gate  * to distribution of the software without specific, written prior
190Sstevel@tonic-gate  * permission.  Furthermore if you modify this software you must label
200Sstevel@tonic-gate  * your software as modified software and not distribute it in such a
210Sstevel@tonic-gate  * fashion that it might be confused with the original M.I.T. software.
220Sstevel@tonic-gate  * M.I.T. makes no representations about the suitability of
230Sstevel@tonic-gate  * this software for any purpose.  It is provided "as is" without express
240Sstevel@tonic-gate  * or implied warranty.
250Sstevel@tonic-gate  *
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * inq_names.c - Return set of nametypes supported by the KRB5 mechanism.
300Sstevel@tonic-gate  */
315053Sgtb #include "gssapiP_krb5.h"
325053Sgtb #include "mglueP.h"
330Sstevel@tonic-gate 
340Sstevel@tonic-gate OM_uint32
krb5_gss_inquire_names_for_mech(minor_status,mechanism,name_types)355053Sgtb krb5_gss_inquire_names_for_mech(minor_status, mechanism, name_types)
360Sstevel@tonic-gate     OM_uint32	*minor_status;
370Sstevel@tonic-gate     gss_OID	mechanism;
380Sstevel@tonic-gate     gss_OID_set	*name_types;
390Sstevel@tonic-gate {
400Sstevel@tonic-gate     OM_uint32	major, minor;
410Sstevel@tonic-gate 
420Sstevel@tonic-gate     /*
430Sstevel@tonic-gate      * We only know how to handle our own mechanism.
440Sstevel@tonic-gate      */
450Sstevel@tonic-gate     if ((mechanism != GSS_C_NULL_OID) &&
460Sstevel@tonic-gate 	!g_OID_equal(gss_mech_krb5, mechanism) &&
470Sstevel@tonic-gate 	!g_OID_equal(gss_mech_krb5_old, mechanism)) {
480Sstevel@tonic-gate 	*minor_status = 0;
490Sstevel@tonic-gate 	return(GSS_S_BAD_MECH);
500Sstevel@tonic-gate     }
510Sstevel@tonic-gate 
520Sstevel@tonic-gate     /* We're okay.  Create an empty OID set */
530Sstevel@tonic-gate     major = gss_create_empty_oid_set(minor_status, name_types);
540Sstevel@tonic-gate     if (major == GSS_S_COMPLETE) {
550Sstevel@tonic-gate 	/* Now add our members. */
560Sstevel@tonic-gate 	if (
575053Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
585053Sgtb 						     gss_nt_user_name,
595053Sgtb 						     name_types)
600Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
615053Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
625053Sgtb 						     gss_nt_machine_uid_name,
635053Sgtb 						     name_types)
640Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
655053Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
665053Sgtb 						     gss_nt_string_uid_name,
675053Sgtb 						     name_types)
680Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
695053Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
705053Sgtb 						     gss_nt_service_name,
715053Sgtb 						     name_types)
725053Sgtb 	      ) == GSS_S_COMPLETE) &&
735053Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
745053Sgtb 						     gss_nt_service_name_v2,
755053Sgtb 						     name_types)
760Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
775053Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
785053Sgtb 						     gss_nt_exported_name,
795053Sgtb 						     name_types)
800Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
815053Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
82*7934SMark.Phalan@Sun.COM 						    (const gss_OID) gss_nt_krb5_name, /* Solaris Kerberos */
835053Sgtb 						     name_types)
840Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE)
850Sstevel@tonic-gate 	    ) {
86*7934SMark.Phalan@Sun.COM 	    /* Solaris Kerberos */
875053Sgtb 	    major = generic_gss_add_oid_set_member(minor_status,
88*7934SMark.Phalan@Sun.COM 						  (const gss_OID) gss_nt_krb5_principal,
895053Sgtb 						   name_types);
900Sstevel@tonic-gate 	}
910Sstevel@tonic-gate 
920Sstevel@tonic-gate 	/*
930Sstevel@tonic-gate 	 * If we choked, then release the set, but don't overwrite the minor
940Sstevel@tonic-gate 	 * status with the release call.
950Sstevel@tonic-gate 	 */
960Sstevel@tonic-gate 	if (major != GSS_S_COMPLETE)
970Sstevel@tonic-gate 	    (void) gss_release_oid_set(&minor,
980Sstevel@tonic-gate 				       name_types);
990Sstevel@tonic-gate     }
1000Sstevel@tonic-gate     return(major);
1010Sstevel@tonic-gate }
102