]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow setting of Response-Packet-Type in Post-Proxy-Type fail
authorAlan T. DeKok <aland@freeradius.org>
Wed, 13 Jan 2016 22:20:37 +0000 (17:20 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 13 Jan 2016 22:20:37 +0000 (17:20 -0500)
which lets you "invent" responses when the home server times out

src/main/process.c

index ff46605177981296adaea731f9166b23bbefa9e3..d3c44dbe802fc4fd8127583d2e55af235489699a 100644 (file)
@@ -2395,7 +2395,7 @@ static int process_proxy_reply(REQUEST *request, RADIUS_PACKET *reply)
        }
 
 #ifdef WITH_COA
-       if (request->packet->code == request->proxy->code)
+       if (request->packet->code == request->proxy->code) {
          /*
           *    Don't run the next bit if we originated a CoA
           *    packet, after receiving an Access-Request or
@@ -2403,21 +2403,31 @@ static int process_proxy_reply(REQUEST *request, RADIUS_PACKET *reply)
           */
 #endif
 
-       /*
-        *      There may NOT be a proxy reply, as we may be
-        *      running Post-Proxy-Type = Fail.
-        */
-       if (reply) {
-               fr_pair_add(&request->reply->vps, fr_pair_list_copy(request->reply, reply->vps));
-
                /*
-                *      Delete the Proxy-State Attributes from
-                *      the reply.  These include Proxy-State
-                *      attributes from us and remote server.
+                *      There may NOT be a proxy reply, as we may be
+                *      running Post-Proxy-Type = Fail.
                 */
-               fr_pair_delete_by_num(&request->reply->vps, PW_PROXY_STATE, 0, TAG_ANY);
-       }
+               if (reply) {
+                       fr_pair_add(&request->reply->vps, fr_pair_list_copy(request->reply, reply->vps));
+
+                       /*
+                        *      Delete the Proxy-State Attributes from
+                        *      the reply.  These include Proxy-State
+                        *      attributes from us and remote server.
+                        */
+                       fr_pair_delete_by_num(&request->reply->vps, PW_PROXY_STATE, 0, TAG_ANY);
 
+               } else {
+                       vp = fr_pair_find_by_num(request->config, PW_RESPONSE_PACKET_TYPE, 0, TAG_ANY);
+                       if (vp) {
+                               request->proxy_reply = rad_alloc_reply(request, request->proxy);
+                               request->proxy_reply->code = vp->vp_integer;
+                               fr_pair_delete_by_num(&request->config, PW_RESPONSE_PACKET_TYPE, 0, TAG_ANY);
+                       }
+               }
+#ifdef WITH_COA
+       }
+#endif
        switch (rcode) {
        default:  /* Don't do anything */
                break;