aboutsummaryrefslogtreecommitdiffstats
path: root/main/freeradius/allow-request_will_proxy-to-return-an-error.patch
blob: 34e352f4238f5f6880bc1d174f8a048da940c95b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 76e95d4300faa4ec0da970345e0043d6811896c5 Mon Sep 17 00:00:00 2001
From: "Alan T. DeKok" <aland@freeradius.org>
Date: Sat, 18 Apr 2020 19:40:28 -0400
Subject: [PATCH] allow request_will_proxy() to return an error

and check it in request_running()
---
 src/main/process.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/main/process.c b/src/main/process.c
index 1a48517d43..fcd0a0ad06 100644
--- a/src/main/process.c
+++ b/src/main/process.c
@@ -1598,6 +1598,8 @@ static void request_finish(REQUEST *request, int action)
  */
 static void request_running(REQUEST *request, int action)
 {
+	int rcode;
+
 	VERIFY_REQUEST(request);
 
 	TRACE_STATE_MACHINE;
@@ -1631,7 +1633,8 @@ static void request_running(REQUEST *request, int action)
 		/*
 		 *	We may need to send a proxied request.
 		 */
-		if (request_will_proxy(request)) {
+		rcode = request_will_proxy(request);
+		if (rcode == 1) {
 #ifdef DEBUG_STATE_MACHINE
 			if (rad_debug_lvl) printf("(%u) ********\tWill Proxy\t********\n", request->number);
 #endif
@@ -1648,6 +1651,14 @@ static void request_running(REQUEST *request, int action)
 				process_proxy_reply(request, NULL);
 				goto req_finished;
 			}
+
+		} else if (rcode < 0) {
+			/*
+			 *	No live home servers, run Post-Proxy-Type Fail.
+			 */
+			(void) setup_post_proxy_fail(request);
+			process_proxy_reply(request, NULL);
+			goto req_finished;
 		} else
 #endif
 		{
@@ -3082,7 +3093,7 @@ static int request_will_proxy(REQUEST *request)
 
 	if (!home) {
 		REDEBUG2("Failed to find live home server: Cancelling proxy");
-		return 1;
+		return -1;
 	}
 
 do_home: