acquire_cred.c: revert previous change, it breaks the test suite
authorKen Raeburn <raeburn@mit.edu>
Fri, 19 Mar 2004 23:25:17 +0000 (23:25 +0000)
committerKen Raeburn <raeburn@mit.edu>
Fri, 19 Mar 2004 23:25:17 +0000 (23:25 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16192 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/gssapi/krb5/ChangeLog
src/lib/gssapi/krb5/acquire_cred.c
src/lib/gssapi/krb5/export_name.c
src/lib/gssapi/krb5/gssapiP_krb5.h
src/lib/gssapi/krb5/import_name.c

index d4106013236ed9a301623ba45da5f15c46c77d23..838f3526500e48e5637edcee84cae8946b674216 100644 (file)
@@ -1,8 +1,7 @@
 2004-03-19  Ken Raeburn  <raeburn@mit.edu>
 
-       * acquire_cred.c (krb5_gss_acquire_cred): Create and destroy a
-       local krb5 context.
-       * add_cred.c (krb5_gss_add_cred): Likewise.
+       * add_cred.c (krb5_gss_add_cred): Create and destroy a local krb5
+       context.
        * compare_name.c (krb5_gss_compare_name): Likewise.
        * copy_ccache.c (gss_krb5_copy_ccache): Likewise.
        * disp_name.c (krb5_gss_display_name): Likewise.
index e652c664c117e9f7bf81d7dcebb74196af2432c8..0a0de14b99a87d5dc1ff6d20094a318d8b9651f9 100644 (file)
@@ -331,6 +331,9 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req,
    OM_uint32 ret;
    krb5_error_code code;
 
+   if (GSS_ERROR(kg_get_context(minor_status, &context)))
+      return(GSS_S_FAILURE);
+
    /* make sure all outputs are valid */
 
    *output_cred_handle = NULL;
@@ -399,13 +402,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req,
    /* if requested, acquire credentials for accepting */
    /* this will fill in cred->princ if the desired_name is not specified */
 
-   code = krb5_init_context(&context);
-   if (code) {
-       xfree(cred);
-       *minor_status = (OM_uint32) code;
-       return GSS_S_FAILURE;
-   }
-
    if ((cred_usage == GSS_C_ACCEPT) ||
        (cred_usage == GSS_C_BOTH))
       if ((ret = acquire_accept_cred(context, minor_status, desired_name,
@@ -414,7 +410,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req,
         if (cred->princ)
            krb5_free_principal(context, cred->princ);
         xfree(cred);
-        krb5_free_context(context);
         /* minor_status set by acquire_accept_cred() */
         return(ret);
       }
@@ -435,7 +430,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req,
         if (cred->princ)
            krb5_free_principal(context, cred->princ);
         xfree(cred);
-        krb5_free_context(context);
         /* minor_status set by acquire_init_cred() */
         return(ret);
       }
@@ -450,7 +444,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req,
         if (cred->keytab)
            (void)krb5_kt_close(context, cred->keytab);
         xfree(cred);
-        krb5_free_context(context);
         *minor_status = code;
         return(GSS_S_FAILURE);
       }
@@ -473,7 +466,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req,
         if (cred->princ)
            krb5_free_principal(context, cred->princ);
         xfree(cred);
-        krb5_free_context(context);
         *minor_status = code;
         return(GSS_S_FAILURE);
       }
@@ -502,7 +494,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req,
           if (cred->princ)
               krb5_free_principal(context, cred->princ);
           xfree(cred);
-          krb5_free_context(context);
           /* *minor_status set above */
           return(ret);
        }
@@ -520,7 +511,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req,
       if (cred->princ)
         krb5_free_principal(context, cred->princ);
       xfree(cred);
-      krb5_free_context(context);
       *minor_status = (OM_uint32) G_VALIDATE_FAILED;
       return(GSS_S_FAILURE);
    }
@@ -532,6 +522,5 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req,
    if (actual_mechs)
       *actual_mechs = ret_mechs;
 
-   krb5_free_context(context);
    return(GSS_S_COMPLETE);
 }
