@@ -553,7 +553,7 @@ static krb5_error_code tokeninfo_matches(TALLOC_CTX *mem_ctx,
553553 "Unsupported authtok type %d\n" , sss_authtok_get_type (auth_tok ));
554554 }
555555
556- return EAGAIN ;
556+ return ERR_CHECK_NEXT_AUTH_TYPE ;
557557}
558558
559559static krb5_error_code answer_otp (krb5_context ctx ,
@@ -603,7 +603,7 @@ static krb5_error_code answer_otp(krb5_context ctx,
603603 /* Allocation errors are ignored on purpose */
604604
605605 DEBUG (SSSDBG_TRACE_INTERNAL , "Exit answer_otp during pre-auth.\n" );
606- return EAGAIN ;
606+ return ERR_CHECK_NEXT_AUTH_TYPE ;
607607 }
608608
609609 /* Find the first supported tokeninfo which matches our authtoken. */
@@ -773,14 +773,14 @@ static krb5_error_code answer_pkinit(krb5_context ctx,
773773 DEBUG (SSSDBG_MINOR_FAILURE ,
774774 "Unexpected authentication token type [%s]\n" ,
775775 sss_authtok_type_to_str (sss_authtok_get_type (kr -> pd -> authtok )));
776- kerr = EAGAIN ;
776+ kerr = ERR_CHECK_NEXT_AUTH_TYPE ;
777777 goto done ;
778778 }
779779 } else {
780780 /* We only expect SSS_PAM_PREAUTH here, but also for all other
781781 * commands the graceful solution would be to let the caller
782782 * check other authentication methods as well. */
783- kerr = EAGAIN ;
783+ kerr = ERR_CHECK_NEXT_AUTH_TYPE ;
784784 }
785785
786786done :
@@ -910,7 +910,7 @@ static krb5_error_code answer_idp_oauth2(krb5_context kctx,
910910 if (type != SSS_AUTHTOK_TYPE_OAUTH2 ) {
911911 DEBUG (SSSDBG_MINOR_FAILURE , "Unexpected authentication token type [%s]\n" ,
912912 sss_authtok_type_to_str (type ));
913- kerr = EAGAIN ;
913+ kerr = ERR_CHECK_NEXT_AUTH_TYPE ;
914914 goto done ;
915915 }
916916
@@ -1137,7 +1137,7 @@ static krb5_error_code answer_passkey(krb5_context kctx,
11371137 if (type != SSS_AUTHTOK_TYPE_PASSKEY_REPLY ) {
11381138 DEBUG (SSSDBG_MINOR_FAILURE , "Unexpected authentication token type [%s]\n" ,
11391139 sss_authtok_type_to_str (type ));
1140- kerr = EAGAIN ;
1140+ kerr = ERR_CHECK_NEXT_AUTH_TYPE ;
11411141 goto done ;
11421142 }
11431143
@@ -1228,7 +1228,7 @@ static krb5_error_code answer_password(krb5_context kctx,
12281228
12291229 /* For SSS_PAM_PREAUTH and the other remaining commands the caller should
12301230 * continue to iterate over the available authentication methods. */
1231- return EAGAIN ;
1231+ return ERR_CHECK_NEXT_AUTH_TYPE ;
12321232}
12331233
12341234static krb5_error_code sss_krb5_responder (krb5_context ctx ,
@@ -1253,12 +1253,12 @@ static krb5_error_code sss_krb5_responder(krb5_context ctx,
12531253 /* It is expected that the answer_*() functions only return EOK
12541254 * (success) if the authentication was successful, i.e. during
12551255 * SSS_PAM_AUTHENTICATE. In all other cases, e.g. during
1256- * SSS_PAM_PREAUTH either EAGAIN should be returned to indicate
1257- * that the other available authentication methods should be
1258- * checked as well. Or some other error code to indicate a fatal
1259- * error where no other methods should be tried.
1260- * Especially if setting the answer failed neither EOK nor EAGAIN
1261- * should be returned. */
1256+ * SSS_PAM_PREAUTH either ERR_CHECK_NEXT_AUTH_TYPE should be
1257+ * returned to indicate that the other available authentication
1258+ * methods should be checked as well. Or some other error code to
1259+ * indicate a fatal error where no other methods should be tried.
1260+ * Especially if setting the answer failed neither EOK nor
1261+ * ERR_CHECK_NEXT_AUTH_TYPE should be returned. */
12621262 if (strcmp (question_list [c ],
12631263 KRB5_RESPONDER_QUESTION_PASSWORD ) == 0 ) {
12641264 kerr = answer_password (ctx , kr , rctx );
@@ -1288,7 +1288,7 @@ static krb5_error_code sss_krb5_responder(krb5_context ctx,
12881288 /* Continue to the next question when the given authtype cannot be
12891289 * handled by the answer_* function. This allows fallback between auth
12901290 * types, such as passkey -> password. */
1291- if (kerr == EAGAIN ) {
1291+ if (kerr == ERR_CHECK_NEXT_AUTH_TYPE ) {
12921292 /* During pre-auth iterating over all authentication methods
12931293 * is expected and no message will be displayed. */
12941294 if (kr -> pd -> cmd == SSS_PAM_AUTHENTICATE ) {
@@ -1306,17 +1306,18 @@ static krb5_error_code sss_krb5_responder(krb5_context ctx,
13061306 kerr = answer_password (ctx , kr , rctx );
13071307 }
13081308
1309- /* During SSS_PAM_PREAUTH 'EAGAIN' is expected because we will run
1310- * through all offered authentication methods and all are expect to return
1311- * 'EAGAIN' in the positive case to indicate that the other methods should
1312- * be checked as well. If all methods are checked we are done and should
1313- * return success.
1314- * In the other steps, especially SSS_PAM_AUTHENTICATE, having 'EAGAIN' at
1315- * this stage would mean that no method feels responsible for the provided
1316- * credentials i.e. authentication failed and we should return an error.
1309+ /* During SSS_PAM_PREAUTH 'ERR_CHECK_NEXT_AUTH_TYPE' is expected because we
1310+ * will run through all offered authentication methods and all are expect to
1311+ * return 'ERR_CHECK_NEXT_AUTH_TYPE' in the positive case to indicate that
1312+ * the other methods should be checked as well. If all methods are checked
1313+ * we are done and should return success.
1314+ * In the other steps, especially SSS_PAM_AUTHENTICATE, having
1315+ * 'ERR_CHECK_NEXT_AUTH_TYPE' at this stage would mean that no method feels
1316+ * responsible for the provided credentials i.e. authentication failed and
1317+ * we should return an error.
13171318 */
13181319 if (kr -> pd -> cmd == SSS_PAM_PREAUTH ) {
1319- return kerr == EAGAIN ? 0 : kerr ;
1320+ return kerr == ERR_CHECK_NEXT_AUTH_TYPE ? 0 : kerr ;
13201321 } else {
13211322 return kerr ;
13221323 }
@@ -2322,6 +2323,11 @@ static krb5_error_code get_and_save_tgt(struct krb5_req *kr,
23222323 KRB5_CHILD_DEBUG (SSSDBG_CRIT_FAILURE , kerr );
23232324
23242325 if (kerr == EAGAIN ) {
2326+ /* The most probable reason for krb5_get_init_creds_password()
2327+ * to return EAGAIN is a temporary failure getaddrinfo() i.e.
2328+ * DNS currently does not work reliable. In this case it makes
2329+ * sense to return KRB5_KDC_UNREACH to tell the backend to try
2330+ * other KDCs or switch into offline mode. */
23252331 kerr = KRB5_KDC_UNREACH ;
23262332 }
23272333
0 commit comments