which is mechanism specific, then import it immediately; don't lazy
evaluate it.
g_mechname.c (gss_add_mech_name_type): New file for maintaining a
registry of name-types which are mechanism specific.
g_dsp_name.c (gss_display_name): If there is a mechanism specific
name, use it when displaying the name.
oid_ops.c (generic_gss_copy_oid): New function used to copy an OID
object.
g_rel_name.c (gss_release_name): Release the OID in the mechanism
name, as it is now allocated. Release the mechanism-specific name if
it is present.
g_imp_name.c (gss_import_name): Copy the input OID, so we don't
have to worry about memory allocation problems later.
oid_ops.c (generic_gss_copy_oid): Added new function to copy OIDs.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7513
dc483132-0cff-0310-8789-
dd5450dbe970
-=======
+Sat Feb 24 00:00:27 1996 Theodore Y. Ts'o <tytso@dcl>
+
+ * g_imp_name.c (gss_import_name): If the user passes in a
+ name-type which is mechanism specific, then import it
+ immediately; don't lazy evaluate it.
+
+ * g_mechname.c (gss_add_mech_name_type): New file for maintaining
+ a registry of name-types which are mechanism specific.
+
+ * g_dsp_name.c (gss_display_name): If there is a mechanism
+ specific name, use it when displaying the name.
+
+ * oid_ops.c (generic_gss_copy_oid): New function used to copy an
+ OID object.
+
+Fri Feb 23 18:27:20 1996 Theodore Y. Ts'o <tytso@dcl>
+
+ * g_rel_name.c (gss_release_name): Release the OID in the
+ mechanism name, as it is now allocated. Release the
+ mechanism-specific name if it is present.
+
+ * g_imp_name.c (gss_import_name): Copy the input OID, so we don't
+ have to worry about memory allocation problems later.
+ Initialize mech_type and mech_name in the union name to be
+ zero. (for now)
+
+ * oid_ops.c (generic_gss_copy_oid): Added new function to copy OIDs.
+
+Thu Feb 22 21:48:44 1996 Theodore Y. Ts'o <tytso@dcl>
+
+ * mglueP.h: Add space for the mechanism name in gss_union_name.
+
Sat Feb 10 18:38:43 1996 Tom Yu <tlyu@dragons-lair.MIT.EDU>
* g_glue.c: grab stdlib.h to get NULL
$(srcdir)/g_glue.c \
$(srcdir)/gssd_pname_to_uid.c \
$(srcdir)/gen_oids.c \
- $(srcdir)/oid_ops.c
+ $(srcdir)/oid_ops.c \
+ $(srcdir)/g_mechname.c
OBJS = g_acquire_cred.$(OBJEXT) \
g_rel_cred.$(OBJEXT) \
g_glue.$(OBJEXT) \
gssd_pname_to_uid.$(OBJEXT) \
gen_oids.$(OBJEXT) \
- oid_ops.$(OBJEXT)
+ oid_ops.$(OBJEXT) \
+ g_mechname.$(OBJEXT)
EHDRDIR= $(BUILDTOP)$(S)include$(S)gssapi
EXPORTED_HEADERS = mechglue.h
gss_OID * output_name_type;
{
+ OM_uint32 major_status;
gss_union_name_t union_name;
- /*
- * copy the value of the external_name component of the union
- * name into the output_name_buffer and point the output_name_type
- * to the name_type component of union_name
- */
-
if (input_name == 0)
return GSS_S_BAD_NAME;
union_name = (gss_union_name_t) input_name;
+
+ if (union_name->mech_type) {
+ /*
+ * OK, we have a mechanism-specific name; let's use it!
+ */
+ return (__gss_display_internal_name(minor_status,
+ union_name->mech_type,
+ union_name->mech_name,
+ output_name_buffer,
+ output_name_type));
+ }
- if(output_name_type != NULL)
- *output_name_type = union_name->name_type;
+ /*
+ * copy the value of the external_name component of the union
+ * name into the output_name_buffer and point the output_name_type
+ * to the name_type component of union_name
+ */
+ if (output_name_type != NULL) {
+ major_status = generic_gss_copy_oid(minor_status,
+ union_name->name_type,
+ output_name_type);
+ if (major_status)
+ return (major_status);
+ }
- if(output_name_buffer != NULL) {
+ if (output_name_buffer != NULL) {
output_name_buffer->length = union_name->external_name->length;
output_name_buffer->value =
#include <stdlib.h>
#endif
#include <string.h>
+#include <errno.h>
OM_uint32
gss_import_name(minor_status,
{
gss_union_name_t union_name;
+ OM_uint32 tmp, major_status = GSS_S_FAILURE;
+ gss_OID mech;
+
+ gss_initialize();
if (minor_status)
*minor_status = 0;
if(output_name == NULL)
return (GSS_S_COMPLETE);
+ *output_name = 0;
+
if (input_name_buffer == GSS_C_NO_BUFFER)
return (GSS_S_BAD_NAME);
*/
union_name = (gss_union_name_t) malloc (sizeof(gss_union_name_desc));
+ if (!union_name) {
+ *minor_status = ENOMEM;
+ goto allocation_failure;
+ }
+ union_name->mech_type = 0;
+ union_name->mech_name = 0;
+ union_name->name_type = 0;
+ union_name->external_name = 0;
/*
* All we do here is record the external name and name_type.
* is assumed to be constant, so only a pointer to it is stored in
* union_name
*/
-
union_name->external_name =
(gss_buffer_t) malloc(sizeof(gss_buffer_desc));
+ if (!union_name->external_name) {
+ *minor_status = ENOMEM;
+ goto allocation_failure;
+ }
+
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+1);
+ if (!union_name->external_name->value) {
+ *minor_status = ENOMEM;
+ goto allocation_failure;
+ }
+
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;
+ major_status = generic_gss_copy_oid(minor_status, input_name_type,
+ &union_name->name_type);
+ if (major_status != GSS_S_COMPLETE)
+ goto allocation_failure;
+
+ mech = gss_find_mechanism_from_name_type(input_name_type);
+ if (mech) {
+ major_status = generic_gss_copy_oid(minor_status, mech,
+ &union_name->mech_type);
+ if (major_status != GSS_S_COMPLETE)
+ goto allocation_failure;
+
+ major_status = __gss_import_internal_name(minor_status, mech,
+ union_name,
+ &union_name->mech_name);
+ if (major_status)
+ goto allocation_failure;
+ }
*output_name = (gss_name_t) union_name;
return(GSS_S_COMPLETE);
+
+allocation_failure:
+ if (union_name) {
+ if (union_name->external_name) {
+ if (union_name->external_name->value)
+ free(union_name->external_name->value);
+ free(union_name->external_name);
+ }
+ if (union_name->name_type)
+ generic_gss_release_oid(&tmp, &union_name->name_type);
+ if (union_name->mech_name)
+ __gss_release_internal_name(minor_status, union_name->mech_type,
+ &union_name->mech_name);
+ if (union_name->mech_type)
+ generic_gss_release_oid(&tmp, &union_name->mech_type);
+ free(union_name);
+ }
+ return (major_status);
}
if (union_name == NULL)
return GSS_S_BAD_NAME;
+
+ if (union_name->name_type)
+ generic_gss_release_oid(minor_status, &union_name->name_type);
free(union_name->external_name->value);
free(union_name->external_name);
+
+ if (union_name->mech_type) {
+ __gss_release_internal_name(minor_status, union_name->mech_type,
+ &union_name->mech_name);
+ generic_gss_release_oid(minor_status, &union_name->mech_type);
+ }
+
free(union_name);
return(GSS_S_COMPLETE);
} gss_union_ctx_id_desc, *gss_union_ctx_id_t;
/*
- * Array of names typed by the name OID (XXX - mechanism OID?)
+ * Generic GSSAPI names. A name can either be a generic name, or a
+ * mechanism specific name....
*/
typedef struct gss_union_name_t {
gss_OID name_type;
gss_buffer_t external_name;
+ /*
+ * These last two fields are only filled in for mechanism
+ * names.
+ */
+ gss_OID mech_type;
+ gss_name_t mech_name;
} gss_union_name_desc, *gss_union_name_t;
+/*
+ * Structure for holding list of mechanism-specific name types
+ */
+typedef struct gss_mech_spec_name_t {
+ gss_OID name_type;
+ gss_OID mech;
+ struct gss_mech_spec_name_t *next, *prev;
+} gss_mech_spec_name_desc, *gss_mech_spec_name;
+
/*
* Credential auxiliary info, used in the credential structure
*/
gss_OID * /* oid */
));
+OM_uint32 generic_gss_copy_oid
+PROTOTYPE( (OM_uint32 *, /* minor_status */
+ gss_OID, /* oid */
+ gss_OID * /* new_oid */
+ ));
+
OM_uint32 generic_gss_create_empty_oid_set
PROTOTYPE( (OM_uint32 *, /* minor_status */
gss_OID_set * /* oid_set */
));
+gss_OID gss_find_mechanism_from_name_type
+PROTOTYPE ( (gss_OID /* name_type */
+ ));
+
+OM_uint32 gss_add_mech_name_type
+PROTOTYPE ( (OM_uint32 *, /* minor_status */
+ gss_OID, /* name_type */
+ gss_OID /* mech */
+ ));
#endif /* _GSS_MECHGLUEP_H */
return(GSS_S_COMPLETE);
}
+OM_uint32
+generic_gss_copy_oid(minor_status, oid, new_oid)
+ OM_uint32 *minor_status;
+ gss_OID oid, *new_oid;
+{
+ gss_OID p;
+
+ p = (gss_OID) malloc(sizeof(gss_OID_desc));
+ if (!p) {
+ *minor_status = ENOMEM;
+ return GSS_S_FAILURE;
+ }
+ p->length = oid->length;
+ p->elements = malloc(p->length);
+ if (!p->elements) {
+ free(p);
+ *minor_status = ENOMEM;
+ return GSS_S_FAILURE;
+ }
+ memcpy(p->elements, oid->elements, p->length);
+ *new_oid = p;
+ return(GSS_S_COMPLETE);
+}
+
+
OM_uint32
generic_gss_create_empty_oid_set(minor_status, oid_set)
OM_uint32 *minor_status;