1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-22 02:50:28 +03:00

heimdal Use a seperate krb5_auth_context for the delegated credentials

If we re-use this context, we overwrite the timestamp while talking
to the KDC and fail the mutual authentiation with the target server.

Andrew Bartlett
This commit is contained in:
Andrew Bartlett 2010-09-29 06:44:33 +10:00 committed by Andrew Tridgell
parent e2c305deb1
commit f84bdf91d8
3 changed files with 35 additions and 1 deletions

View File

@ -59,6 +59,7 @@ _gsskrb5_delete_sec_context(OM_uint32 * minor_status,
HEIMDAL_MUTEX_lock(&ctx->ctx_id_mutex);
krb5_auth_con_free (context, ctx->auth_context);
krb5_auth_con_free (context, ctx->deleg_auth_context);
if (ctx->kcred)
krb5_free_creds(context, ctx->kcred);
if(ctx->source)

View File

@ -55,6 +55,7 @@ struct gss_msg_order;
typedef struct gsskrb5_ctx {
struct krb5_auth_context_data *auth_context;
struct krb5_auth_context_data *deleg_auth_context;
krb5_principal source, target;
#define IS_DCE_STYLE(ctx) (((ctx)->flags & GSS_C_DCE_STYLE) != 0)
OM_uint32 flags;

View File

@ -117,6 +117,7 @@ _gsskrb5_create_ctx(
return GSS_S_FAILURE;
}
ctx->auth_context = NULL;
ctx->deleg_auth_context = NULL;
ctx->source = NULL;
ctx->target = NULL;
ctx->kcred = NULL;
@ -139,13 +140,34 @@ _gsskrb5_create_ctx(
return GSS_S_FAILURE;
}
kret = krb5_auth_con_init (context, &ctx->deleg_auth_context);
if (kret) {
*minor_status = kret;
krb5_auth_con_free(context, ctx->auth_context);
HEIMDAL_MUTEX_destroy(&ctx->ctx_id_mutex);
return GSS_S_FAILURE;
}
kret = set_addresses(context, ctx->auth_context, input_chan_bindings);
if (kret) {
*minor_status = kret;
krb5_auth_con_free(context, ctx->auth_context);
krb5_auth_con_free(context, ctx->deleg_auth_context);
HEIMDAL_MUTEX_destroy(&ctx->ctx_id_mutex);
return GSS_S_BAD_BINDINGS;
}
kret = set_addresses(context, ctx->deleg_auth_context, input_chan_bindings);
if (kret) {
*minor_status = kret;
krb5_auth_con_free(context, ctx->auth_context);
krb5_auth_con_free(context, ctx->deleg_auth_context);
HEIMDAL_MUTEX_destroy(&ctx->ctx_id_mutex);
return GSS_S_BAD_BINDINGS;
}
@ -160,6 +182,16 @@ _gsskrb5_create_ctx(
KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CRED,
NULL);
/*
* We need a sequence number
*/
krb5_auth_con_addflags(context,
ctx->deleg_auth_context,
KRB5_AUTH_CONTEXT_DO_SEQUENCE |
KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CRED,
NULL);
*context_handle = (gss_ctx_id_t)ctx;
return GSS_S_COMPLETE;
@ -538,7 +570,7 @@ init_auth_restart
ap_options = 0;
if (flagmask & GSS_C_DELEG_FLAG) {
do_delegation (context,
ctx->auth_context,
ctx->deleg_auth_context,
ctx->ccache, ctx->kcred, ctx->target,
&fwd_data, flagmask, &flags);
}