g_imp_name.c (gss_import_name): If the user passes in a name-type
authorTheodore Tso <tytso@mit.edu>
Sat, 24 Feb 1996 05:05:48 +0000 (05:05 +0000)
committerTheodore Tso <tytso@mit.edu>
Sat, 24 Feb 1996 05:05:48 +0000 (05:05 +0000)
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

src/lib/gssapi/mechglue/ChangeLog
src/lib/gssapi/mechglue/Makefile.in
src/lib/gssapi/mechglue/g_dsp_name.c
src/lib/gssapi/mechglue/g_imp_name.c
src/lib/gssapi/mechglue/g_rel_name.c
src/lib/gssapi/mechglue/mglueP.h
src/lib/gssapi/mechglue/oid_ops.c

index 9e1eb87becd702ddf1790eac3ce2ab5f41788cd1..7ec33e1360c61e1cbd38e6ea9627c1fe648e439c 100644 (file)
@@ -1,4 +1,35 @@
-=======
+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
index 0ac0e59b9cc162d6037d877da9186b87a9185bef..82e6429bffabc729bfc8e0b563d79d4d478f0a12 100644 (file)
@@ -43,7 +43,8 @@ SRCS  = $(srcdir)/g_acquire_cred.c \
          $(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) \
@@ -74,7 +75,8 @@ OBJS  = g_acquire_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
index 4ae8d2c0c979bfb839dcb0a541617433597a94f4..86d1ec19b331ea4dfb23d443613138405c989243 100644 (file)
@@ -45,23 +45,39 @@ gss_buffer_t                output_name_buffer;
 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 =
index 654b0459b6de493f2bf7a57c783335c78cc041ba..637acfa573135b2c788408ba1ff9b31d2617ee4c 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 #endif
 #include <string.h>
+#include <errno.h>
 
 OM_uint32
 gss_import_name(minor_status,
@@ -46,6 +47,10 @@ gss_name_t *         output_name;
 
 {
     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;
@@ -55,6 +60,8 @@ gss_name_t *          output_name;
     if(output_name == NULL)
        return (GSS_S_COMPLETE);
 
+    *output_name = 0;
+
     if (input_name_buffer == GSS_C_NO_BUFFER)
        return (GSS_S_BAD_NAME);
 
@@ -64,6 +71,14 @@ gss_name_t *         output_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.
@@ -72,25 +87,68 @@ gss_name_t *                output_name;
      * 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);
 }
index dd6358af0abb00bc7b8438f7094bbb925b628da7..493266e7c50826b4fefbcc0eab72f76867492b0c 100644 (file)
@@ -58,9 +58,19 @@ gss_name_t *         input_name;
     
     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);
index cd881d06049a727be10b0ac109f4889e956ac624..d4a2715342011cf16accea0695fdaef6e7feda54 100644 (file)
@@ -21,13 +21,29 @@ typedef struct gss_union_ctx_id_t {
 } 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
  */
@@ -332,6 +348,12 @@ PROTOTYPE( (OM_uint32 *,   /* minor_status */
            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 */
@@ -363,5 +385,14 @@ PROTOTYPE( (OM_uint32 *,   /* minor_status */
           ));
 
 
+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 */
index 2db42af67dd22d836d360a1ca486beacf04ba906..a3001985807d9c7197d61f5f1a96ee28bb4629f5 100644 (file)
@@ -69,6 +69,31 @@ generic_gss_release_oid(minor_status, oid)
     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;