bmh10 / rpms / openssh

Forked from rpms/openssh 2 days ago
Clone
Dmitry Belyavskiy a43be1
diff -u -p -r1.166 auth2.c
Dmitry Belyavskiy a43be1
--- a/auth2.c	8 Mar 2023 04:43:12 -0000	1.166
Dmitry Belyavskiy a43be1
+++ b/auth2.c	28 Aug 2023 08:32:44 -0000
Dmitry Belyavskiy a43be1
@@ -208,6 +208,7 @@ input_service_request(int type, u_int32_
Dmitry Belyavskiy a43be1
 }
Dmitry Belyavskiy a43be1
 
Dmitry Belyavskiy a43be1
 #define MIN_FAIL_DELAY_SECONDS 0.005
Dmitry Belyavskiy a43be1
+#define MAX_FAIL_DELAY_SECONDS 5.0
Dmitry Belyavskiy a43be1
 static double
Dmitry Belyavskiy a43be1
 user_specific_delay(const char *user)
Dmitry Belyavskiy a43be1
 {
Dmitry Belyavskiy a43be1
@@ -233,6 +234,12 @@ ensure_minimum_time_since(double start, 
Dmitry Belyavskiy a43be1
 	struct timespec ts;
Dmitry Belyavskiy a43be1
 	double elapsed = monotime_double() - start, req = seconds, remain;
Dmitry Belyavskiy a43be1
 
Dmitry Belyavskiy a43be1
+	if (elapsed > MAX_FAIL_DELAY_SECONDS) {
Dmitry Belyavskiy a43be1
+		debug3_f("elapsed %0.3lfms exceeded the max delay "
Dmitry Belyavskiy a43be1
+		    "requested %0.3lfms)", elapsed*1000, req*1000);
Dmitry Belyavskiy a43be1
+		return;
Dmitry Belyavskiy a43be1
+	}
Dmitry Belyavskiy a43be1
+
Dmitry Belyavskiy a43be1
 	/* if we've already passed the requested time, scale up */
Dmitry Belyavskiy a43be1
 	while ((remain = seconds - elapsed) < 0.0)
Dmitry Belyavskiy a43be1
 		seconds *= 2;
Dmitry Belyavskiy a43be1
@@ -317,7 +324,7 @@ input_userauth_request(int type, u_int32
Dmitry Belyavskiy a43be1
 		debug2("input_userauth_request: try method %s", method);
Dmitry Belyavskiy a43be1
 		authenticated =	m->userauth(ssh);
Dmitry Belyavskiy a43be1
 	}
Dmitry Belyavskiy a43be1
-	if (!authctxt->authenticated)
Dmitry Belyavskiy a43be1
+	if (!authctxt->authenticated && strcmp(method, "none") != 0)
Dmitry Belyavskiy a43be1
 		ensure_minimum_time_since(tstart,
Dmitry Belyavskiy a43be1
 		    user_specific_delay(authctxt->user));
Dmitry Belyavskiy a43be1
 	userauth_finish(ssh, authenticated, method, NULL);