index cab284cc3663a8439b65f3f6e23deca7f46098c3..c949d471ec46368be647f1cc11b3d851de2bf988 100644 (file)
@@ -36,8 +36,11 @@ OM_uint32 krb5_gss_export_name(OM_uint32  *minor_status,
        size_t length;
        char *str, *cp;
 
-       if (GSS_ERROR(kg_get_context(minor_status, &context)))
-               return(GSS_S_FAILURE);
+       code = krb5_init_context(&context);
+       if (code) {
+           *minor_status = code;
+           return GSS_S_FAILURE;
+       }
 
        exported_name->length = 0;
        exported_name->value = NULL;
@@ -45,15 +48,18 @@ OM_uint32 krb5_gss_export_name(OM_uint32  *minor_status,
        if (! kg_validate_name(input_name)) {
                if (minor_status)
                        *minor_status = (OM_uint32) G_VALIDATE_FAILED;
+               krb5_free_context(context);
                return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_BAD_NAME);
        }
 
        if ((code = krb5_unparse_name(context, (krb5_principal) input_name, 
                                      &str))) {
                *minor_status = code;
+               krb5_free_context(context);
                return(GSS_S_FAILURE);
        }
 
+       krb5_free_context(context);
        length = strlen(str);
        exported_name->length = 10 + length + gss_mech_krb5->length;
        exported_name->value = malloc(exported_name->length);
@@ -82,9 +88,3 @@ OM_uint32 krb5_gss_export_name(OM_uint32  *minor_status,
 
        return(GSS_S_COMPLETE);
 }
-
-
-
-
-
-
index d207010c1f544229c96bce3b42120898f8dbd4f0..9fb41ad2d9aa0fe2795468d6590024b7fa0fb9e7 100644 (file)
@@ -296,9 +296,6 @@ krb5_error_code kg_ctx_internalize (krb5_context kcontext,
                                              krb5_octet **buffer,
                                              size_t *lenremain);
 
-OM_uint32 kg_get_context (OM_uint32 *minor_status,
-                                   krb5_context *context);
-
 OM_uint32 kg_sync_ccache_name (OM_uint32 *minor_status);
 
 OM_uint32 kg_get_ccache_name (OM_uint32 *minor_status, 
index d57144fee44a9649acacf573f83c1340a5d6aa24..c9f95857d44ddfff41be2e240602de583d77e8db 100644 (file)
@@ -60,8 +60,11 @@ krb5_gss_import_name(minor_status, input_name_buffer,
    struct passwd *pw;
 #endif
 
-   if (GSS_ERROR(kg_get_context(minor_status, &context)))
-      return(GSS_S_FAILURE);
+   code = krb5_init_context(&context);
+   if (code) {
+       *minor_status = code;
+       return GSS_S_FAILURE;
+   }
 
    /* set up default returns */
 
@@ -78,6 +81,7 @@ krb5_gss_import_name(minor_status, input_name_buffer,
       if ((tmp =
           (char *) xmalloc(input_name_buffer->length + 1)) == NULL) {
         *minor_status = ENOMEM;
+        krb5_free_context(context);
         return(GSS_S_FAILURE);
       }
 
@@ -100,6 +104,7 @@ krb5_gss_import_name(minor_status, input_name_buffer,
 
       if (input_name_buffer->length != sizeof(krb5_principal)) {
         *minor_status = (OM_uint32) G_WRONG_SIZE;
+        krb5_free_context(context);
         return(GSS_S_BAD_NAME);
       }
 
@@ -107,6 +112,7 @@ krb5_gss_import_name(minor_status, input_name_buffer,
 
       if ((code = krb5_copy_principal(context, input, &princ))) {
         *minor_status = code;
+        krb5_free_context(context);
         return(GSS_S_FAILURE);
       }
    } else {
@@ -115,6 +121,7 @@ krb5_gss_import_name(minor_status, input_name_buffer,
       if ((tmp =
           (char *) xmalloc(input_name_buffer->length + 1)) == NULL) {
         *minor_status = ENOMEM;
+        krb5_free_context(context);
         return(GSS_S_FAILURE);
       }
       tmp2 = 0;
@@ -165,6 +172,7 @@ krb5_gss_import_name(minor_status, input_name_buffer,
         if (tmp2 == NULL) {
                 xfree(tmp);
                 *minor_status = ENOMEM;
+                krb5_free_context(context);
                 return GSS_S_FAILURE;
         }
         strncpy(tmp2, cp, length);
@@ -172,6 +180,7 @@ krb5_gss_import_name(minor_status, input_name_buffer,
         
         stringrep = tmp2;
      } else {
+        krb5_free_context(context);
         return(GSS_S_BAD_NAMETYPE);
       }
 
@@ -184,6 +193,7 @@ krb5_gss_import_name(minor_status, input_name_buffer,
         xfree(tmp);
         if (tmp2)
                 xfree(tmp2);
+        krb5_free_context(context);
         return(GSS_S_BAD_NAME);
       }
       
@@ -197,6 +207,7 @@ krb5_gss_import_name(minor_status, input_name_buffer,
 
    if (code) {
       *minor_status = (OM_uint32) code;
+      krb5_free_context(context);
       return(GSS_S_BAD_NAME);
    }
 
@@ -204,10 +215,13 @@ krb5_gss_import_name(minor_status, input_name_buffer,
 
    if (! kg_save_name((gss_name_t) princ)) {
       krb5_free_principal(context, princ);
+      krb5_free_context(context);
       *minor_status = (OM_uint32) G_VALIDATE_FAILED;
       return(GSS_S_FAILURE);
    }
 
+   krb5_free_context(context);
+
    /* return it */
 
    *output_name = (gss_name_t) princ;