Blame SOURCES/openssh-8.0p1-preserve-pam-errors.patch

7afad6
diff -up openssh-8.0p1/auth-pam.c.preserve-pam-errors openssh-8.0p1/auth-pam.c
7afad6
--- openssh-8.0p1/auth-pam.c.preserve-pam-errors	2021-03-31 17:03:15.618592347 +0200
7afad6
+++ openssh-8.0p1/auth-pam.c	2021-03-31 17:06:58.115220014 +0200
7afad6
@@ -511,7 +511,11 @@ sshpam_thread(void *ctxtp)
7afad6
 		goto auth_fail;
7afad6
 
7afad6
 	if (!do_pam_account()) {
7afad6
-		sshpam_err = PAM_ACCT_EXPIRED;
7afad6
+		/* Preserve PAM_PERM_DENIED and PAM_USER_UNKNOWN.
7afad6
+		 * Backward compatibility for other errors. */
7afad6
+		if (sshpam_err != PAM_PERM_DENIED
7afad6
+			&& sshpam_err != PAM_USER_UNKNOWN)
7afad6
+			sshpam_err = PAM_ACCT_EXPIRED;
7afad6
 		goto auth_fail;
7afad6
 	}
7afad6
 	if (sshpam_authctxt->force_pwchange) {
7afad6
@@ -568,8 +572,10 @@ sshpam_thread(void *ctxtp)
7afad6
 	    pam_strerror(sshpam_handle, sshpam_err))) != 0)
7afad6
 		fatal("%s: buffer error: %s", __func__, ssh_err(r));
7afad6
 	/* XXX - can't do much about an error here */
7afad6
-	if (sshpam_err == PAM_ACCT_EXPIRED)
7afad6
-		ssh_msg_send(ctxt->pam_csock, PAM_ACCT_EXPIRED, buffer);
7afad6
+	if (sshpam_err == PAM_PERM_DENIED
7afad6
+		|| sshpam_err == PAM_USER_UNKNOWN
7afad6
+		|| sshpam_err == PAM_ACCT_EXPIRED)
7afad6
+		ssh_msg_send(ctxt->pam_csock, sshpam_err, buffer);
7afad6
 	else if (sshpam_maxtries_reached)
7afad6
 		ssh_msg_send(ctxt->pam_csock, PAM_MAXTRIES, buffer);
7afad6
 	else
7afad6
@@ -856,10 +862,12 @@ sshpam_query(void *ctx, char **name, cha
7afad6
 			plen++;
7afad6
 			free(msg);
7afad6
 			break;
7afad6
+		case PAM_USER_UNKNOWN:
7afad6
+		case PAM_PERM_DENIED:
7afad6
 		case PAM_ACCT_EXPIRED:
7afad6
+			sshpam_account_status = 0;
7afad6
+			/* FALLTHROUGH */
7afad6
 		case PAM_MAXTRIES:
7afad6
-			if (type == PAM_ACCT_EXPIRED)
7afad6
-				sshpam_account_status = 0;
7afad6
 			if (type == PAM_MAXTRIES)
7afad6
 				sshpam_set_maxtries_reached(1);
7afad6
 			/* FALLTHROUGH */