Skip to content

Commit

Permalink
Use responder for non-preauth AS requests
Browse files Browse the repository at this point in the history
If no AS reply key is computed during pre-authentication (typically
because no pre-authentication was required by the KDC), ask for the
password using the responder before calling gak_fct for the key, and
supply any resulting responder items to gak_fct.

(cherry picked from commit 0639adc)

ticket: 8454
version_fixed: 1.14.4
  • Loading branch information
greghudson authored and tlyu committed Sep 2, 2016
1 parent 2e64212 commit 2346029
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/lib/krb5/krb/get_in_tkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,8 @@ init_creds_step_reply(krb5_context context,
krb5_keyblock encrypting_key;
krb5_boolean fast_avail;
krb5_ccache out_ccache = k5_gic_opt_get_out_ccache(ctx->opt);
krb5_responder_fn responder;
void *responder_data;

encrypting_key.length = 0;
encrypting_key.contents = NULL;
Expand Down Expand Up @@ -1509,13 +1511,33 @@ init_creds_step_reply(krb5_context context,
code = -1;

if (code != 0) {
/* If a responder was provided and we are using a password, ask for the
* password using the responder before falling back to the prompter. */
k5_gic_opt_get_responder(ctx->opt, &responder, &responder_data);
if (responder != NULL && !ctx->as_key.length) {
/* Indicate a need for the AS key by calling the gak_fct with a
* NULL as_key. */
code = ctx->gak_fct(context, ctx->request->client, ctx->etype,
NULL, NULL, NULL, NULL, NULL, ctx->gak_data,
ctx->rctx.items);
if (code != 0)
goto cleanup;

/* If that produced a responder question, invoke the responder. */
if (!k5_response_items_empty(ctx->rctx.items)) {
code = (*responder)(context, responder_data, &ctx->rctx);
if (code != 0)
goto cleanup;
}
}

/* if we haven't get gotten a key, get it now */
TRACE_INIT_CREDS_GAK(context, &ctx->salt, &ctx->s2kparams);
code = (*ctx->gak_fct)(context, ctx->request->client,
ctx->reply->enc_part.enctype,
ctx->prompter, ctx->prompter_data,
&ctx->salt, &ctx->s2kparams,
&ctx->as_key, ctx->gak_data, NULL);
&ctx->as_key, ctx->gak_data, ctx->rctx.items);
if (code != 0)
goto cleanup;
TRACE_INIT_CREDS_AS_KEY_GAK(context, &ctx->as_key);
Expand Down
5 changes: 5 additions & 0 deletions src/tests/t_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@

realm = K5Realm(create_host=False)

# Regression test for #8454 (responder callback isn't used when
# preauth is not required).
realm.run(['./responder', '-r', 'password=%s' % password('user'),
realm.user_princ])

# Test that WRONG_REALM responses aren't treated as referrals unless
# they contain a crealm field pointing to a different realm.
# (Regression test for #8060.)
Expand Down

0 comments on commit 2346029

Please sign in to comment.