bmh10 / rpms / openssh

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