Blame SOURCES/0166-IPA-Fix-the-PAM-error-code-that-auth-code-expects-to.patch

bb7cd1
From 62cebc27bd0bdb2c12531203fd79f231e96eab7b Mon Sep 17 00:00:00 2001
bb7cd1
From: Sumit Bose <sbose@redhat.com>
bb7cd1
Date: Fri, 2 Jun 2017 11:17:18 +0200
bb7cd1
Subject: [PATCH 166/166] IPA: Fix the PAM error code that auth code expects to
bb7cd1
 start migration
bb7cd1
MIME-Version: 1.0
bb7cd1
Content-Type: text/plain; charset=UTF-8
bb7cd1
Content-Transfer-Encoding: 8bit
bb7cd1
bb7cd1
Recent patches which adds support for PKINIT in krb5_child changed a
bb7cd1
return code which is used to indicate to the IPA provider that password
bb7cd1
migration should be tried.
bb7cd1
bb7cd1
With this patch krb5_child properly returns PAM_CRED_ERR as expected by
bb7cd1
the IPA provider in this case.
bb7cd1
bb7cd1
Resolves:
bb7cd1
https://pagure.io/SSSD/sssd/issue/3394
bb7cd1
bb7cd1
Reviewed-by: Simo Sorce <simo@redhat.com>
bb7cd1
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
bb7cd1
---
bb7cd1
 src/providers/krb5/krb5_child.c | 11 +++++++++++
bb7cd1
 1 file changed, 11 insertions(+)
bb7cd1
bb7cd1
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
bb7cd1
index cbbc892bee0365892ac66d3654c974d325166b60..3cd8bfba76a35acd2c885ee2aac4765a6c1cc03c 100644
bb7cd1
--- a/src/providers/krb5/krb5_child.c
bb7cd1
+++ b/src/providers/krb5/krb5_child.c
bb7cd1
@@ -1540,6 +1540,17 @@ static krb5_error_code get_and_save_tgt(struct krb5_req *kr,
bb7cd1
         if (kerr != 0) {
bb7cd1
             KRB5_CHILD_DEBUG(SSSDBG_CRIT_FAILURE, kerr);
bb7cd1
 
bb7cd1
+            /* Special case for IPA password migration */
bb7cd1
+            if (kr->pd->cmd == SSS_PAM_AUTHENTICATE
bb7cd1
+                    && kerr == KRB5_PREAUTH_FAILED
bb7cd1
+                    && kr->pkinit_prompting == false
bb7cd1
+                    && kr->password_prompting == false
bb7cd1
+                    && kr->otp == false
bb7cd1
+                    && sss_authtok_get_type(kr->pd->authtok)
bb7cd1
+                            == SSS_AUTHTOK_TYPE_PASSWORD) {
bb7cd1
+                return ERR_CREDS_INVALID;
bb7cd1
+            }
bb7cd1
+
bb7cd1
             /* If during authentication either the MIT Kerberos pkinit
bb7cd1
              * pre-auth module is missing or no Smartcard is inserted and only
bb7cd1
              * pkinit is available KRB5_PREAUTH_FAILED is returned.
bb7cd1
-- 
bb7cd1
2.9.4
bb7cd1