]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Always respect Response-Packet-Type for authentication requests
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 21 Dec 2012 15:13:11 +0000 (15:13 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 21 Dec 2012 15:13:11 +0000 (15:13 +0000)
src/main/process.c

index 663aeab8db2547c25b13aa1d959830d85aba2765..6bef46a5b93a2c20d33b6b36d270227410241cfe 100644 (file)
@@ -1060,32 +1060,32 @@ STATE_MACHINE_DECL(request_finish)
        /*
         *      Catch Auth-Type := Reject BEFORE proxying the packet.
         */
-       if ((request->packet->code == PW_AUTHENTICATION_REQUEST) &&
-           (request->reply->code == 0)) {
-               if (((vp = pairfind(request->config_items, PW_AUTH_TYPE, 0)) != NULL) &&
-                   (vp->vp_integer == PW_AUTHTYPE_REJECT)) {
-                       request->reply->code = PW_AUTHENTICATION_REJECT;
-
-               } else {
-                       /*
-                        *      Check if the lack of response is
-                        *      intentional.
-                        */
-                       vp = pairfind(request->config_items,
-                                     PW_RESPONSE_PACKET_TYPE, 0);
-                       if (!vp) {
-                               RDEBUG2("There was no response configured: rejecting request");
-                               request->reply->code = PW_AUTHENTICATION_REJECT;
-
-                       } else if (vp->vp_integer == 256) {
+       if (request->packet->code == PW_AUTHENTICATION_REQUEST) {
+               /*
+                *      Override the response code if a 
+                *      control:Response-Packet-Type attribute is present.
+                */
+               vp = pairfind(request->config_items, PW_RESPONSE_PACKET_TYPE, 0);
+               if (vp) {
+                       if (vp->vp_integer == 256) {
                                RDEBUG2("Not responding to request");
 
+                               request->reply->code = 0;
                        } else {
                                request->reply->code = vp->vp_integer;
                        }
+               } else if (request->reply->code == 0) {
+                       vp = pairfind(request->config_items, PW_AUTH_TYPE, 0);
+                       
+                       if (!vp || (vp->vp_integer != PW_AUTHENTICATION_REJECT)) {
+                               RDEBUG2("There was no response configured: "
+                                       "rejecting request");
+                       }
+                       
+                       request->reply->code = PW_AUTHENTICATION_REJECT;
                }
        }
-
+       
        /*
         *      Copy Proxy-State from the request to the reply.
         */