Blob Blame History Raw
From 03afa4cbef2c2ba3c70fbad4f3e1e36c05fafe82 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek@redhat.com>
Date: Mon, 8 Dec 2014 13:29:23 +0100
Subject: [PATCH 138/138] KRB5: Check FAST kinit errors using get_tgt_times()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
---
 src/providers/krb5/krb5_child.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
index 8f23346a67d4d2467a4d1869fd298ec4d6f68e92..3318e0647c0e7d7f0e7305cc4204d9c2db020162 100644
--- a/src/providers/krb5/krb5_child.c
+++ b/src/providers/krb5/krb5_child.c
@@ -1662,6 +1662,7 @@ static krb5_error_code get_tgt_times(krb5_context ctx, const char *ccname,
     krberr = krb5_cc_resolve(ctx, ccname, &ccache);
     if (krberr != 0) {
         DEBUG(SSSDBG_CRIT_FAILURE, "krb5_cc_resolve failed.\n");
+        KRB5_CHILD_DEBUG(SSSDBG_CRIT_FAILURE, krberr);
         goto done;
     }
 
@@ -1814,7 +1815,6 @@ static krb5_error_code check_fast_ccache(TALLOC_CTX *mem_ctx,
             } while (kerr == -1 && errno == EINTR);
 
             if (kerr > 0) {
-                kerr = EIO;
                 if (WIFEXITED(status)) {
                     kerr = WEXITSTATUS(status);
                     /* Don't blindly fail if the child fails, but check
@@ -1830,26 +1830,28 @@ static krb5_error_code check_fast_ccache(TALLOC_CTX *mem_ctx,
                           fchild_pid);
                 }
             } else {
-                DEBUG(SSSDBG_FUNC_DATA,
-                    "Failed to wait for children %d\n", fchild_pid);
-                kerr = EIO;
+                DEBUG(SSSDBG_CRIT_FAILURE,
+                      "Failed to wait for child %d\n", fchild_pid);
+                /* Let the code re-check the TGT times and fail if we
+                 * can't find the updated principal */
             }
     }
 
     /* Check the ccache times again. Should be updated ... */
     memset(&tgtt, 0, sizeof(tgtt));
     kerr = get_tgt_times(ctx, ccname, server_princ, client_princ, &tgtt);
-    if (kerr == 0) {
-        if (tgtt.endtime > time(NULL)) {
-            DEBUG(SSSDBG_FUNC_DATA, "FAST TGT was successfully recreated!\n");
-            goto done;
-        } else {
-            kerr = ERR_CREDS_EXPIRED;
-            goto done;
-        }
+    if (kerr != 0) {
+        DEBUG(SSSDBG_OP_FAILURE, "get_tgt_times() failed\n");
+        goto done;
     }
 
-    kerr = 0;
+    if (tgtt.endtime < time(NULL)) {
+        DEBUG(SSSDBG_OP_FAILURE,
+              "Valid FAST TGT not found after attempting to renew it\n");
+        kerr = ERR_CREDS_EXPIRED;
+        goto done;
+    }
+    DEBUG(SSSDBG_FUNC_DATA, "FAST TGT was successfully recreated!\n");
 
 done:
     if (client_princ != NULL) {
-- 
1.9.3