]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add dictionary pointer to request, and use it to qualify name based dictionary lookups
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 30 May 2018 05:46:43 +0000 (11:46 +0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 30 May 2018 15:14:40 +0000 (21:14 +0600)
13 files changed:
src/include/radiusd.h
src/main/request.c
src/main/tmpl.c
src/main/trigger.c
src/modules/proto_dhcpv4/proto_dhcpv4.c
src/modules/proto_radius/proto_radius.c
src/modules/proto_vmps/proto_vmps.c
src/modules/rlm_client/rlm_client.c
src/modules/rlm_couchbase/mod.c
src/modules/rlm_csv/rlm_csv.c
src/modules/rlm_lua/lua.c
src/modules/rlm_rest/rest.c
src/modules/rlm_stats/rlm_stats.c

index 180ef2c33a171a3d3bec34ac5c321c96c182d4af..2956260af21300499265097530203118b35c9d1d 100644 (file)
@@ -212,6 +212,8 @@ struct rad_request {
        uint64_t                child_number;   //!< Monotonically increasing number for children of this request
        char const              *name;          //!< for debug printing, as (%d) is no longer sufficient
 
+       fr_dict_t const         *dict;          //!< Dictionary of the protocol that this request belongs to.
+
        fr_event_list_t         *el;            //!< thread-specific event list.
        fr_heap_t               *backlog;       //!< thread-specific backlog
        fr_request_state_t      request_state;  //!< state for the various protocol handlers.
index e40eca736a1d5be44824ac244a19da6b7cbe0683..e20e807ad502b467560e2ea41b6c38352a1ebf54 100644 (file)
@@ -123,6 +123,7 @@ static REQUEST *request_init_fake(REQUEST *request, REQUEST *fake)
        fake->seq_start = 0;    /* children always start with their own sequence */
 
        fake->parent = request;
+       fake->dict = request->dict;
        fake->root = request->root;
        fake->client = request->client;
 
index 8164540340c8a1a319f40764984b48c83d4fde7b..e172c02306f73bbfdb45dfe713194cd662d0c93a 100644 (file)
@@ -2506,7 +2506,7 @@ void tmpl_verify(char const *file, int line, vp_tmpl_t const *vpt)
                        /*
                         *      Attribute may be present with multiple names
                         */
-                       da = fr_dict_attr_by_name(NULL, vpt->tmpl_da->name);
+                       da = fr_dict_attr_by_name(fr_dict_by_da(vpt->tmpl_da), vpt->tmpl_da->name);
                        if (!da) {
                                FR_FAULT_LOG("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_ATTR "
                                             "attribute \"%s\" (%s) not found in global dictionary",
index d417be0e004d831b858025dde6bf121510caf792..68ea00a1b7c4e130f712a5a9b9d0d8d338fe5d6c 100644 (file)
@@ -67,7 +67,7 @@ static ssize_t xlat_trigger(UNUSED TALLOC_CTX *ctx, char **out, UNUSED size_t ou
         */
        if (!head) return -1;
 
-       da = fr_dict_attr_by_name(NULL, fmt);
+       da = fr_dict_attr_by_name(request->dict, fmt);
        if (!da) {
                ERROR("Unknown attribute \"%s\"", fmt);
                return -1;
index bac0c15c0eca048cd3e1a9515b1c3aaa51fa312e..e06bcbd93bbd66fe0001cf9a3b8b0a58a87602f7 100644 (file)
@@ -264,6 +264,13 @@ static int mod_decode(void const *instance, REQUEST *request, uint8_t *const dat
 
        rad_assert(data[0] < FR_MAX_PACKET_CODE);
 
+       /*
+        *      Set the request dictionary so that we can do
+        *      generic->protocol attribute conversions as
+        *      the request runs through the server.
+        */
+       request->dict = dict_dhcpv4;
+
 #if 0
        /*
         *      @todo - print hex packets here!
index ddbf6a13ef86b3cf02dd97442826b588c77ec3ea..1d393fbfcb6ebb074c0220e8cc242464970e4334 100644 (file)
@@ -299,6 +299,13 @@ static int mod_decode(void const *instance, REQUEST *request, uint8_t *const dat
                fr_radius_print_hex(fr_log_fp, data, data_len);
        }
 
+       /*
+        *      Set the request dictionary so that we can do
+        *      generic->protocol attribute conversions as
+        *      the request runs through the server.
+        */
+       request->dict = dict_radius;
+
        client = address->radclient;
 
        /*
index 5fe29413f56babb1e64dd6e9836efa030018118f..907d5ef19f2acd7b28c27638408e560ece3b02ac 100644 (file)
@@ -229,6 +229,13 @@ static int mod_decode(void const *instance, REQUEST *request, uint8_t *const dat
                fr_vmps_print_hex(fr_log_fp, data, data_len);
        }
 
+       /*
+        *      Set the request dictionary so that we can do
+        *      generic->protocol attribute conversions as
+        *      the request runs through the server.
+        */
+       request->dict = dict_vqp;
+
        client = address->radclient;
 
        /*
index bbc61f4b27ad82e5bccbf6296232ff28f35deb0c..b83c427084b6ec96a0f348e027602cdace825cd5 100644 (file)
@@ -65,7 +65,7 @@ static int _map_proc_client_get_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *r
                        return -1;
                }
 
-               da = fr_dict_attr_by_name(NULL, attr);
+               da = fr_dict_attr_by_name(request->dict, attr);
                if (!da) {
                        RWDEBUG("No such attribute '%s'", attr);
                        return -1;
index fcc43673f84a792b494604611355660f3eff750f..fd7943aa3d1a3040fb66bfbf66f418a8247a1bcf 100644 (file)
@@ -369,7 +369,7 @@ int mod_json_object_to_map(TALLOC_CTX *ctx, fr_cursor_t *out, REQUEST *request,
                 *      Lookup the string attr_name in the
                 *      request dictionary.
                 */
-               da = fr_dict_attr_by_name(NULL, attr_name);
+               da = fr_dict_attr_by_name(request->dict, attr_name);
                if (!da) {
                        RPERROR("Invalid attribute \"%s\"", attr_name);
                        goto error;
index 32ef571a51ddb0708926f23bcad6612ad66f50f1..42f96d4f3b0ea7ac508e45693908d08c13c8a84f 100644 (file)
@@ -428,7 +428,8 @@ static int csv_map_getvalue(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request,
                        return -1;
                }
 
-               da = fr_dict_attr_by_name(NULL, attr);
+
+               da = fr_dict_attr_by_name(request->dict, attr);
                if (!da) {
                        RWDEBUG("No such attribute '%s'", attr);
                        return -1;
index e81606c0755ecd09c0e1b36648550194ca8b88a8..a8575e1a6e46bd833cd2b47ddefc34b808e95f89 100644 (file)
@@ -544,7 +544,7 @@ static int _lua_pair_accessor_init(lua_State *L)
                return -1;
        }
 
-       da = fr_dict_attr_by_name(NULL, attr);
+       da = fr_dict_attr_by_name(request->dict, attr);
        if (!da) {
                REDEBUG("Unknown or invalid attribute name \"%s\"", attr);
                return -1;
index 70b225306eb07c5e9e501fdb496b24097abfaa7f..2475be45463df2c27a996f1e5a6fb9813d880bef 100644 (file)
@@ -791,7 +791,7 @@ static int rest_decode_post(UNUSED rlm_rest_t const *instance, UNUSED rlm_rest_s
                        continue;
                }
 
-               da = fr_dict_attr_by_name(NULL, attribute);
+               da = fr_dict_attr_by_name(request->dict, attribute);
                if (!da) {
                        RWDEBUG("Attribute \"%s\" unknown, skipping", attribute);
 
index 9246ec387646b2cf228fbd917d5ae4e1f2d82a5f..cecec0ca92b2399ab6cb3d97ebc5181a5862414c 100644 (file)
@@ -344,7 +344,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_stats(void *instance, void *thread, REQU
                if (!local_stats[i]) continue;
 
                strlcpy(buffer + 18, fr_packet_codes[i], sizeof(buffer) - 18);
-               da = fr_dict_attr_by_name(NULL, buffer);
+               da = fr_dict_attr_by_name(dict_radius, buffer);
                if (!da) continue;
 
                vp = fr_pair_afrom_da(request->reply, da);