Blame SOURCES/Adjust-processing-of-pa_type-ccache-config.patch

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