From a6b669132f87a17a2cdd6d804f4c048e15219137 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 7 Feb 1996 05:04:58 +0000 Subject: [PATCH] Commited new snapshot from Roland Schemers at Sun This snapshot features a BSD-style copyright notice from Sun. It also includes the code to parse a configuration file and then dlopen the proper shared library. Miscellaneous cleanup in the mechglue directory. Namespace uglieness (like get_mechanism) have been cleaned up, to use things like __gss_get_mechanism instead. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7442 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/gssapi/krb5/ChangeLog | 7 + src/lib/gssapi/krb5/k5mech.c | 5 +- src/lib/gssapi/krb5/pname_to_uid.c | 82 ++++--- src/lib/gssapi/mechglue/ChangeLog | 6 + src/lib/gssapi/mechglue/Makefile.in | 11 +- src/lib/gssapi/mechglue/add_mechanism.c | 71 ------ .../gssapi/mechglue/g_accept_sec_context.c | 40 +++- src/lib/gssapi/mechglue/g_acquire_cred.c | 34 ++- src/lib/gssapi/mechglue/g_compare_name.c | 25 ++- src/lib/gssapi/mechglue/g_context_time.c | 28 ++- .../gssapi/mechglue/g_delete_sec_context.c | 28 ++- src/lib/gssapi/mechglue/g_dsp_name.c | 27 ++- src/lib/gssapi/mechglue/g_dsp_status.c | 27 ++- src/lib/gssapi/mechglue/g_exp_sec_context.c | 29 ++- src/lib/gssapi/mechglue/g_glue.c | 209 ++++++++++++++++++ src/lib/gssapi/mechglue/g_imp_name.c | 40 +++- src/lib/gssapi/mechglue/g_imp_sec_context.c | 27 ++- src/lib/gssapi/mechglue/g_indicate_mechs.c | 38 +++- src/lib/gssapi/mechglue/g_init_sec_context.c | 32 ++- src/lib/gssapi/mechglue/g_initialize.c | 184 ++++++++++++++- src/lib/gssapi/mechglue/g_inquire_context.c | 27 ++- src/lib/gssapi/mechglue/g_inquire_cred.c | 26 ++- src/lib/gssapi/mechglue/g_inquire_names.c | 27 ++- src/lib/gssapi/mechglue/g_oid_ops.c | 10 +- src/lib/gssapi/mechglue/g_process_context.c | 28 ++- src/lib/gssapi/mechglue/g_rel_buffer.c | 28 ++- src/lib/gssapi/mechglue/g_rel_cred.c | 28 ++- src/lib/gssapi/mechglue/g_rel_name.c | 26 ++- src/lib/gssapi/mechglue/g_rel_oid_set.c | 36 ++- src/lib/gssapi/mechglue/g_seal.c | 28 ++- src/lib/gssapi/mechglue/g_sign.c | 28 ++- src/lib/gssapi/mechglue/g_unseal.c | 28 ++- src/lib/gssapi/mechglue/g_verify.c | 28 ++- src/lib/gssapi/mechglue/get_mechanism.c | 36 --- src/lib/gssapi/mechglue/get_mtype.c | 69 ------ src/lib/gssapi/mechglue/gssd_pname_to_uid.c | 30 ++- src/lib/gssapi/mechglue/internal_name.c | 90 -------- src/lib/gssapi/mechglue/mech.conf | 7 + src/lib/gssapi/mechglue/mechglue.h | 26 ++- src/lib/gssapi/mechglue/mglueP.h | 13 +- 40 files changed, 1115 insertions(+), 454 deletions(-) delete mode 100644 src/lib/gssapi/mechglue/add_mechanism.c create mode 100644 src/lib/gssapi/mechglue/g_glue.c delete mode 100644 src/lib/gssapi/mechglue/get_mechanism.c delete mode 100644 src/lib/gssapi/mechglue/get_mtype.c delete mode 100644 src/lib/gssapi/mechglue/internal_name.c create mode 100644 src/lib/gssapi/mechglue/mech.conf diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog index 2a32d00b2..ef151295a 100644 --- a/src/lib/gssapi/krb5/ChangeLog +++ b/src/lib/gssapi/krb5/ChangeLog @@ -1,3 +1,10 @@ +Tue Feb 6 23:55:45 1996 Theodore Y. Ts'o + + * pname_to_uid.c (krb5_pname_to_uid): Instead of using specialized + code to derive the username from a kerberos principal, use + krb5_aname_to_lname(). Added extra argument for the + context structure. + Fri Jan 26 03:09:32 1996 Sam Hartman * init_sec_context.c (make_ap_req): Make sure we get a DES session key. diff --git a/src/lib/gssapi/krb5/k5mech.c b/src/lib/gssapi/krb5/k5mech.c index 865453582..1efee7b56 100644 --- a/src/lib/gssapi/krb5/k5mech.c +++ b/src/lib/gssapi/krb5/k5mech.c @@ -269,10 +269,11 @@ extern OM_uint32 krb5_gss_get_context ); extern int krb5_pname_to_uid - (char *, /* minor_status */ + (void *, /* context */ + char *, /* principal name */ gss_OID, /* name_type */ gss_OID, /* mech_type */ - uid_t * /* input_name */ + uid_t * /* uid (OUT) */ ); /* diff --git a/src/lib/gssapi/krb5/pname_to_uid.c b/src/lib/gssapi/krb5/pname_to_uid.c index bc7d88a93..1da331fb1 100644 --- a/src/lib/gssapi/krb5/pname_to_uid.c +++ b/src/lib/gssapi/krb5/pname_to_uid.c @@ -3,8 +3,27 @@ * krb5 mechanism specific routine for pname_to_uid * * Copyright 1995 Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. */ +#include "gssapiP_krb5.h" #include #ifdef HAVE_STDLIB_H #include @@ -13,12 +32,13 @@ #include #include -extern char *strpbrk(const char *s1, const char *s2); -extern struct passwd *getpwnam(const char *name); +/* + * This function will probably get replaced with the gsscred stuff... + */ int -krb5_pname_to_uid(pname, name_type, mech_type, uid) - +krb5_pname_to_uid(context, pname, name_type, mech_type, uid) +krb5_context context; char * pname; gss_OID name_type; gss_OID mech_type; @@ -26,67 +46,43 @@ uid_t * uid; { struct passwd *pw; - char *pname_copy, *prefix, *suffix, *default_realm = NULL, - *temp; static unsigned char krb5principalname[] = - {"\052\206\110\206\367\022\001\002\002\001"}; + {"\052\206\110\206\367\022\001\002\002\001"}; + krb5_principal principal; + char lname[256]; + krb5_error_code stat; /* * check that the name_type is the Kerberos Principal Name form * [1.2.840.113554.1.2.2.1] or NULL. */ - if(name_type->length !=0) - if((name_type->length != 10) - || + if((name_type->length != 10) || (memcmp(name_type->elements, krb5principalname, 10) != 0)) return(0); -/* take care of the special case of "root.@realm */ - - if(strncmp(pname, "root.", 5) == 0) { - *uid = 0; - return(1); - } -/* get the name and realm parts of the Kerberos Principal Name */ - - pname_copy = (char *) malloc(strlen(pname)+1); - strcpy(pname_copy, pname); - prefix = pname_copy; - suffix = pname_copy; + /* get the name and realm parts of the Kerberos Principal Name */ - /* find last occurance of "@" */ - - temp = (char *) !NULL; - while(temp != NULL) - suffix = (((temp = strpbrk(suffix, "@")) == NULL) ? - suffix : temp+1); - - if(suffix != pname_copy) - *(suffix-1) = '\0'; + if (krb5_parse_name(context, pname, &principal)) { + return(0); + } -/* Make sure the name is in the local realm */ + stat = krb5_aname_to_localname(context, principal, + sizeof(lname), lname); + krb5_free_principal(context, principal); - if(suffix != pname_copy) { - krb5_get_default_realm(&default_realm); - if(default_realm == NULL || - strcmp(default_realm, suffix) != 0) { - free(pname_copy); - return(0); - } - } + if (stat) + return(0); /* * call getpwnam() and return uid result if successful. * Otherwise, return failure. */ - if(pw = getpwnam(prefix)) { + if(pw = getpwnam(lname)) { *uid = pw->pw_uid; - free(pname_copy); return(1); } else { - free(pname_copy); return(0); } } diff --git a/src/lib/gssapi/mechglue/ChangeLog b/src/lib/gssapi/mechglue/ChangeLog index 143342cd4..7b5a6c5bb 100644 --- a/src/lib/gssapi/mechglue/ChangeLog +++ b/src/lib/gssapi/mechglue/ChangeLog @@ -1,3 +1,9 @@ +Tue Feb 6 23:59:49 1996 Theodore Y. Ts'o + + * g_initialize.c (gss_initialize): Added code to try to + dynamically read in the GSSAPI mechanim library using + dlopen(). + Wed Jan 24 20:49:13 1996 Tom Yu * g_compare_name.c, g_delete_sec_context.c, g_dsp_status.c, diff --git a/src/lib/gssapi/mechglue/Makefile.in b/src/lib/gssapi/mechglue/Makefile.in index a71f2f5e4..0ac0e59b9 100644 --- a/src/lib/gssapi/mechglue/Makefile.in +++ b/src/lib/gssapi/mechglue/Makefile.in @@ -11,6 +11,7 @@ DEPLIBS= SHLIB_LDFLAGS= $(LDFLAGS) @SHLIB_RPATH_DIRS@ \ $(LD_UNRESOLVED_PREFIX)krb5_gss_initialize + SHLIB_LIBDIRS= @SHLIB_LIBDIRS@ SRCS = $(srcdir)/g_acquire_cred.c \ @@ -39,11 +40,8 @@ SRCS = $(srcdir)/g_acquire_cred.c \ $(srcdir)/g_inquire_context.c \ $(srcdir)/g_inquire_names.c \ $(srcdir)/g_initialize.c \ - $(srcdir)/get_mtype.c \ - $(srcdir)/get_mechanism.c \ - $(srcdir)/internal_name.c \ + $(srcdir)/g_glue.c \ $(srcdir)/gssd_pname_to_uid.c \ - $(srcdir)/add_mechanism.c \ $(srcdir)/gen_oids.c \ $(srcdir)/oid_ops.c @@ -73,11 +71,8 @@ OBJS = g_acquire_cred.$(OBJEXT) \ g_inquire_context.$(OBJEXT) \ g_inquire_names.$(OBJEXT) \ g_initialize.$(OBJEXT) \ - get_mtype.$(OBJEXT) \ - get_mechanism.$(OBJEXT) \ - internal_name.$(OBJEXT) \ + g_glue.$(OBJEXT) \ gssd_pname_to_uid.$(OBJEXT) \ - add_mechanism.$(OBJEXT) \ gen_oids.$(OBJEXT) \ oid_ops.$(OBJEXT) diff --git a/src/lib/gssapi/mechglue/add_mechanism.c b/src/lib/gssapi/mechglue/add_mechanism.c deleted file mode 100644 index 843dd19f6..000000000 --- a/src/lib/gssapi/mechglue/add_mechanism.c +++ /dev/null @@ -1,71 +0,0 @@ -#ident "@(#)add_mechanism.c 1.5 95/08/04 SMI" -/* - * This function will add a new mechanism to the mechs_array - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#include "mglueP.h" -#ifdef HAVE_STDLIB_H -#include -#endif -#include -#include - -static struct gss_config null_mech = { - {0,NULL}}; - -gss_mechanism *mechs_array = NULL; - -OM_uint32 add_mechanism (gss_mechanism mech, int replace) -{ - gss_mechanism *temp_array; - int i; - - if (mech == NULL) - return GSS_S_COMPLETE; - - /* initialize the mechs_array if it hasn't already been initialized */ - if (mechs_array == NULL) { - mechs_array = (gss_mechanism *) malloc (sizeof(gss_mechanism)); - - if (mechs_array == NULL) - return ENOMEM; - - mechs_array[0] = &null_mech; - } - - /* - * Find the length of mechs_array, and look for an existing - * entry for this OID - */ - for (i=0; mechs_array[i]->mech_type.length != 0; i++) { - if ((mechs_array[i]->mech_type.length == mech->mech_type.length) && - (memcmp (mechs_array[i]->mech_type.elements, - mech->mech_type.elements, - mech->mech_type.length) == 0)) { - - /* We found a match. Replace it? */ - if (!replace) - return GSS_S_FAILURE; - - mechs_array[i] = mech; - return GSS_S_COMPLETE; - } - } - - /* we didn't find it -- add it to the end of the mechs_array */ - temp_array = (gss_mechanism *) realloc(mechs_array, - (i+2)*sizeof(gss_mechanism)); - - if (temp_array == NULL) - return ENOMEM; - - temp_array[i++] = mech; - temp_array[i] = &null_mech; - - mechs_array = temp_array; - - return GSS_S_COMPLETE; -} diff --git a/src/lib/gssapi/mechglue/g_accept_sec_context.c b/src/lib/gssapi/mechglue/g_accept_sec_context.c index 97693a959..c9cad6053 100644 --- a/src/lib/gssapi/mechglue/g_accept_sec_context.c +++ b/src/lib/gssapi/mechglue/g_accept_sec_context.c @@ -1,9 +1,29 @@ #ident "@(#)gss_accept_sec_context.c 1.19 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_accept_sec_context - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -76,7 +96,7 @@ gss_cred_id_t * delegated_cred_handle; * and copy in the OID */ - get_mech_type(&token_mech_type, input_token_buffer); + __gss_get_mech_type(&token_mech_type, input_token_buffer); union_ctx_id->mech_type->elements = (void *) malloc(token_mech_type->length); @@ -118,7 +138,7 @@ gss_cred_id_t * delegated_cred_handle; * call it. */ - mech = get_mechanism (token_mech_type); + mech = __gss_get_mechanism (token_mech_type); if (mech && mech->gss_accept_sec_context) { status = mech->gss_accept_sec_context( @@ -150,8 +170,8 @@ gss_cred_id_t * delegated_cred_handle; * the union name struct cast to src_name */ - if(src_name != NULL) { - temp_status = display_internal_name ( + if(src_name != NULL && status == GSS_S_COMPLETE) { + temp_status = __gss_display_internal_name ( &temp_minor_status, &mech->mech_type, internal_name, @@ -170,7 +190,7 @@ gss_cred_id_t * delegated_cred_handle; gss_release_buffer( &temp_minor_status, output_token); - release_internal_name(&temp_minor_status, + __gss_release_internal_name(&temp_minor_status, &mech->mech_type, &internal_name); return(GSS_S_FAILURE); @@ -190,7 +210,7 @@ gss_cred_id_t * delegated_cred_handle; gss_release_buffer( &temp_minor_status, output_token); - release_internal_name( + __gss_release_internal_name( &temp_minor_status, &mech->mech_type, &internal_name); @@ -200,7 +220,7 @@ gss_cred_id_t * delegated_cred_handle; return(GSS_S_FAILURE); } - release_internal_name( + __gss_release_internal_name( &temp_minor_status, &mech->mech_type, &internal_name); diff --git a/src/lib/gssapi/mechglue/g_acquire_cred.c b/src/lib/gssapi/mechglue/g_acquire_cred.c index 915642eba..0b601e8f3 100644 --- a/src/lib/gssapi/mechglue/g_acquire_cred.c +++ b/src/lib/gssapi/mechglue/g_acquire_cred.c @@ -1,9 +1,29 @@ #ident "@(#)gss_acquire_cred.c 1.19 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_acquire_cred - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -83,7 +103,7 @@ OM_uint32 * time_rec; */ if(desired_mechs == GSS_C_NULL_OID_SET) { - if ((mech = get_mechanism (NULL)) == NULL) + if ((mech = __gss_get_mechanism (NULL)) == NULL) return (GSS_S_BAD_MECH); desired_mechs = &default_OID_set; @@ -114,7 +134,7 @@ OM_uint32 * time_rec; creds_returned[j].available = 0; - mech = get_mechanism (&desired_mechs->elements[j]); + mech = __gss_get_mechanism (&desired_mechs->elements[j]); if (mech && mech->gss_acquire_cred) { /* @@ -123,7 +143,7 @@ OM_uint32 * time_rec; * gss_acquire_cred() call. */ - if ((status = import_internal_name( + if ((status = __gss_import_internal_name( minor_status, &mech->mech_type, union_name, @@ -143,7 +163,7 @@ OM_uint32 * time_rec; NULL, &temp_time_rec); - if ((temp_status = release_internal_name( + if ((temp_status = __gss_release_internal_name( &temp_minor_status, &mech->mech_type, &internal_name))) { diff --git a/src/lib/gssapi/mechglue/g_compare_name.c b/src/lib/gssapi/mechglue/g_compare_name.c index ec575aa7e..23e8dc7c6 100644 --- a/src/lib/gssapi/mechglue/g_compare_name.c +++ b/src/lib/gssapi/mechglue/g_compare_name.c @@ -1,9 +1,30 @@ #ident "@(#)gss_compare_name.c 1.13 95/08/02 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_compare_name * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" diff --git a/src/lib/gssapi/mechglue/g_context_time.c b/src/lib/gssapi/mechglue/g_context_time.c index 775fd04b2..193d3906c 100644 --- a/src/lib/gssapi/mechglue/g_context_time.c +++ b/src/lib/gssapi/mechglue/g_context_time.c @@ -1,9 +1,29 @@ #ident "@(#)gss_context_time.c 1.8 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routines for gss_context_time - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -33,7 +53,7 @@ OM_uint32 * time_rec; */ ctx = (gss_union_ctx_id_t) context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (mech) { diff --git a/src/lib/gssapi/mechglue/g_delete_sec_context.c b/src/lib/gssapi/mechglue/g_delete_sec_context.c index 5ac2dbf55..6d6551a62 100644 --- a/src/lib/gssapi/mechglue/g_delete_sec_context.c +++ b/src/lib/gssapi/mechglue/g_delete_sec_context.c @@ -1,9 +1,29 @@ #ident "@(#)gss_delete_sec_context.c 1.10 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_delete_sec_context - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -38,7 +58,7 @@ gss_buffer_t output_token; */ ctx = (gss_union_ctx_id_t) *context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (mech) { diff --git a/src/lib/gssapi/mechglue/g_dsp_name.c b/src/lib/gssapi/mechglue/g_dsp_name.c index a0fa17901..4ae8d2c0c 100644 --- a/src/lib/gssapi/mechglue/g_dsp_name.c +++ b/src/lib/gssapi/mechglue/g_dsp_name.c @@ -1,9 +1,30 @@ -#ident "%Z%%M% %I% %E% SMI" +#ident "@(#)g_dsp_name.c 1.2 96/02/06 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_display_name() * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" diff --git a/src/lib/gssapi/mechglue/g_dsp_status.c b/src/lib/gssapi/mechglue/g_dsp_status.c index e31bb5e44..c4b35755e 100644 --- a/src/lib/gssapi/mechglue/g_dsp_status.c +++ b/src/lib/gssapi/mechglue/g_dsp_status.c @@ -1,9 +1,30 @@ #ident "@(#)gss_display_status.c 1.8 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine gss_display_status * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -38,7 +59,7 @@ gss_buffer_t status_string; * call it. */ - mech = get_mechanism (mech_type); + mech = __gss_get_mechanism (mech_type); if (mech == NULL) return (GSS_S_BAD_MECH); diff --git a/src/lib/gssapi/mechglue/g_exp_sec_context.c b/src/lib/gssapi/mechglue/g_exp_sec_context.c index b0b66b50a..2d623c19d 100644 --- a/src/lib/gssapi/mechglue/g_exp_sec_context.c +++ b/src/lib/gssapi/mechglue/g_exp_sec_context.c @@ -2,10 +2,29 @@ #ident "@(#)g_exp_sec_context.c 1.2 96/01/18 SMI" /* - * glue routine gss_export_sec_context - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * glue routine for gss_export_sec_context */ #include "mglueP.h" @@ -38,7 +57,7 @@ gss_buffer_t interprocess_token; */ ctx = (gss_union_ctx_id_t) *context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (mech) { diff --git a/src/lib/gssapi/mechglue/g_glue.c b/src/lib/gssapi/mechglue/g_glue.c new file mode 100644 index 000000000..877605d19 --- /dev/null +++ b/src/lib/gssapi/mechglue/g_glue.c @@ -0,0 +1,209 @@ + +#ident "@(#)g_glue.c 1.1 96/02/06 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "mglueP.h" +extern gss_mechanism *__gss_mechs_array; + +/* + * This file contains the support routines for the glue layer. + */ + +/* + * given the mechs_array and a mechanism OID, return the + * pointer to the mechanism, or NULL if that mechanism is + * not supported. If the requested OID is NULL, then return + * the first mechanism. + */ + +gss_mechanism __gss_get_mechanism (gss_OID type) +{ + int i; + + if (type == GSS_C_NULL_OID) + return (__gss_mechs_array[0]); + + for (i=0; __gss_mechs_array[i]->mech_type.length != 0; i++) { + if ((__gss_mechs_array[i]->mech_type.length == type->length) && + (memcmp (__gss_mechs_array[i]->mech_type.elements, type->elements, + type->length) == 0)) { + + return (__gss_mechs_array[i]); + } + } + return NULL; +} + + +/* + * glue routine for get_mech_type + * + */ + +OM_uint32 __gss_get_mech_type(OID, token) + +gss_OID * OID; +gss_buffer_t token; + +{ + unsigned char * buffer_ptr; + + /* + * This routine reads the prefix of "token" in order to determine + * its mechanism type. It assumes the encoding suggested in + * Appendix B of RFC 1508. This format starts out as follows : + * + * tag for APPLICATION 0, Sequence[constructed, definite length] + * length of remainder of token + * tag of OBJECT IDENTIFIER + * length of mechanism OID + * encoding of mechanism OID + * + * + * Numerically, this looks like : + * + * 0x60 + * - could be multiple bytes + * 0x06 + * - assume only one byte, hence OID length < 127 + * + * + * The routine returns a pointer to the OID value. The return code is + * the length of the OID, if successful; otherwise it is 0. + */ + + if (OID == NULL || *OID == GSS_C_NULL_OID) + return (0); + + /* if the token is a null pointer, return a zero length OID */ + + if(token == NULL) { + (*OID)->length = 0; + (*OID)->elements = NULL; + return (0); + } + + /* Skip past the APP/Sequnce byte and the token length */ + + buffer_ptr = (unsigned char *) token->value; + + while(*(++buffer_ptr) & (1<<7)) + continue; + + /* increment buffer_ptr to point to the OID and return its length */ + + (*OID)->length = (OM_uint32) *(buffer_ptr+3); + (*OID)->elements = (void *) (buffer_ptr+4); + return ((*OID)->length); +} + + +/* + * Internal routines to get and release an internal mechanism name + */ + +#include "mglueP.h" + +OM_uint32 __gss_import_internal_name (minor_status, mech_type, union_name, + internal_name) +OM_uint32 *minor_status; +gss_OID mech_type; +gss_union_name_t union_name; +gss_name_t *internal_name; +{ + OM_uint32 status; + gss_mechanism mech; + + mech = __gss_get_mechanism (mech_type); + if (mech) { + if (mech->gss_import_name) + status = mech->gss_import_name ( + mech->context, + minor_status, + union_name->external_name, + union_name->name_type, + internal_name); + else + status = GSS_S_BAD_BINDINGS; + + return (status); + } + + return (GSS_S_BAD_MECH); +} + +OM_uint32 __gss_display_internal_name (minor_status, mech_type, internal_name, + external_name, name_type) +OM_uint32 *minor_status; +gss_OID mech_type; +gss_name_t internal_name; +gss_buffer_t external_name; +gss_OID *name_type; +{ + OM_uint32 status; + gss_mechanism mech; + + mech = __gss_get_mechanism (mech_type); + if (mech) { + if (mech->gss_display_name) + status = mech->gss_display_name ( + mech->context, + minor_status, + internal_name, + external_name, + name_type); + else + status = GSS_S_BAD_BINDINGS; + + return (status); + } + + return (GSS_S_BAD_MECH); +} + +OM_uint32 __gss_release_internal_name (minor_status, mech_type, internal_name) +OM_uint32 *minor_status; +gss_OID mech_type; +gss_name_t *internal_name; +{ + OM_uint32 status; + gss_mechanism mech; + + mech = __gss_get_mechanism (mech_type); + if (mech) { + if (mech->gss_release_name) + status = mech->gss_release_name ( + mech->context, + minor_status, + internal_name); + else + status = GSS_S_BAD_BINDINGS; + + return (status); + } + + return (GSS_S_BAD_MECH); +} + + diff --git a/src/lib/gssapi/mechglue/g_imp_name.c b/src/lib/gssapi/mechglue/g_imp_name.c index 3a9053cc8..654b0459b 100644 --- a/src/lib/gssapi/mechglue/g_imp_name.c +++ b/src/lib/gssapi/mechglue/g_imp_name.c @@ -1,9 +1,30 @@ -#ident "%Z%%M% %I% %E% SMI" +#ident "@(#)g_imp_name.c 1.2 96/02/06 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine gss_import_name * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -38,8 +59,8 @@ gss_name_t * output_name; return (GSS_S_BAD_NAME); /* - * First create the union name struct that will hold the internal - * name and the mech_type. Then fill in the mech_type. + * First create the union name struct that will hold the external + * name and the name type. */ union_name = (gss_union_name_t) malloc (sizeof(gss_union_name_desc)); @@ -55,11 +76,18 @@ gss_name_t * output_name; union_name->external_name = (gss_buffer_t) malloc(sizeof(gss_buffer_desc)); union_name->external_name->length = input_name_buffer->length; + /* we malloc length+1 to stick a NULL on the end, just in case */ + /* Note that this NULL is not included in ->length for a reason! */ union_name->external_name->value = - (void *) malloc(input_name_buffer->length); + (void *) malloc(input_name_buffer->length+1); memcpy(union_name->external_name->value, input_name_buffer->value, input_name_buffer->length); + /* add NULL to end of external_name->value, just in case... */ + + ((char *)union_name->external_name->value) + [input_name_buffer->length] = '\0'; + union_name->name_type = (gss_OID) input_name_type; *output_name = (gss_name_t) union_name; diff --git a/src/lib/gssapi/mechglue/g_imp_sec_context.c b/src/lib/gssapi/mechglue/g_imp_sec_context.c index 63cd14577..79a6bb2f9 100644 --- a/src/lib/gssapi/mechglue/g_imp_sec_context.c +++ b/src/lib/gssapi/mechglue/g_imp_sec_context.c @@ -1,11 +1,30 @@ #ident "@(#)g_imp_sec_context.c 1.2 96/01/18 SMI" +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine gss_export_sec_context - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -38,7 +57,7 @@ gss_ctx_id_t * context_handle; */ ctx = (gss_union_ctx_id_t) *context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (mech) { diff --git a/src/lib/gssapi/mechglue/g_indicate_mechs.c b/src/lib/gssapi/mechglue/g_indicate_mechs.c index 33d4bdd6f..01cad3f1b 100644 --- a/src/lib/gssapi/mechglue/g_indicate_mechs.c +++ b/src/lib/gssapi/mechglue/g_indicate_mechs.c @@ -1,9 +1,29 @@ #ident "@(#)gss_indicate_mechs.c 1.13 95/08/04 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_indicate_mechs - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -12,7 +32,7 @@ #endif #include -extern gss_mechanism *mechs_array; +extern gss_mechanism *__gss_mechs_array; static gss_OID_set_desc supported_mechs_desc; static gss_OID_set supported_mechs = NULL; @@ -44,7 +64,7 @@ gss_OID_set * mech_set; /* Build the mech_set from the OIDs in mechs_array. */ - for(i=0; mechs_array[i]->mech_type.length != 0; i++) + for(i=0; __gss_mechs_array[i]->mech_type.length != 0; i++) supported_mechs->count++; supported_mechs->elements = @@ -53,12 +73,12 @@ gss_OID_set * mech_set; for(i=0; i < supported_mechs->count; i++) { supported_mechs->elements[i].length = - mechs_array[i]->mech_type.length; + __gss_mechs_array[i]->mech_type.length; supported_mechs->elements[i].elements = (void *) - malloc(mechs_array[i]->mech_type.length); + malloc(__gss_mechs_array[i]->mech_type.length); memcpy(supported_mechs->elements[i].elements, - mechs_array[i]->mech_type.elements, - mechs_array[i]->mech_type.length); + __gss_mechs_array[i]->mech_type.elements, + __gss_mechs_array[i]->mech_type.length); } } diff --git a/src/lib/gssapi/mechglue/g_init_sec_context.c b/src/lib/gssapi/mechglue/g_init_sec_context.c index 91b607382..b9520cb73 100644 --- a/src/lib/gssapi/mechglue/g_init_sec_context.c +++ b/src/lib/gssapi/mechglue/g_init_sec_context.c @@ -1,9 +1,29 @@ #ident "@(#)gss_init_sec_context.c 1.20 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_init_sec_context - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -59,7 +79,7 @@ OM_uint32 FAR * time_rec; * mechanism. If mech_type is NULL, set it to the resultant * mechanism */ - mech = get_mechanism (mech_type); + mech = __gss_get_mechanism (mech_type); if (mech == NULL) return (GSS_S_BAD_MECH); @@ -73,7 +93,7 @@ OM_uint32 FAR * time_rec; union_name = (gss_union_name_t) target_name; - if ((temp_status = import_internal_name ( + if ((temp_status = __gss_import_internal_name ( minor_status, mech_type, union_name, @@ -136,7 +156,7 @@ OM_uint32 FAR * time_rec; } else status = GSS_S_BAD_BINDINGS; - temp_status = release_internal_name( + temp_status = __gss_release_internal_name( &temp_minor_status, mech_type, &internal_name); diff --git a/src/lib/gssapi/mechglue/g_initialize.c b/src/lib/gssapi/mechglue/g_initialize.c index 8325130cf..e65bd1dc2 100644 --- a/src/lib/gssapi/mechglue/g_initialize.c +++ b/src/lib/gssapi/mechglue/g_initialize.c @@ -1,9 +1,29 @@ -#ident "@(#)gss_initialize.c 1.5 95/09/11 SMI" +#ident "@(#)g_initialize.c 1.2 96/02/06 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * This function will initialize the gssapi mechglue library - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -11,10 +31,85 @@ #include #endif +#ifdef USE_SOLARIS_SHARED_LIBRARIES +#include +#include +#include +#include + +#define MECH_CONF "/etc/mech.conf" +#define MECH_SYM "gss_mech_initialize" + +static void solaris_initialize (void); +#endif /* USE_SOLARIS_SHARED_LIBRARIES */ + extern gss_mechanism krb5_gss_initialize(); static int _gss_initialized = 0; +static struct gss_config null_mech = { + {0,NULL}}; + +gss_mechanism *__gss_mechs_array = NULL; + +/* + * This function will add a new mechanism to the mechs_array + */ + +static OM_uint32 +add_mechanism (gss_mechanism mech, int replace) +{ + gss_mechanism *temp_array; + int i; + + if (mech == NULL) + return GSS_S_COMPLETE; + + /* initialize the mechs_array if it hasn't already been initialized */ + if (__gss_mechs_array == NULL) { + __gss_mechs_array = (gss_mechanism *) malloc (sizeof(gss_mechanism)); + + if (__gss_mechs_array == NULL) + return ENOMEM; + + __gss_mechs_array[0] = &null_mech; + } + + /* + * Find the length of __gss_mechs_array, and look for an existing + * entry for this OID + */ + for (i=0; __gss_mechs_array[i]->mech_type.length != 0; i++) { + if ((__gss_mechs_array[i]->mech_type.length == + mech->mech_type.length) && + (memcmp (__gss_mechs_array[i]->mech_type.elements, + mech->mech_type.elements, + mech->mech_type.length) == 0)) { + + /* We found a match. Replace it? */ + if (!replace) + return GSS_S_FAILURE; + + __gss_mechs_array[i] = mech; + return GSS_S_COMPLETE; + } + } + + /* we didn't find it -- add it to the end of the __gss_mechs_array */ + temp_array = (gss_mechanism *) realloc(__gss_mechs_array, + (i+2)*sizeof(gss_mechanism)); + + if (temp_array == NULL) + return ENOMEM; + + temp_array[i++] = mech; + temp_array[i] = &null_mech; + + __gss_mechs_array = temp_array; + + return GSS_S_COMPLETE; +} + void gss_initialize (void) { gss_mechanism mech; @@ -24,6 +119,10 @@ void gss_initialize (void) return; _gss_initialized = 1; +#ifdef USE_SOLARIS_SHARED_LIBRARIES + solaris_initialize(); + +#else /* * Use hard-coded in mechanisms... I need to know what mechanisms * are supported... As more mechanisms become supported, they @@ -35,5 +134,82 @@ void gss_initialize (void) if (mech) add_mechanism (mech, 1); +#endif /* USE_SOLARIS_SHARED_LIBRARIES */ + + if (__gss_mechs_array == NULL) { /* this is very bad! */ + fprintf(stderr,"gss_initialize fatal error: no mechanisms loaded!\n"); + exit(-1); + } + + return; +} + +#ifdef USE_SOLARIS_SHARED_LIBRARIES +/* + * read the configuration file to find out what mechanisms to + * load, load them, and then load the mechanism defitions in + * and add the mechanisms + */ +static void solaris_initialize (void) +{ + char buffer[BUFSIZ], *filename, *symname, *endp; + FILE *conffile; + void *dl; + gss_mechanism (*sym)(void), mech; + + if ((filename = getenv("GSSAPI_MECH_CONF")) == NULL) + filename = MECH_CONF; + + if ((conffile = fopen(filename, "r")) == NULL) + return; + + while (fgets (buffer, BUFSIZ, conffile) != NULL) { + /* ignore lines beginning with # */ + if (*buffer == '#') + continue; + + /* find the first white-space character after the filename */ + for (symname = buffer; *symname && !isspace(*symname); symname++); + + /* Now find the first non-white-space character */ + if (*symname) { + *symname = '\0'; + symname++; + while (*symname && isspace(*symname)) + symname++; + } + + if (! *symname) + symname = MECH_SYM; + else { + /* Find the end of the symname and make sure it is NULL-terminated */ + for (endp = symname; *endp && !isspace(*endp); endp++); + if (*endp) + *endp = '\0'; + } + + if ((dl = dlopen(buffer, RTLD_NOW)) == NULL) { + /* for debugging only */ + fprintf(stderr,"can't open %s: %s\n",buffer, dlerror()); + continue; + } + + if ((sym = (gss_mechanism (*)(void))dlsym(dl, symname)) == NULL) { + dlclose(dl); + continue; + } + + /* Call the symbol to get the mechanism table */ + mech = sym(); + + /* And add the mechanism (or close the shared library) */ + if (mech) + add_mechanism (mech, 1); + else + dlclose(dl); + + } /* while */ + return; } +#endif /* USE_SOLARIS_SHARED_LIBRARIES */ diff --git a/src/lib/gssapi/mechglue/g_inquire_context.c b/src/lib/gssapi/mechglue/g_inquire_context.c index 2d3dfccb0..608f7febd 100644 --- a/src/lib/gssapi/mechglue/g_inquire_context.c +++ b/src/lib/gssapi/mechglue/g_inquire_context.c @@ -1,11 +1,30 @@ #ident "@(#)g_inquire_context.c 1.2 96/01/18 SMI" +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_inquire_context - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -58,7 +77,7 @@ int * open; */ ctx = (gss_union_ctx_id_t) context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (!mech || !mech->gss_inquire_context || !mech->gss_display_name) { return(GSS_S_NO_CONTEXT); diff --git a/src/lib/gssapi/mechglue/g_inquire_cred.c b/src/lib/gssapi/mechglue/g_inquire_cred.c index f2931cafd..cbc1997b0 100644 --- a/src/lib/gssapi/mechglue/g_inquire_cred.c +++ b/src/lib/gssapi/mechglue/g_inquire_cred.c @@ -1,9 +1,29 @@ #ident "@(#)gss_inquire_cred.c 1.9 95/08/02 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_inquire_cred - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" diff --git a/src/lib/gssapi/mechglue/g_inquire_names.c b/src/lib/gssapi/mechglue/g_inquire_names.c index 05548cbe9..0cd5e49a9 100644 --- a/src/lib/gssapi/mechglue/g_inquire_names.c +++ b/src/lib/gssapi/mechglue/g_inquire_names.c @@ -1,11 +1,30 @@ #ident "@(#)g_inquire_names.c 1.1 95/12/19 SMI" +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_inquire_context - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -31,7 +50,7 @@ gss_OID_set * name_types; * call it. */ - mech = get_mechanism (mechanism); + mech = __gss_get_mechanism (mechanism); if (mech) { diff --git a/src/lib/gssapi/mechglue/g_oid_ops.c b/src/lib/gssapi/mechglue/g_oid_ops.c index 91033c403..ee7cac70c 100644 --- a/src/lib/gssapi/mechglue/g_oid_ops.c +++ b/src/lib/gssapi/mechglue/g_oid_ops.c @@ -29,7 +29,7 @@ #include "mglueP.h" /* should include to get protos #include "../generic/gssapiP_generic.h" */ -extern gss_mechanism *mechs_array; +extern gss_mechanism *__gss_mechs_array; OM_uint32 gss_release_oid(minor_status, oid) @@ -45,10 +45,10 @@ gss_release_oid(minor_status, oid) * if no mechanisms recognize the OID, then call the generic version. */ - for(i=0; mechs_array[i]->mech_type.length !=0; i++) { - if (mechs_array[i]->gss_internal_release_oid) { - major_status = mechs_array[i]->gss_internal_release_oid( - mechs_array[i]->context, + for(i=0; __gss_mechs_array[i]->mech_type.length !=0; i++) { + if (__gss_mechs_array[i]->gss_internal_release_oid) { + major_status = __gss_mechs_array[i]->gss_internal_release_oid( + __gss_mechs_array[i]->context, minor_status, oid); if (major_status == GSS_S_COMPLETE) { diff --git a/src/lib/gssapi/mechglue/g_process_context.c b/src/lib/gssapi/mechglue/g_process_context.c index 75ecb32c3..9c94bda32 100644 --- a/src/lib/gssapi/mechglue/g_process_context.c +++ b/src/lib/gssapi/mechglue/g_process_context.c @@ -1,9 +1,29 @@ #ident "@(#)gss_process_context.c 1.9 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine gss_process_context - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -33,7 +53,7 @@ gss_buffer_t token_buffer; */ ctx = (gss_union_ctx_id_t) context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (mech) { diff --git a/src/lib/gssapi/mechglue/g_rel_buffer.c b/src/lib/gssapi/mechglue/g_rel_buffer.c index ef1408386..c13bc72e2 100644 --- a/src/lib/gssapi/mechglue/g_rel_buffer.c +++ b/src/lib/gssapi/mechglue/g_rel_buffer.c @@ -1,9 +1,29 @@ -#ident "%Z%%M% %I% %E% SMI" +#ident "@(#)g_rel_buffer.c 1.2 96/02/06 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_release_buffer - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" diff --git a/src/lib/gssapi/mechglue/g_rel_cred.c b/src/lib/gssapi/mechglue/g_rel_cred.c index 6f953da70..ea11a08aa 100644 --- a/src/lib/gssapi/mechglue/g_rel_cred.c +++ b/src/lib/gssapi/mechglue/g_rel_cred.c @@ -1,9 +1,29 @@ #ident "@(#)gss_release_cred.c 1.15 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_release_cred - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -50,7 +70,7 @@ gss_cred_id_t * cred_handle; for(j=0; j < union_cred->count; j++) { - mech = get_mechanism (&union_cred->mechs_array[j]); + mech = __gss_get_mechanism (&union_cred->mechs_array[j]); if (union_cred->mechs_array[j].elements) free(union_cred->mechs_array[j].elements); diff --git a/src/lib/gssapi/mechglue/g_rel_name.c b/src/lib/gssapi/mechglue/g_rel_name.c index 06fd0a36a..dd6358af0 100644 --- a/src/lib/gssapi/mechglue/g_rel_name.c +++ b/src/lib/gssapi/mechglue/g_rel_name.c @@ -1,9 +1,29 @@ #ident "@(#)gss_release_name.c 1.2 95/05/09 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_release_name - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" diff --git a/src/lib/gssapi/mechglue/g_rel_oid_set.c b/src/lib/gssapi/mechglue/g_rel_oid_set.c index 4bcdd3e08..0f6fb43f8 100644 --- a/src/lib/gssapi/mechglue/g_rel_oid_set.c +++ b/src/lib/gssapi/mechglue/g_rel_oid_set.c @@ -1,9 +1,29 @@ #ident "@(#)gss_release_oid_set.c 1.12 95/08/23 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_release_oid_set - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -19,8 +39,8 @@ OM_uint32 * minor_status; gss_OID_set * set; { size_t index; - OM_uint32 status; - + OM_uint32 temp_minor; + gss_OID oid; if (minor_status) *minor_status = 0; @@ -30,8 +50,10 @@ gss_OID_set * set; if (*set == GSS_C_NULL_OID_SET) return(GSS_S_COMPLETE); - for (index=0; index<(*set)->count; index++) - free((*set)->elements[index].elements); + for (index=0; index<(*set)->count; index++) { + oid = &(*set)->elements[index]; + gss_release_oid(&temp_minor, &oid); + } free((*set)->elements); free(*set); diff --git a/src/lib/gssapi/mechglue/g_seal.c b/src/lib/gssapi/mechglue/g_seal.c index 0981b73ed..7512cecc4 100644 --- a/src/lib/gssapi/mechglue/g_seal.c +++ b/src/lib/gssapi/mechglue/g_seal.c @@ -1,9 +1,29 @@ #ident "@(#)gss_seal.c 1.10 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_seal - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -41,7 +61,7 @@ gss_buffer_t output_message_buffer; */ ctx = (gss_union_ctx_id_t) context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (mech) { if (mech->gss_seal) diff --git a/src/lib/gssapi/mechglue/g_sign.c b/src/lib/gssapi/mechglue/g_sign.c index 98092337d..19e386a5b 100644 --- a/src/lib/gssapi/mechglue/g_sign.c +++ b/src/lib/gssapi/mechglue/g_sign.c @@ -1,9 +1,29 @@ #ident "@(#)gss_sign.c 1.10 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine gss_sign - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -37,7 +57,7 @@ gss_buffer_t msg_token; */ ctx = (gss_union_ctx_id_t) context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (mech) { if (mech->gss_sign) diff --git a/src/lib/gssapi/mechglue/g_unseal.c b/src/lib/gssapi/mechglue/g_unseal.c index 0a1bd846b..f3f77c621 100644 --- a/src/lib/gssapi/mechglue/g_unseal.c +++ b/src/lib/gssapi/mechglue/g_unseal.c @@ -1,9 +1,29 @@ #ident "@(#)gss_unseal.c 1.10 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine gss_unseal - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -39,7 +59,7 @@ int * qop_state; */ ctx = (gss_union_ctx_id_t) context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (mech) { if (mech->gss_unseal) diff --git a/src/lib/gssapi/mechglue/g_verify.c b/src/lib/gssapi/mechglue/g_verify.c index 0d3b890d4..d7ca76402 100644 --- a/src/lib/gssapi/mechglue/g_verify.c +++ b/src/lib/gssapi/mechglue/g_verify.c @@ -1,9 +1,29 @@ #ident "@(#)gss_verify.c 1.9 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routine for gss_verify - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -37,7 +57,7 @@ int * qop_state; */ ctx = (gss_union_ctx_id_t) context_handle; - mech = get_mechanism (ctx->mech_type); + mech = __gss_get_mechanism (ctx->mech_type); if (mech) { if (mech->gss_verify) diff --git a/src/lib/gssapi/mechglue/get_mechanism.c b/src/lib/gssapi/mechglue/get_mechanism.c deleted file mode 100644 index ef600fd8d..000000000 --- a/src/lib/gssapi/mechglue/get_mechanism.c +++ /dev/null @@ -1,36 +0,0 @@ -#ident "@(#)get_mechanism.c 1.10 95/08/04 SMI" -/* - * given the mechs_array and a mechanism OID, return the - * pointer to the mechanism, or NULL if that mechanism is - * not supported. If the requested OID is NULL, then return - * the first mechanism. - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#include "mglueP.h" -#ifdef HAVE_STDLIB_H -#include -#endif -#include - -extern gss_mechanism *mechs_array; - -gss_mechanism get_mechanism (gss_OID type) -{ - int i; - - if (type == GSS_C_NULL_OID) - return (mechs_array[0]); - - for (i=0; mechs_array[i]->mech_type.length != 0; i++) { - if ((mechs_array[i]->mech_type.length == type->length) && - (memcmp (mechs_array[i]->mech_type.elements, type->elements, - type->length) == 0)) { - - return (mechs_array[i]); - } - } - return NULL; -} diff --git a/src/lib/gssapi/mechglue/get_mtype.c b/src/lib/gssapi/mechglue/get_mtype.c deleted file mode 100644 index 618b344d3..000000000 --- a/src/lib/gssapi/mechglue/get_mtype.c +++ /dev/null @@ -1,69 +0,0 @@ -#ident "@(#)get_mech_type.c 1.4 95/06/08 SMI" -/* - * glue routine for get_mech_type - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#include "mglueP.h" -#ifdef HAVE_STDLIB_H -#include -#endif - -OM_uint32 get_mech_type(OID, token) - -gss_OID * OID; -gss_buffer_t token; - -{ - unsigned char * buffer_ptr; - - /* - * This routine reads the prefix of "token" in order to determine - * its mechanism type. It assumes the encoding suggested in - * Appendix B of RFC 1508. This format starts out as follows : - * - * tag for APPLICATION 0, Sequence[constructed, definite length] - * length of remainder of token - * tag of OBJECT IDENTIFIER - * length of mechanism OID - * encoding of mechanism OID - * - * - * Numerically, this looks like : - * - * 0x60 - * - could be multiple bytes - * 0x06 - * - assume only one byte, hence OID length < 127 - * - * - * The routine returns a pointer to the OID value. The return code is - * the length of the OID, if successful; otherwise it is 0. - */ - - if (OID == NULL || *OID == GSS_C_NULL_OID) - return (0); - - /* if the token is a null pointer, return a zero length OID */ - - if(token == NULL) { - (*OID)->length = 0; - (*OID)->elements = NULL; - return (0); - } - - /* Skip past the APP/Sequnce byte and the token length */ - - buffer_ptr = (unsigned char *) token->value; - - while(*(++buffer_ptr) & (1<<7)) - continue; - - /* increment buffer_ptr to point to the OID and return its length */ - - (*OID)->length = (OM_uint32) *(buffer_ptr+3); - (*OID)->elements = (void *) (buffer_ptr+4); - return ((*OID)->length); -} diff --git a/src/lib/gssapi/mechglue/gssd_pname_to_uid.c b/src/lib/gssapi/mechglue/gssd_pname_to_uid.c index e99e85f20..d3c18edaf 100644 --- a/src/lib/gssapi/mechglue/gssd_pname_to_uid.c +++ b/src/lib/gssapi/mechglue/gssd_pname_to_uid.c @@ -1,12 +1,33 @@ #ident "@(#)gssd_pname_to_uid.c 1.5 95/08/02 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * glue routines that test the mech id either passed in to * gss_init_sec_contex() or gss_accept_sec_context() or within the glue * routine supported version of the security context and then call * the appropriate underlying mechanism library procedure. * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #include "mglueP.h" @@ -28,14 +49,15 @@ uid_t * uid; * call it. */ - mech = get_mechanism (mech_type); + mech = __gss_get_mechanism (mech_type); if (mech) { if (mech_type == GSS_C_NULL_OID) mech_type = &mech->mech_type; if (mech->pname_to_uid) - status = mech->pname_to_uid(pname, name_type, mech_type, uid); + status = mech->pname_to_uid(mech->context, + pname, name_type, mech_type, uid); else status = GSS_S_BAD_MECH; } else diff --git a/src/lib/gssapi/mechglue/internal_name.c b/src/lib/gssapi/mechglue/internal_name.c deleted file mode 100644 index 7657a2b34..000000000 --- a/src/lib/gssapi/mechglue/internal_name.c +++ /dev/null @@ -1,90 +0,0 @@ -#ident "@(#)internal_name.c 1.5 95/08/07 SMI" -/* - * Internal routines to get and release an internal mechanism name - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#include "mglueP.h" - -OM_uint32 import_internal_name (minor_status, mech_type, union_name, - internal_name) -OM_uint32 *minor_status; -gss_OID mech_type; -gss_union_name_t union_name; -gss_name_t *internal_name; -{ - OM_uint32 status; - gss_mechanism mech; - - mech = get_mechanism (mech_type); - if (mech) { - if (mech->gss_import_name) - status = mech->gss_import_name ( - mech->context, - minor_status, - union_name->external_name, - union_name->name_type, - internal_name); - else - status = GSS_S_BAD_BINDINGS; - - return (status); - } - - return (GSS_S_BAD_MECH); -} - -OM_uint32 display_internal_name (minor_status, mech_type, internal_name, - external_name, name_type) -OM_uint32 *minor_status; -gss_OID mech_type; -gss_name_t internal_name; -gss_buffer_t external_name; -gss_OID *name_type; -{ - OM_uint32 status; - gss_mechanism mech; - - mech = get_mechanism (mech_type); - if (mech) { - if (mech->gss_display_name) - status = mech->gss_display_name ( - mech->context, - minor_status, - internal_name, - external_name, - name_type); - else - status = GSS_S_BAD_BINDINGS; - - return (status); - } - - return (GSS_S_BAD_MECH); -} - -OM_uint32 release_internal_name (minor_status, mech_type, internal_name) -OM_uint32 *minor_status; -gss_OID mech_type; -gss_name_t *internal_name; -{ - OM_uint32 status; - gss_mechanism mech; - - mech = get_mechanism (mech_type); - if (mech) { - if (mech->gss_release_name) - status = mech->gss_release_name ( - mech->context, - minor_status, - internal_name); - else - status = GSS_S_BAD_BINDINGS; - - return (status); - } - - return (GSS_S_BAD_MECH); -} diff --git a/src/lib/gssapi/mechglue/mech.conf b/src/lib/gssapi/mechglue/mech.conf new file mode 100644 index 000000000..5257a01a2 --- /dev/null +++ b/src/lib/gssapi/mechglue/mech.conf @@ -0,0 +1,7 @@ +# +# +# GSSAPI Mechanism Definitions +# +# library function +/opt/SUNWgss/lib/mech_krb5.so krb5_gss_initialize +#mech_krb5.so krb5_gss_initialize diff --git a/src/lib/gssapi/mechglue/mechglue.h b/src/lib/gssapi/mechglue/mechglue.h index 304bcfb66..d6848cb85 100644 --- a/src/lib/gssapi/mechglue/mechglue.h +++ b/src/lib/gssapi/mechglue/mechglue.h @@ -1,9 +1,29 @@ #ident "@(#)mechglue.h 1.13 95/08/07 SMI" + +/* + * Copyright 1996 by Sun Microsystems, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Sun Microsystems not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + /* * This header contains the mechglue definitions. - * - * Copyright (c) 1995, by Sun Microsystems, Inc. - * All rights reserved. */ #ifndef _GSS_MECHGLUE_H diff --git a/src/lib/gssapi/mechglue/mglueP.h b/src/lib/gssapi/mechglue/mglueP.h index bc5110015..cd881d060 100644 --- a/src/lib/gssapi/mechglue/mglueP.h +++ b/src/lib/gssapi/mechglue/mglueP.h @@ -302,6 +302,7 @@ typedef struct gss_config { )); int (*pname_to_uid) NPROTOTYPE(( + void *, /* context */ char *, /* pname */ gss_OID, /* name type */ gss_OID, /* mech type */ @@ -313,19 +314,17 @@ typedef struct gss_config { /********************************************************/ /* Internal mechglue routines */ -gss_mechanism get_mechanism +gss_mechanism __gss_get_mechanism PROTOTYPE((gss_OID)); -OM_uint32 add_mechanism -PROTOTYPE((gss_mechanism, int)); -OM_uint32 get_mech_type +OM_uint32 __gss_get_mech_type PROTOTYPE((gss_OID *, gss_buffer_t)); -OM_uint32 import_internal_name +OM_uint32 __gss_import_internal_name PROTOTYPE((OM_uint32 *, gss_OID, gss_union_name_t, gss_name_t *)); -OM_uint32 display_internal_name +OM_uint32 __gss_display_internal_name PROTOTYPE((OM_uint32 *, gss_OID, gss_name_t, gss_buffer_t, gss_OID *)); -OM_uint32 release_internal_name +OM_uint32 __gss_release_internal_name PROTOTYPE((OM_uint32 *, gss_OID, gss_name_t *)); OM_uint32 generic_gss_release_oid -- 2.26.2