Blame SOURCES/0057-krb5-return-to-responder-that-pkinit-is-not-availabl.patch

bb7cd1
From 01ed8c7d7fcd9090d0953f85ef0604cbcad4f48b Mon Sep 17 00:00:00 2001
bb7cd1
From: Sumit Bose <sbose@redhat.com>
bb7cd1
Date: Thu, 16 Mar 2017 20:43:08 +0100
bb7cd1
Subject: [PATCH 57/60] krb5: return to responder that pkinit is not available
bb7cd1
MIME-Version: 1.0
bb7cd1
Content-Type: text/plain; charset=UTF-8
bb7cd1
Content-Transfer-Encoding: 8bit
bb7cd1
bb7cd1
If pkinit is not available for a user but other authentication methods
bb7cd1
are SSSD should still fall back to local certificate based
bb7cd1
authentication if Smartcard credentials are provided.
bb7cd1
bb7cd1
Resolves https://pagure.io/SSSD/sssd/issue/3343
bb7cd1
bb7cd1
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
bb7cd1
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
bb7cd1
---
bb7cd1
 src/providers/krb5/krb5_child.c | 17 +++++++++++++----
bb7cd1
 1 file changed, 13 insertions(+), 4 deletions(-)
bb7cd1
bb7cd1
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
bb7cd1
index 777a25f2a0ea434dde12d2396f6a35c2a1b86cd0..a4128dda6b0861a95dba223047d66c4158b1afb6 100644
bb7cd1
--- a/src/providers/krb5/krb5_child.c
bb7cd1
+++ b/src/providers/krb5/krb5_child.c
bb7cd1
@@ -42,6 +42,10 @@
bb7cd1
 
bb7cd1
 #define SSSD_KRB5_CHANGEPW_PRINCIPAL "kadmin/changepw"
bb7cd1
 
bb7cd1
+#define IS_SC_AUTHTOK(tok) ( \
bb7cd1
+    sss_authtok_get_type((tok)) == SSS_AUTHTOK_TYPE_SC_PIN \
bb7cd1
+        || sss_authtok_get_type((tok)) == SSS_AUTHTOK_TYPE_SC_KEYPAD)
bb7cd1
+
bb7cd1
 enum k5c_fast_opt {
bb7cd1
     K5C_FAST_NEVER,
bb7cd1
     K5C_FAST_TRY,
bb7cd1
@@ -1529,12 +1533,17 @@ static krb5_error_code get_and_save_tgt(struct krb5_req *kr,
bb7cd1
              * pre-auth module is missing or no Smartcard is inserted and only
bb7cd1
              * pkinit is available KRB5_PREAUTH_FAILED is returned.
bb7cd1
              * ERR_NO_AUTH_METHOD_AVAILABLE is used to indicate to the
bb7cd1
-             * frontend that local authentication might be tried. */
bb7cd1
+             * frontend that local authentication might be tried.
bb7cd1
+             * Same is true if Smartcard credentials are given but only other
bb7cd1
+             * authentication methods are available. */
bb7cd1
             if (kr->pd->cmd == SSS_PAM_AUTHENTICATE
bb7cd1
                     && kerr == KRB5_PREAUTH_FAILED
bb7cd1
-                    && kr->password_prompting == false
bb7cd1
-                    && kr->otp == false
bb7cd1
-                    && kr->pkinit_prompting == false) {
bb7cd1
+                    && kr->pkinit_prompting == false
bb7cd1
+                    && (( kr->password_prompting == false
bb7cd1
+                              && kr->otp == false)
bb7cd1
+                            || ((kr->otp == true
bb7cd1
+                                    || kr->password_prompting == true)
bb7cd1
+                              && IS_SC_AUTHTOK(kr->pd->authtok))) ) {
bb7cd1
                 return ERR_NO_AUTH_METHOD_AVAILABLE;
bb7cd1
             }
bb7cd1
             return kerr;
bb7cd1
-- 
bb7cd1
2.9.3
bb7cd1