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.
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;
/* 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,
if (cred->princ)
krb5_free_principal(context, cred->princ);
xfree(cred);
- krb5_free_context(context);
/* minor_status set by acquire_accept_cred() */
return(ret);
}
if (cred->princ)
krb5_free_principal(context, cred->princ);
xfree(cred);
- krb5_free_context(context);
/* minor_status set by acquire_init_cred() */
return(ret);
}
if (cred->keytab)
(void)krb5_kt_close(context, cred->keytab);
xfree(cred);
- krb5_free_context(context);
*minor_status = code;
return(GSS_S_FAILURE);
}
if (cred->princ)
krb5_free_principal(context, cred->princ);
xfree(cred);
- krb5_free_context(context);
*minor_status = code;
return(GSS_S_FAILURE);
}
if (cred->princ)
krb5_free_principal(context, cred->princ);
xfree(cred);
- krb5_free_context(context);
/* *minor_status set above */
return(ret);
}
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);
}
if (actual_mechs)
*actual_mechs = ret_mechs;
- krb5_free_context(context);
return(GSS_S_COMPLETE);
}
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;
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);
return(GSS_S_COMPLETE);
}
-
-
-
-
-
-
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,
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 */
if ((tmp =
(char *) xmalloc(input_name_buffer->length + 1)) == NULL) {
*minor_status = ENOMEM;
+ krb5_free_context(context);
return(GSS_S_FAILURE);
}
if (input_name_buffer->length != sizeof(krb5_principal)) {
*minor_status = (OM_uint32) G_WRONG_SIZE;
+ krb5_free_context(context);
return(GSS_S_BAD_NAME);
}
if ((code = krb5_copy_principal(context, input, &princ))) {
*minor_status = code;
+ krb5_free_context(context);
return(GSS_S_FAILURE);
}
} else {
if ((tmp =
(char *) xmalloc(input_name_buffer->length + 1)) == NULL) {
*minor_status = ENOMEM;
+ krb5_free_context(context);
return(GSS_S_FAILURE);
}
tmp2 = 0;
if (tmp2 == NULL) {
xfree(tmp);
*minor_status = ENOMEM;
+ krb5_free_context(context);
return GSS_S_FAILURE;
}
strncpy(tmp2, cp, length);
stringrep = tmp2;
} else {
+ krb5_free_context(context);
return(GSS_S_BAD_NAMETYPE);
}
xfree(tmp);
if (tmp2)
xfree(tmp2);
+ krb5_free_context(context);
return(GSS_S_BAD_NAME);
}
if (code) {
*minor_status = (OM_uint32) code;
+ krb5_free_context(context);
return(GSS_S_BAD_NAME);
}
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;