]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add a default reply code
authorAlan T. DeKok <aland@freeradius.org>
Tue, 23 Mar 2021 13:06:11 +0000 (09:06 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 31 Mar 2021 15:09:49 +0000 (16:09 +0100)
so that modules which return HANDLED, but don't set the reply
will get a default reply

src/lib/server/process.h

index d885a652f6b6c6fc74c3e2a4f4bed60c4b6903f4..3ea20499329262107ae16d26298ba45266a812fc 100644 (file)
@@ -64,6 +64,7 @@ typedef PROCESS_PACKET_TYPE fr_process_rcode_t[RLM_MODULE_NUMCODES];
  */
 typedef struct {
        PROCESS_PACKET_TYPE     packet_type[RLM_MODULE_NUMCODES];       //!< rcode to packet type mapping.
+       PROCESS_PACKET_TYPE     default_reply;  //!< if not otherwise set
        size_t                  section_offset; //!< Where to look in the process instance for
                                                ///< a pointer to the section we should execute.
        rlm_rcode_t             rcode;          //!< Default rcode
@@ -140,9 +141,12 @@ RESUME(recv_generic)
        fr_assert(rcode < RLM_MODULE_NUMCODES);
 
        UPDATE_STATE(packet);
-       fr_assert(state->packet_type[rcode] != 0);
 
        request->reply->code = state->packet_type[rcode];
+       if (!request->reply->code) request->reply->code = state->default_reply;
+       if (!request->reply->code) request->reply->code = PROCESS_CODE_DO_NOT_RESPOND;
+       fr_assert(request->reply->code != 0);
+
        UPDATE_STATE_CS(reply);
 
        fr_assert(state->send != NULL);