kentpeacock / rpms / openssh

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