xref: /onnv-gate/usr/src/uts/common/gssapi/mechs/krb5/mech/gssapi_krb5.c (revision 13132:9615cdbf7b70)
10Sstevel@tonic-gate /*
2*13132SGlenn.Barry@oracle.com  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
30Sstevel@tonic-gate  */
40Sstevel@tonic-gate 
50Sstevel@tonic-gate 
60Sstevel@tonic-gate /*
70Sstevel@tonic-gate  * Copyright 1993 by OpenVision Technologies, Inc.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * Permission to use, copy, modify, distribute, and sell this software
100Sstevel@tonic-gate  * and its documentation for any purpose is hereby granted without fee,
110Sstevel@tonic-gate  * provided that the above copyright notice appears in all copies and
120Sstevel@tonic-gate  * that both that copyright notice and this permission notice appear in
130Sstevel@tonic-gate  * supporting documentation, and that the name of OpenVision not be used
140Sstevel@tonic-gate  * in advertising or publicity pertaining to distribution of the software
150Sstevel@tonic-gate  * without specific, written prior permission. OpenVision makes no
160Sstevel@tonic-gate  * representations about the suitability of this software for any
170Sstevel@tonic-gate  * purpose.  It is provided "as is" without express or implied warranty.
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
200Sstevel@tonic-gate  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
210Sstevel@tonic-gate  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
220Sstevel@tonic-gate  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
230Sstevel@tonic-gate  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
240Sstevel@tonic-gate  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
250Sstevel@tonic-gate  * PERFORMANCE OF THIS SOFTWARE.
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * Copyright (C) 1998 by the FundsXpress, INC.
300Sstevel@tonic-gate  *
310Sstevel@tonic-gate  * All rights reserved.
320Sstevel@tonic-gate  *
330Sstevel@tonic-gate  * Export of this software from the United States of America may require
340Sstevel@tonic-gate  * a specific license from the United States Government.  It is the
350Sstevel@tonic-gate  * responsibility of any person or organization contemplating export to
360Sstevel@tonic-gate  * obtain such a license before exporting.
370Sstevel@tonic-gate  *
380Sstevel@tonic-gate  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
390Sstevel@tonic-gate  * distribute this software and its documentation for any purpose and
400Sstevel@tonic-gate  * without fee is hereby granted, provided that the above copyright
410Sstevel@tonic-gate  * notice appear in all copies and that both that copyright notice and
420Sstevel@tonic-gate  * this permission notice appear in supporting documentation, and that
430Sstevel@tonic-gate  * the name of FundsXpress. not be used in advertising or publicity pertaining
440Sstevel@tonic-gate  * to distribution of the software without specific, written prior
450Sstevel@tonic-gate  * permission.  FundsXpress makes no representations about the suitability of
460Sstevel@tonic-gate  * this software for any purpose.  It is provided "as is" without express
470Sstevel@tonic-gate  * or implied warranty.
480Sstevel@tonic-gate  *
490Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
500Sstevel@tonic-gate  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
510Sstevel@tonic-gate  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
520Sstevel@tonic-gate  */
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /*
557934SMark.Phalan@Sun.COM  * $Id: gssapi_krb5.c 18343 2006-07-19 18:14:01Z lxs $
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate 
585053Sgtb 
595053Sgtb /* For declaration of krb5_ser_context_init */
605053Sgtb #include "k5-int.h"
615053Sgtb #include "gssapiP_krb5.h"
62*13132SGlenn.Barry@oracle.com #ifndef	_KERNEL
63*13132SGlenn.Barry@oracle.com #include "gss_libinit.h"
64*13132SGlenn.Barry@oracle.com #endif
650Sstevel@tonic-gate 
660Sstevel@tonic-gate /*
675053Sgtb  * Solaris Kerberos
680Sstevel@tonic-gate  * Kernel kgssd module debugging aid. The global variable "krb5_log" is a bit
695053Sgtb  * mask which allows various types of log messages to be printed out.
700Sstevel@tonic-gate  *
710Sstevel@tonic-gate  * The log levels are defined in:
720Sstevel@tonic-gate  * usr/src/uts/common/gssapi/mechs/krb5/include/k5-int.h
730Sstevel@tonic-gate  *
745053Sgtb  * Note, KRB5_LOG_LVL can be assigned via the make invocation.
755053Sgtb  * See KRB5_DEFS in the various Makefiles.
760Sstevel@tonic-gate  */
770Sstevel@tonic-gate 
780Sstevel@tonic-gate #ifdef KRB5_LOG_LVL
790Sstevel@tonic-gate /* set the log level to that specified */
800Sstevel@tonic-gate u_int krb5_log = KRB5_LOG_LVL;
810Sstevel@tonic-gate #else
820Sstevel@tonic-gate /* default log level */
830Sstevel@tonic-gate u_int krb5_log = 0;
840Sstevel@tonic-gate #endif /* KRB5_LOG_LVL */
850Sstevel@tonic-gate 
860Sstevel@tonic-gate /** exported constants defined in gssapi_krb5{,_nx}.h **/
870Sstevel@tonic-gate 
880Sstevel@tonic-gate /* these are bogus, but will compile */
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /*
910Sstevel@tonic-gate  * The OID of the draft krb5 mechanism, assigned by IETF, is:
920Sstevel@tonic-gate  * 	iso(1) org(3) dod(5) internet(1) security(5)
930Sstevel@tonic-gate  *	kerberosv5(2) = 1.3.5.1.5.2
940Sstevel@tonic-gate  * The OID of the krb5_name type is:
950Sstevel@tonic-gate  * 	iso(1) member-body(2) US(840) mit(113554) infosys(1) gssapi(2)
960Sstevel@tonic-gate  * 	krb5(2) krb5_name(1) = 1.2.840.113554.1.2.2.1
970Sstevel@tonic-gate  * The OID of the krb5_principal type is:
985053Sgtb  * 	iso(1) member-body(2) US(840) mit(113554) infosys(1) gssapi(2)
995053Sgtb  * 	krb5(2) krb5_principal(2) = 1.2.840.113554.1.2.2.2
1000Sstevel@tonic-gate  * The OID of the proposed standard krb5 mechanism is:
1010Sstevel@tonic-gate  * 	iso(1) member-body(2) US(840) mit(113554) infosys(1) gssapi(2)
1020Sstevel@tonic-gate  * 	krb5(2) = 1.2.840.113554.1.2.2
1030Sstevel@tonic-gate  * The OID of the proposed standard krb5 v2 mechanism is:
1040Sstevel@tonic-gate  * 	iso(1) member-body(2) US(840) mit(113554) infosys(1) gssapi(2)
1050Sstevel@tonic-gate  * 	krb5v2(3) = 1.2.840.113554.1.2.3
1060Sstevel@tonic-gate  *
1070Sstevel@tonic-gate  */
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate /*
1100Sstevel@tonic-gate  * Encoding rules: The first two values are encoded in one byte as 40
1110Sstevel@tonic-gate  * * value1 + value2.  Subsequent values are encoded base 128, most
1120Sstevel@tonic-gate  * significant digit first, with the high bit (\200) set on all octets
1130Sstevel@tonic-gate  * except the last in each value's encoding.
1140Sstevel@tonic-gate  */
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate const gss_OID_desc krb5_gss_oid_array[] = {
1170Sstevel@tonic-gate    /* this is the official, rfc-specified OID */
1185053Sgtb    {GSS_MECH_KRB5_OID_LENGTH, GSS_MECH_KRB5_OID},
1195053Sgtb    /* this pre-RFC mech OID */
1205053Sgtb    {GSS_MECH_KRB5_OLD_OID_LENGTH, GSS_MECH_KRB5_OLD_OID},
1215053Sgtb    /* this is the unofficial, incorrect mech OID emitted by MS */
1225053Sgtb    {GSS_MECH_KRB5_WRONG_OID_LENGTH, GSS_MECH_KRB5_WRONG_OID},
1230Sstevel@tonic-gate    /* this is the v2 assigned OID */
1240Sstevel@tonic-gate    {9, "\052\206\110\206\367\022\001\002\003"},
1250Sstevel@tonic-gate    /* these two are name type OID's */
1265053Sgtb 
1275053Sgtb     /* 2.1.1. Kerberos Principal Name Form:  (rfc 1964)
1285053Sgtb      * This name form shall be represented by the Object Identifier {iso(1)
1295053Sgtb      * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
1305053Sgtb      * krb5(2) krb5_name(1)}.  The recommended symbolic name for this type
1315053Sgtb      * is "GSS_KRB5_NT_PRINCIPAL_NAME". */
1320Sstevel@tonic-gate    {10, "\052\206\110\206\367\022\001\002\002\001"},
1335053Sgtb 
1345053Sgtb    /* gss_nt_krb5_principal.  Object identifier for a krb5_principal. Do not use. */
1350Sstevel@tonic-gate    {10, "\052\206\110\206\367\022\001\002\002\002"},
1360Sstevel@tonic-gate    { 0, 0 }
1370Sstevel@tonic-gate };
1380Sstevel@tonic-gate 
1395053Sgtb const gss_OID_desc * const gss_mech_krb5              = krb5_gss_oid_array+0;
1405053Sgtb const gss_OID_desc * const gss_mech_krb5_old          = krb5_gss_oid_array+1;
1415053Sgtb const gss_OID_desc * const gss_mech_krb5_wrong        = krb5_gss_oid_array+2;
1425053Sgtb const gss_OID_desc * const gss_nt_krb5_name           = krb5_gss_oid_array+4;
1435053Sgtb const gss_OID_desc * const gss_nt_krb5_principal      = krb5_gss_oid_array+5;
1445053Sgtb const gss_OID_desc * const GSS_KRB5_NT_PRINCIPAL_NAME = krb5_gss_oid_array+4;
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate static const gss_OID_set_desc oidsets[] = {
1470Sstevel@tonic-gate    {1, (gss_OID) krb5_gss_oid_array+0},
1480Sstevel@tonic-gate    {1, (gss_OID) krb5_gss_oid_array+1},
1495053Sgtb    {3, (gss_OID) krb5_gss_oid_array+0},
1500Sstevel@tonic-gate    {1, (gss_OID) krb5_gss_oid_array+2},
1510Sstevel@tonic-gate    {3, (gss_OID) krb5_gss_oid_array+0},
1520Sstevel@tonic-gate };
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate const gss_OID_set_desc * const gss_mech_set_krb5 = oidsets+0;
1550Sstevel@tonic-gate const gss_OID_set_desc * const gss_mech_set_krb5_old = oidsets+1;
1560Sstevel@tonic-gate const gss_OID_set_desc * const gss_mech_set_krb5_both = oidsets+2;
1570Sstevel@tonic-gate 
1585053Sgtb g_set kg_vdb = G_SET_INIT;
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate /** default credential support */
1610Sstevel@tonic-gate 
1625053Sgtb #ifndef  _KERNEL
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate /*
1655053Sgtb  * init_sec_context() will explicitly re-acquire default credentials,
1665053Sgtb  * so handling the expiration/invalidation condition here isn't needed.
1670Sstevel@tonic-gate  */
1680Sstevel@tonic-gate OM_uint32
kg_get_defcred(minor_status,cred)1690Sstevel@tonic-gate kg_get_defcred(minor_status, cred)
1700Sstevel@tonic-gate      OM_uint32 *minor_status;
1710Sstevel@tonic-gate      gss_cred_id_t *cred;
1720Sstevel@tonic-gate {
1735053Sgtb     OM_uint32 major;
1745053Sgtb 
1755053Sgtb     if ((major = krb5_gss_acquire_cred(minor_status,
1765053Sgtb 				      (gss_name_t) NULL, GSS_C_INDEFINITE,
1775053Sgtb 				      GSS_C_NULL_OID_SET, GSS_C_INITIATE,
1785053Sgtb 				      cred, NULL, NULL)) && GSS_ERROR(major)) {
1795053Sgtb       return(major);
1800Sstevel@tonic-gate    }
1810Sstevel@tonic-gate    *minor_status = 0;
1820Sstevel@tonic-gate    return(GSS_S_COMPLETE);
1830Sstevel@tonic-gate }
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate OM_uint32
kg_sync_ccache_name(krb5_context context,OM_uint32 * minor_status)1865053Sgtb kg_sync_ccache_name (krb5_context context, OM_uint32 *minor_status)
1870Sstevel@tonic-gate {
1885053Sgtb     OM_uint32 err = 0;
1895053Sgtb 
1905053Sgtb     /*
1915053Sgtb      * Sync up the context ccache name with the GSSAPI ccache name.
1925053Sgtb      * If kg_ccache_name is NULL -- normal unless someone has called
1935053Sgtb      * gss_krb5_ccache_name() -- then the system default ccache will
1945053Sgtb      * be picked up and used by resetting the context default ccache.
1955053Sgtb      * This is needed for platforms which support multiple ccaches.
1965053Sgtb      */
1975053Sgtb 
1985053Sgtb     if (!err) {
1995053Sgtb         /* if NULL, resets the context default ccache */
2005053Sgtb         err = krb5_cc_set_default_name(context,
2015053Sgtb 				       (char *) k5_getspecific(K5_KEY_GSS_KRB5_CCACHE_NAME));
2025053Sgtb     }
2035053Sgtb 
2045053Sgtb     *minor_status = err;
2055053Sgtb     return (*minor_status == 0) ? GSS_S_COMPLETE : GSS_S_FAILURE;
2060Sstevel@tonic-gate }
2070Sstevel@tonic-gate 
2087934SMark.Phalan@Sun.COM /* This function returns whether or not the caller set a cccache name.  Used by
2097934SMark.Phalan@Sun.COM  * gss_acquire_cred to figure out if the caller wants to only look at this
2107934SMark.Phalan@Sun.COM  * ccache or search the cache collection for the desired name */
2117934SMark.Phalan@Sun.COM OM_uint32
kg_caller_provided_ccache_name(OM_uint32 * minor_status,int * out_caller_provided_name)2127934SMark.Phalan@Sun.COM kg_caller_provided_ccache_name (OM_uint32 *minor_status,
2137934SMark.Phalan@Sun.COM int *out_caller_provided_name)
2147934SMark.Phalan@Sun.COM {
2157934SMark.Phalan@Sun.COM     if (out_caller_provided_name) {
2167934SMark.Phalan@Sun.COM         *out_caller_provided_name =
2177934SMark.Phalan@Sun.COM 	  (k5_getspecific(K5_KEY_GSS_KRB5_CCACHE_NAME) != NULL);
2187934SMark.Phalan@Sun.COM     }
2197934SMark.Phalan@Sun.COM 
2207934SMark.Phalan@Sun.COM     *minor_status = 0;
2217934SMark.Phalan@Sun.COM     return GSS_S_COMPLETE;
2227934SMark.Phalan@Sun.COM }
2237934SMark.Phalan@Sun.COM 
2240Sstevel@tonic-gate OM_uint32
kg_get_ccache_name(OM_uint32 * minor_status,const char ** out_name)2255053Sgtb kg_get_ccache_name (OM_uint32 *minor_status, const char **out_name)
2260Sstevel@tonic-gate {
2275053Sgtb     const char *name = NULL;
2285053Sgtb     OM_uint32 err = 0;
2295053Sgtb     char *kg_ccache_name;
2305053Sgtb 
2315053Sgtb     kg_ccache_name = k5_getspecific(K5_KEY_GSS_KRB5_CCACHE_NAME);
2325053Sgtb 
2335053Sgtb     if (kg_ccache_name != NULL) {
2345053Sgtb 	name = strdup(kg_ccache_name);
2355053Sgtb 	if (name == NULL)
2365053Sgtb 	    err = errno;
2375053Sgtb     } else {
2385053Sgtb 	krb5_context context = NULL;
2390Sstevel@tonic-gate 
2405053Sgtb 	/* Reset the context default ccache (see text above), and then
2415053Sgtb 	   retrieve it.  */
2425053Sgtb 	err = krb5_gss_init_context(&context);
2435053Sgtb 	if (!err)
2445053Sgtb 	    err = krb5_cc_set_default_name (context, NULL);
2455053Sgtb 	if (!err) {
2465053Sgtb 	    name = krb5_cc_default_name(context);
2475053Sgtb 	    if (name) {
2485053Sgtb 		name = strdup(name);
2495053Sgtb 		if (name == NULL)
250*13132SGlenn.Barry@oracle.com 		    err = ENOMEM;
2515053Sgtb 	    }
2525053Sgtb 	}
253*13132SGlenn.Barry@oracle.com 	if (err && context)
254*13132SGlenn.Barry@oracle.com 	    save_error_info(err, context);
255*13132SGlenn.Barry@oracle.com    	if (context)
2565053Sgtb 	    krb5_free_context(context);
2575053Sgtb     }
2580Sstevel@tonic-gate 
2595053Sgtb     if (!err) {
2605053Sgtb         if (out_name) {
2615053Sgtb             *out_name = name;
2625053Sgtb         }
2635053Sgtb     }
2645053Sgtb 
2655053Sgtb     *minor_status = err;
2665053Sgtb     return (*minor_status == 0) ? GSS_S_COMPLETE : GSS_S_FAILURE;
2675053Sgtb }
2685053Sgtb 
2695053Sgtb OM_uint32
kg_set_ccache_name(OM_uint32 * minor_status,const char * name)2705053Sgtb kg_set_ccache_name (OM_uint32 *minor_status, const char *name)
2715053Sgtb {
2725053Sgtb     char *new_name = NULL;
2735053Sgtb     char *swap = NULL;
2745053Sgtb     char *kg_ccache_name;
2755053Sgtb     krb5_error_code kerr;
2765053Sgtb 
2775053Sgtb     if (name) {
2785053Sgtb 	new_name = malloc(strlen(name) + 1);
2795053Sgtb 	if (new_name == NULL) {
2805053Sgtb 	    *minor_status = ENOMEM;
2815053Sgtb 	    return GSS_S_FAILURE;
2825053Sgtb 	}
2835053Sgtb 	strcpy(new_name, name);
2845053Sgtb     }
2855053Sgtb 
2865053Sgtb     kg_ccache_name = k5_getspecific(K5_KEY_GSS_KRB5_CCACHE_NAME);
2875053Sgtb     swap = kg_ccache_name;
2885053Sgtb     kg_ccache_name = new_name;
2895053Sgtb     new_name = swap;
2905053Sgtb     kerr = k5_setspecific(K5_KEY_GSS_KRB5_CCACHE_NAME, kg_ccache_name);
2915053Sgtb     if (kerr != 0) {
2925053Sgtb 	/* Can't store, so free up the storage.  */
2935053Sgtb 	free(kg_ccache_name);
2945053Sgtb 	/* ??? free(new_name); */
2955053Sgtb 	*minor_status = kerr;
2965053Sgtb 	return GSS_S_FAILURE;
2975053Sgtb     }
2985053Sgtb 
2995053Sgtb     free (new_name);
3005053Sgtb     *minor_status = 0;
3015053Sgtb     return GSS_S_COMPLETE;
3020Sstevel@tonic-gate }
30310598SGlenn.Barry@Sun.COM 
30410598SGlenn.Barry@Sun.COM #define g_OID_prefix_equal(o1, o2) \
30510598SGlenn.Barry@Sun.COM         (((o1)->length >= (o2)->length) && \
30610598SGlenn.Barry@Sun.COM         (memcmp((o1)->elements, (o2)->elements, (o2)->length) == 0))
30710598SGlenn.Barry@Sun.COM 
30810598SGlenn.Barry@Sun.COM /*
30910598SGlenn.Barry@Sun.COM  * gss_inquire_sec_context_by_oid() methods
31010598SGlenn.Barry@Sun.COM  */
31110598SGlenn.Barry@Sun.COM static struct {
31210598SGlenn.Barry@Sun.COM     gss_OID_desc oid;
31310598SGlenn.Barry@Sun.COM     OM_uint32 (*func)(OM_uint32 *, const gss_ctx_id_t, const gss_OID, gss_buffer_set_t *);
31410598SGlenn.Barry@Sun.COM } krb5_gss_inquire_sec_context_by_oid_ops[] = {
31510598SGlenn.Barry@Sun.COM     {
31610598SGlenn.Barry@Sun.COM         {GSS_KRB5_GET_TKT_FLAGS_OID_LENGTH, GSS_KRB5_GET_TKT_FLAGS_OID},
31710598SGlenn.Barry@Sun.COM         gss_krb5int_get_tkt_flags
31810598SGlenn.Barry@Sun.COM     },
31910598SGlenn.Barry@Sun.COM     {
32010598SGlenn.Barry@Sun.COM         {GSS_KRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT_OID_LENGTH, GSS_KRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT_OID},
32110598SGlenn.Barry@Sun.COM         gss_krb5int_extract_authz_data_from_sec_context
32210598SGlenn.Barry@Sun.COM     },
32310598SGlenn.Barry@Sun.COM     {
32410598SGlenn.Barry@Sun.COM         {GSS_KRB5_INQ_SSPI_SESSION_KEY_OID_LENGTH, GSS_KRB5_INQ_SSPI_SESSION_KEY_OID},
32510598SGlenn.Barry@Sun.COM         gss_krb5int_inq_session_key
32610598SGlenn.Barry@Sun.COM     },
32710598SGlenn.Barry@Sun.COM     {
32810598SGlenn.Barry@Sun.COM         {GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT_OID_LENGTH, GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT_OID},
32910598SGlenn.Barry@Sun.COM         gss_krb5int_export_lucid_sec_context
33010598SGlenn.Barry@Sun.COM     },
33110598SGlenn.Barry@Sun.COM     {
33210598SGlenn.Barry@Sun.COM         {GSS_KRB5_EXTRACT_AUTHTIME_FROM_SEC_CONTEXT_OID_LENGTH, GSS_KRB5_EXTRACT_AUTHTIME_FROM_SEC_CONTEXT_OID},
33310598SGlenn.Barry@Sun.COM         gss_krb5int_extract_authtime_from_sec_context
33410598SGlenn.Barry@Sun.COM     }
33510598SGlenn.Barry@Sun.COM };
33610598SGlenn.Barry@Sun.COM 
33710598SGlenn.Barry@Sun.COM OM_uint32
krb5_gss_inquire_sec_context_by_oid(OM_uint32 * minor_status,const gss_ctx_id_t context_handle,const gss_OID desired_object,gss_buffer_set_t * data_set)33810598SGlenn.Barry@Sun.COM krb5_gss_inquire_sec_context_by_oid (OM_uint32 *minor_status,
33910598SGlenn.Barry@Sun.COM                                      const gss_ctx_id_t context_handle,
34010598SGlenn.Barry@Sun.COM                                      const gss_OID desired_object,
34110598SGlenn.Barry@Sun.COM                                      gss_buffer_set_t *data_set)
34210598SGlenn.Barry@Sun.COM {
34310598SGlenn.Barry@Sun.COM     krb5_gss_ctx_id_rec *ctx;
34410598SGlenn.Barry@Sun.COM     size_t i;
34510598SGlenn.Barry@Sun.COM 
34610598SGlenn.Barry@Sun.COM     if (minor_status == NULL)
34710598SGlenn.Barry@Sun.COM         return GSS_S_CALL_INACCESSIBLE_WRITE;
34810598SGlenn.Barry@Sun.COM 
34910598SGlenn.Barry@Sun.COM     *minor_status = 0;
35010598SGlenn.Barry@Sun.COM 
35110598SGlenn.Barry@Sun.COM     if (desired_object == GSS_C_NO_OID)
35210598SGlenn.Barry@Sun.COM         return GSS_S_CALL_INACCESSIBLE_READ;
35310598SGlenn.Barry@Sun.COM 
35410598SGlenn.Barry@Sun.COM     if (data_set == NULL)
35510598SGlenn.Barry@Sun.COM         return GSS_S_CALL_INACCESSIBLE_WRITE;
35610598SGlenn.Barry@Sun.COM 
35710598SGlenn.Barry@Sun.COM     *data_set = GSS_C_NO_BUFFER_SET;
35810598SGlenn.Barry@Sun.COM 
35910598SGlenn.Barry@Sun.COM     if (!kg_validate_ctx_id(context_handle))
36010598SGlenn.Barry@Sun.COM         return GSS_S_NO_CONTEXT;
36110598SGlenn.Barry@Sun.COM 
36210598SGlenn.Barry@Sun.COM     ctx = (krb5_gss_ctx_id_rec *) context_handle;
36310598SGlenn.Barry@Sun.COM 
36410598SGlenn.Barry@Sun.COM     if (!ctx->established)
36510598SGlenn.Barry@Sun.COM         return GSS_S_NO_CONTEXT;
36610598SGlenn.Barry@Sun.COM 
36710598SGlenn.Barry@Sun.COM     for (i = 0; i < sizeof(krb5_gss_inquire_sec_context_by_oid_ops)/
36810598SGlenn.Barry@Sun.COM                     sizeof(krb5_gss_inquire_sec_context_by_oid_ops[0]); i++) {
36910598SGlenn.Barry@Sun.COM         if (g_OID_prefix_equal(desired_object, &krb5_gss_inquire_sec_context_by_oid_ops[i].oid)) {
37010598SGlenn.Barry@Sun.COM             return (*krb5_gss_inquire_sec_context_by_oid_ops[i].func)(minor_status,
37110598SGlenn.Barry@Sun.COM                                                                       context_handle,
37210598SGlenn.Barry@Sun.COM                                                                       desired_object,
37310598SGlenn.Barry@Sun.COM                                                                       data_set);
37410598SGlenn.Barry@Sun.COM         }
37510598SGlenn.Barry@Sun.COM     }
37610598SGlenn.Barry@Sun.COM 
37710598SGlenn.Barry@Sun.COM     *minor_status = EINVAL;
37810598SGlenn.Barry@Sun.COM 
37910598SGlenn.Barry@Sun.COM     return GSS_S_UNAVAILABLE;
38010598SGlenn.Barry@Sun.COM }
38110598SGlenn.Barry@Sun.COM 
382*13132SGlenn.Barry@oracle.com 
383*13132SGlenn.Barry@oracle.com #if 0 /* Solaris Kerberos - revisit for full 1.7/next resync */
384*13132SGlenn.Barry@oracle.com MAKE_INIT_FUNCTION(gss_krb5int_lib_init);
385*13132SGlenn.Barry@oracle.com MAKE_FINI_FUNCTION(gss_krb5int_lib_fini);
3860Sstevel@tonic-gate #endif
387*13132SGlenn.Barry@oracle.com 
gss_krb5int_initialize_library(void)388*13132SGlenn.Barry@oracle.com OM_uint32 gss_krb5int_initialize_library (void)
389*13132SGlenn.Barry@oracle.com {
390*13132SGlenn.Barry@oracle.com #if 0 /* Solaris Kerberos - revisit for full 1.7/next resync */
391*13132SGlenn.Barry@oracle.com #ifdef _GSS_STATIC_LINK
392*13132SGlenn.Barry@oracle.com 	return gssint_mechglue_initialize_library();
393*13132SGlenn.Barry@oracle.com #else
394*13132SGlenn.Barry@oracle.com 	return CALL_INIT_FUNCTION(gss_krb5int_lib_init);
395*13132SGlenn.Barry@oracle.com #endif
396*13132SGlenn.Barry@oracle.com #endif
397*13132SGlenn.Barry@oracle.com 	return gssint_initialize_library();
398*13132SGlenn.Barry@oracle.com }
399*13132SGlenn.Barry@oracle.com #endif /* !KERNEL */
400