Periodic commit.
authorMark Donnelly <mark@painless-security.com>
Mon, 23 Dec 2013 15:00:14 +0000 (10:00 -0500)
committerMark Donnelly <mark@painless-security.com>
Mon, 23 Dec 2013 15:00:14 +0000 (10:00 -0500)
* Found where the JS wasn't handling pointers well in str_to_oid, fixed.
* Now back to using the SPNEGO mechanism as default in the convenience
  function, rather than GSS_C_NO_OID.
* Added some more logging output around the results of
  gss_init_sec_context.

gssapi_utils/gssapi_utils.c
xpi/lib/main.js

index 8d43643..3361cee 100644 (file)
@@ -39,6 +39,21 @@ gss_construct_sec_context(
     status->major = GSS_S_CALL_INACCESSIBLE_READ;
     return(1);
   }
+  else
+  {
+    OM_uint32 maj;
+    OM_uint32 min;
+    gss_buffer_desc printable;
+    gss_OID nametype;
+
+    maj = gss_display_name(&min, target_name, &printable, &nametype);
+    
+    fprintf(stderr, "target_name:\n");
+    fprintf(stderr, "    value: %s\n", (char *)(printable.value) );
+    fprintf(stderr, "    nametype: [ length: %u, elements: %s ]\n",
+           nametype->length,
+           (char *)(nametype->elements));
+  }
   
   if (mech_type == NULL)
   {
@@ -47,17 +62,22 @@ gss_construct_sec_context(
     OM_uint32 maj = 0;
     OM_uint32 min = 0;
     gss_buffer_desc spnego_str;
+
+    char *elems;
     
     spnego_str.value = "1.3.6.1.5.5.2";
     spnego_str.length = 13;
     mech_type = (gss_OID)malloc(sizeof(gss_OID_desc));
     maj = gss_str_to_oid(&min, &spnego_str, &mech_type);
+
+    elems = (char *)malloc(mech_type->length + 1);
+    strncpy(elems, (char *)(mech_type->elements), mech_type->length);
+    elems[mech_type->length] = '\0';
     fprintf(stderr, "str_to_oid major/minor %u/%u\n", maj, min);
     fprintf(stderr, "mech_type: [length: %u, elements: %s]\n",
            mech_type->length,
-           (char *)(mech_type->elements));
+           elems);
   }
-  mech_type = GSS_C_NO_OID;
   
   /* Main processing */
   
@@ -75,9 +95,20 @@ gss_construct_sec_context(
                                        &ret_flags,
                                        &time_rec);
 
-  if (status->minor != 0)
+  if (status->major != 0)
   {
-    fprintf(stderr, "minor status is: %d/%s\n", status->minor, strerror(status->minor));
+    OM_uint32 maj;
+    OM_uint32 min;
+    OM_uint32 context = 0;
+    gss_buffer_desc statbuf;
+    
+    fprintf(stderr, "major status is: 0x%x\n", status->major);
+    do {
+      maj = gss_display_status(&min, status->major, GSS_C_GSS_CODE, 
+                              mech_type, &context, &statbuf);
+      fprintf(stderr, "Major status: %s\n", (char *)(statbuf.value));
+    } while(context != 0);
+    
     if (actual_mech_type == NULL)
       fprintf(stderr, "actual mech type is NULL.\n");
     else
@@ -88,6 +119,20 @@ gss_construct_sec_context(
     }
     
   }
+  if (status->minor != 0)
+  {
+    OM_uint32 maj;
+    OM_uint32 min;
+    OM_uint32 context = 0;
+    gss_buffer_desc statbuf;
+    
+    fprintf(stderr, "minor status is: %d/%s\n", status->minor, strerror(status->minor));
+    do {
+      maj = gss_display_status(&min, status->minor, GSS_C_MECH_CODE, 
+                              mech_type, &context, &statbuf);
+      fprintf(stderr, "Minor status: %s\n", (char *)(statbuf.value));
+    } while(context != 0);
+  }    
   return(0);
 }
 
index 4769e2f..6bd10ae 100644 (file)
@@ -91,14 +91,16 @@ function str_to_oid(oid_str)
     minStatus = new ctypes.uint32_t(0);
     var majStatus;
     
-    myDump("Abotut to str_to_oid");
+    myDump("Abotut to str_to_oid: " + oid_str);
     majStatus = gss_str_to_oid(
        minStatus.address(), 
        buffer.address(), 
        oid_ptr.address() );
     myDump("Finished the str_to_oid: " + majStatus + "/" + minStatus);
     
-    return(oid);
+    myDump("   returned oid: [ length: " + oid_ptr.contents.length + " ]");
+    
+    return(oid_ptr.contents);
 }
 
 function import_name(name)
@@ -112,6 +114,9 @@ function import_name(name)
     var minor           = new ctypes.uint32_t(0);
     var major;
     
+    var printable = new gss_buffer_t_struct();
+    var printtype = new gss_OID();
+    
     major = gss_import_name(
        minor.address(),
        name_buffer.address(),
@@ -120,6 +125,16 @@ function import_name(name)
     );
     myDump("Finished the gss_import_name: " + major + "/" + minor);
     
+    major = gss_display_name(
+       minor.address(),
+       output_name_ptr,
+       printable.address(),
+       printtype.address()
+    );
+    myDump("Display name: [ length: " + printable.length + 
+          " value: " + printable.value + " ]");
+    myDump("Display name type: [ length: " + printtype.length + " ]");
+    
     return(output_name_ptr);
 }
 
@@ -153,6 +168,15 @@ try{
         gss_OID.ptr);        /* arg: oid */
     myDump("gss_str_to_oid function is " + gss_str_to_oid);
 
+    const gss_display_name = libkrb5.declare("gss_display_name",
+        ctypes.default_abi, 
+        ctypes.uint32_t,     /* Return value           */
+        ctypes.uint32_t.ptr, /* arg: minor_status */
+        gss_name_t.ptr,      /* arg: input_name */
+        gss_buffer_t,        /* arg: output_name_buffer */
+        gss_OID.ptr);        /* arg: ouptut_name_type */
+    myDump("gss_str_to_oid function is " + gss_str_to_oid);
+
     const gss_import_name = libkrb5.declare("gss_import_name", 
         ctypes.default_abi, 
         ctypes.uint32_t,     /* Return value           */