17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * lib/gssapi/krb5/inq_names.c
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * Copyright 1995 by the Massachusetts Institute of Technology.
57c478bd9Sstevel@tonic-gate  * All Rights Reserved.
67c478bd9Sstevel@tonic-gate  *
77c478bd9Sstevel@tonic-gate  * Export of this software from the United States of America may
87c478bd9Sstevel@tonic-gate  *   require a specific license from the United States Government.
97c478bd9Sstevel@tonic-gate  *   It is the responsibility of any person or organization contemplating
107c478bd9Sstevel@tonic-gate  *   export to obtain such a license before exporting.
117c478bd9Sstevel@tonic-gate  *
127c478bd9Sstevel@tonic-gate  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
137c478bd9Sstevel@tonic-gate  * distribute this software and its documentation for any purpose and
147c478bd9Sstevel@tonic-gate  * without fee is hereby granted, provided that the above copyright
157c478bd9Sstevel@tonic-gate  * notice appear in all copies and that both that copyright notice and
167c478bd9Sstevel@tonic-gate  * this permission notice appear in supporting documentation, and that
177c478bd9Sstevel@tonic-gate  * the name of M.I.T. not be used in advertising or publicity pertaining
187c478bd9Sstevel@tonic-gate  * to distribution of the software without specific, written prior
197c478bd9Sstevel@tonic-gate  * permission.  Furthermore if you modify this software you must label
207c478bd9Sstevel@tonic-gate  * your software as modified software and not distribute it in such a
217c478bd9Sstevel@tonic-gate  * fashion that it might be confused with the original M.I.T. software.
227c478bd9Sstevel@tonic-gate  * M.I.T. makes no representations about the suitability of
237c478bd9Sstevel@tonic-gate  * this software for any purpose.  It is provided "as is" without express
247c478bd9Sstevel@tonic-gate  * or implied warranty.
257c478bd9Sstevel@tonic-gate  *
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate /*
297c478bd9Sstevel@tonic-gate  * inq_names.c - Return set of nametypes supported by the KRB5 mechanism.
307c478bd9Sstevel@tonic-gate  */
31ab9b2e15Sgtb #include "gssapiP_krb5.h"
32ab9b2e15Sgtb #include "mglueP.h"
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate OM_uint32
krb5_gss_inquire_names_for_mech(minor_status,mechanism,name_types)35ab9b2e15Sgtb krb5_gss_inquire_names_for_mech(minor_status, mechanism, name_types)
367c478bd9Sstevel@tonic-gate     OM_uint32	*minor_status;
377c478bd9Sstevel@tonic-gate     gss_OID	mechanism;
387c478bd9Sstevel@tonic-gate     gss_OID_set	*name_types;
397c478bd9Sstevel@tonic-gate {
407c478bd9Sstevel@tonic-gate     OM_uint32	major, minor;
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate     /*
437c478bd9Sstevel@tonic-gate      * We only know how to handle our own mechanism.
447c478bd9Sstevel@tonic-gate      */
457c478bd9Sstevel@tonic-gate     if ((mechanism != GSS_C_NULL_OID) &&
467c478bd9Sstevel@tonic-gate 	!g_OID_equal(gss_mech_krb5, mechanism) &&
477c478bd9Sstevel@tonic-gate 	!g_OID_equal(gss_mech_krb5_old, mechanism)) {
487c478bd9Sstevel@tonic-gate 	*minor_status = 0;
497c478bd9Sstevel@tonic-gate 	return(GSS_S_BAD_MECH);
507c478bd9Sstevel@tonic-gate     }
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate     /* We're okay.  Create an empty OID set */
537c478bd9Sstevel@tonic-gate     major = gss_create_empty_oid_set(minor_status, name_types);
547c478bd9Sstevel@tonic-gate     if (major == GSS_S_COMPLETE) {
557c478bd9Sstevel@tonic-gate 	/* Now add our members. */
567c478bd9Sstevel@tonic-gate 	if (
57ab9b2e15Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
58ab9b2e15Sgtb 						     gss_nt_user_name,
59ab9b2e15Sgtb 						     name_types)
607c478bd9Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
61ab9b2e15Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
62ab9b2e15Sgtb 						     gss_nt_machine_uid_name,
63ab9b2e15Sgtb 						     name_types)
647c478bd9Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
65ab9b2e15Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
66ab9b2e15Sgtb 						     gss_nt_string_uid_name,
67ab9b2e15Sgtb 						     name_types)
687c478bd9Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
69ab9b2e15Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
70ab9b2e15Sgtb 						     gss_nt_service_name,
71ab9b2e15Sgtb 						     name_types)
727c478bd9Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
73ab9b2e15Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
74ab9b2e15Sgtb 						     gss_nt_service_name_v2,
75ab9b2e15Sgtb 						     name_types)
767c478bd9Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
77ab9b2e15Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
78ab9b2e15Sgtb 						     gss_nt_exported_name,
79ab9b2e15Sgtb 						     name_types)
807c478bd9Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE) &&
81ab9b2e15Sgtb 	    ((major = generic_gss_add_oid_set_member(minor_status,
82*159d09a2SMark Phalan 						    (const gss_OID) gss_nt_krb5_name, /* Solaris Kerberos */
83ab9b2e15Sgtb 						     name_types)
847c478bd9Sstevel@tonic-gate 	      ) == GSS_S_COMPLETE)
857c478bd9Sstevel@tonic-gate 	    ) {
86*159d09a2SMark Phalan 	    /* Solaris Kerberos */
87ab9b2e15Sgtb 	    major = generic_gss_add_oid_set_member(minor_status,
88*159d09a2SMark Phalan 						  (const gss_OID) gss_nt_krb5_principal,
89ab9b2e15Sgtb 						   name_types);
907c478bd9Sstevel@tonic-gate 	}
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 	/*
937c478bd9Sstevel@tonic-gate 	 * If we choked, then release the set, but don't overwrite the minor
947c478bd9Sstevel@tonic-gate 	 * status with the release call.
957c478bd9Sstevel@tonic-gate 	 */
967c478bd9Sstevel@tonic-gate 	if (major != GSS_S_COMPLETE)
977c478bd9Sstevel@tonic-gate 	    (void) gss_release_oid_set(&minor,
987c478bd9Sstevel@tonic-gate 				       name_types);
997c478bd9Sstevel@tonic-gate     }
1007c478bd9Sstevel@tonic-gate     return(major);
1017c478bd9Sstevel@tonic-gate }
102