|
|
665228 |
From 5c71088657f56a26f367aeebe905df51b38be434 Mon Sep 17 00:00:00 2001
|
|
|
665228 |
From: Greg Hudson <ghudson@mit.edu>
|
|
|
665228 |
Date: Fri, 13 Jan 2017 10:14:36 -0500
|
|
|
665228 |
Subject: [PATCH] Adjust processing of pa_type ccache config
|
|
|
665228 |
|
|
|
665228 |
Read the allowed preauth type from the input ccache in
|
|
|
665228 |
restart_init_creds_loop(); there is no need to reread it each time we
|
|
|
665228 |
produce a request. Move read_allowed_preauth_type() earlier in the
|
|
|
665228 |
file to allow it to be called from restart_init_creds_loop() without a
|
|
|
665228 |
prototype.
|
|
|
665228 |
|
|
|
665228 |
Clear the selected preauth type in restart_init_creds_loop(), not in
|
|
|
665228 |
init_creds_step_request(). We want to make sure that it doesn't
|
|
|
665228 |
survive a restart due to a realm referral or expiry, but we don't want
|
|
|
665228 |
to forget about it when retrying after an error.
|
|
|
665228 |
|
|
|
665228 |
(cherry picked from commit 468c6eb7bb860f7ec0381086a22859f822b41c43)
|
|
|
665228 |
---
|
|
|
665228 |
src/lib/krb5/krb/get_in_tkt.c | 61 ++++++++++++++++++-----------------
|
|
|
665228 |
1 file changed, 31 insertions(+), 30 deletions(-)
|
|
|
665228 |
|
|
|
665228 |
diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c
|
|
|
665228 |
index 52e07bb67..da12204ac 100644
|
|
|
665228 |
--- a/src/lib/krb5/krb/get_in_tkt.c
|
|
|
665228 |
+++ b/src/lib/krb5/krb/get_in_tkt.c
|
|
|
665228 |
@@ -791,6 +791,31 @@ set_request_times(krb5_context context, krb5_init_creds_context ctx)
|
|
|
665228 |
return 0;
|
|
|
665228 |
}
|
|
|
665228 |
|
|
|
665228 |
+static void
|
|
|
665228 |
+read_allowed_preauth_type(krb5_context context, krb5_init_creds_context ctx)
|
|
|
665228 |
+{
|
|
|
665228 |
+ krb5_error_code ret;
|
|
|
665228 |
+ krb5_data config;
|
|
|
665228 |
+ char *tmp, *p;
|
|
|
665228 |
+ krb5_ccache in_ccache = k5_gic_opt_get_in_ccache(ctx->opt);
|
|
|
665228 |
+
|
|
|
665228 |
+ ctx->allowed_preauth_type = KRB5_PADATA_NONE;
|
|
|
665228 |
+ if (in_ccache == NULL)
|
|
|
665228 |
+ return;
|
|
|
665228 |
+ memset(&config, 0, sizeof(config));
|
|
|
665228 |
+ if (krb5_cc_get_config(context, in_ccache, ctx->request->server,
|
|
|
665228 |
+ KRB5_CC_CONF_PA_TYPE, &config) != 0)
|
|
|
665228 |
+ return;
|
|
|
665228 |
+ tmp = k5memdup0(config.data, config.length, &ret;;
|
|
|
665228 |
+ krb5_free_data_contents(context, &config);
|
|
|
665228 |
+ if (tmp == NULL)
|
|
|
665228 |
+ return;
|
|
|
665228 |
+ ctx->allowed_preauth_type = strtol(tmp, &p, 10);
|
|
|
665228 |
+ if (p == NULL || *p != '\0')
|
|
|
665228 |
+ ctx->allowed_preauth_type = KRB5_PADATA_NONE;
|
|
|
665228 |
+ free(tmp);
|
|
|
665228 |
+}
|
|
|
665228 |
+
|
|
|
665228 |
/**
|
|
|
665228 |
* Throw away any pre-authentication realm state and begin with a
|
|
|
665228 |
* unauthenticated or optimistically authenticated request. If fast_upgrade is
|
|
|
665228 |
@@ -807,6 +832,7 @@ restart_init_creds_loop(krb5_context context, krb5_init_creds_context ctx,
|
|
|
665228 |
krb5_free_error(context, ctx->err_reply);
|
|
|
665228 |
ctx->preauth_to_use = ctx->err_padata = NULL;
|
|
|
665228 |
ctx->err_reply = NULL;
|
|
|
665228 |
+ ctx->selected_preauth_type = KRB5_PADATA_NONE;
|
|
|
665228 |
|
|
|
665228 |
krb5int_fast_free_state(context, ctx->fast_state);
|
|
|
665228 |
ctx->fast_state = NULL;
|
|
|
665228 |
@@ -849,6 +875,11 @@ restart_init_creds_loop(krb5_context context, krb5_init_creds_context ctx,
|
|
|
665228 |
&ctx->outer_request_body);
|
|
|
665228 |
if (code != 0)
|
|
|
665228 |
goto cleanup;
|
|
|
665228 |
+
|
|
|
665228 |
+ /* Read the allowed preauth type for this server principal from the input
|
|
|
665228 |
+ * ccache, if the application supplied one. */
|
|
|
665228 |
+ read_allowed_preauth_type(context, ctx);
|
|
|
665228 |
+
|
|
|
665228 |
cleanup:
|
|
|
665228 |
return code;
|
|
|
665228 |
}
|
|
|
665228 |
@@ -1154,31 +1185,6 @@ init_creds_validate_reply(krb5_context context,
|
|
|
665228 |
return 0;
|
|
|
665228 |
}
|
|
|
665228 |
|
|
|
665228 |
-static void
|
|
|
665228 |
-read_allowed_preauth_type(krb5_context context, krb5_init_creds_context ctx)
|
|
|
665228 |
-{
|
|
|
665228 |
- krb5_error_code ret;
|
|
|
665228 |
- krb5_data config;
|
|
|
665228 |
- char *tmp, *p;
|
|
|
665228 |
- krb5_ccache in_ccache = k5_gic_opt_get_in_ccache(ctx->opt);
|
|
|
665228 |
-
|
|
|
665228 |
- ctx->allowed_preauth_type = KRB5_PADATA_NONE;
|
|
|
665228 |
- if (in_ccache == NULL)
|
|
|
665228 |
- return;
|
|
|
665228 |
- memset(&config, 0, sizeof(config));
|
|
|
665228 |
- if (krb5_cc_get_config(context, in_ccache, ctx->request->server,
|
|
|
665228 |
- KRB5_CC_CONF_PA_TYPE, &config) != 0)
|
|
|
665228 |
- return;
|
|
|
665228 |
- tmp = k5memdup0(config.data, config.length, &ret;;
|
|
|
665228 |
- krb5_free_data_contents(context, &config);
|
|
|
665228 |
- if (tmp == NULL)
|
|
|
665228 |
- return;
|
|
|
665228 |
- ctx->allowed_preauth_type = strtol(tmp, &p, 10);
|
|
|
665228 |
- if (p == NULL || *p != '\0')
|
|
|
665228 |
- ctx->allowed_preauth_type = KRB5_PADATA_NONE;
|
|
|
665228 |
- free(tmp);
|
|
|
665228 |
-}
|
|
|
665228 |
-
|
|
|
665228 |
static krb5_error_code
|
|
|
665228 |
save_selected_preauth_type(krb5_context context, krb5_ccache ccache,
|
|
|
665228 |
krb5_init_creds_context ctx)
|
|
|
665228 |
@@ -1317,11 +1323,6 @@ init_creds_step_request(krb5_context context,
|
|
|
665228 |
if (code)
|
|
|
665228 |
goto cleanup;
|
|
|
665228 |
|
|
|
665228 |
- /* Read the allowed patype for this server principal from the in_ccache,
|
|
|
665228 |
- * if the application supplied one. */
|
|
|
665228 |
- read_allowed_preauth_type(context, ctx);
|
|
|
665228 |
- ctx->selected_preauth_type = KRB5_PADATA_NONE;
|
|
|
665228 |
-
|
|
|
665228 |
/*
|
|
|
665228 |
* Read cached preauth configuration data for this server principal from
|
|
|
665228 |
* the in_ccache, if the application supplied one, and delete any that was
|