]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove "auto_converted" flag from templates.
authorAlan T. DeKok <aland@freeradius.org>
Tue, 28 Mar 2017 20:01:06 +0000 (16:01 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 28 Mar 2017 20:01:06 +0000 (16:01 -0400)
Only the compiler should auto-convert things, and then only
if the LHS / RHS match in data type, and in parsing of that
data type

src/include/tmpl.h
src/main/tmpl.c
src/main/unlang_compile.c

index 5b29738ab0ca1af10e565a9be62be07926cdd3cf..2494ed585fe49f1f12bbf6fe58ec1514b457d46d 100644 (file)
@@ -174,8 +174,6 @@ typedef struct vp_tmpl_t {
        size_t          len;            //!< Length of the raw string used to create the template.
        FR_TOKEN        quote;          //!< What type of quoting was around the raw string.
 
-       bool            auto_converted; //!< Attr-26.9.1 --> Cisco-AVPair
-
 #ifdef HAVE_REGEX
        bool            iflag;          //!< regex - case insensitive (if operand is used in regex comparison)
        bool            mflag;          //!< regex - multiline flags (controls $ matching)
index 686b4f1a0d4d2aac4a8c7391ad2412c22f96d159..67b60babbca385066af8daeae311886fd2819435 100644 (file)
@@ -715,31 +715,26 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *nam
                break;
        }
 
+       /*
+        *      Look up by name, *including* any Attr-1.2.3.4 which was created when
+        *      parsing the configuration files.
+        */
        vpt->tmpl_da = fr_dict_attr_by_name_substr(NULL, &p);
        if (!vpt->tmpl_da) {
                char const *q;
 
                fr_strerror();  /* Clear out any existing errors */
 
+               /*
+                *      At this point, the OID *must* be unknown, and
+                *      not previously used.
+                */
                slen = fr_dict_unknown_afrom_oid_substr(vpt, &vpt->tmpl_unknown,
                                                        fr_dict_root(fr_dict_internal), p);
                /*
                 *      Attr-1.2.3.4 is OK.
                 */
                if (slen > 0) {
-                       /*
-                        *      Check what we just parsed really hasn't been defined
-                        *      in the main dictionaries.
-                        *
-                        *      If it has, parsing is the same as if the attribute
-                        *      name had been used instead of its OID.
-                        */
-                       vpt->tmpl_da = fr_dict_attr_by_name(NULL, p);
-                       if (vpt->tmpl_da) {
-                               vpt->auto_converted = true;
-                               goto do_num;
-                       }
-
                        if (!allow_unknown) {
                                fr_strerror_printf("Unknown attribute");
                                slen = -(p - name);
index aaae2d86fbfa31aeb31d4ce483a933b005422149..97c6c270e083669db54e4e08bbe63eb27530eb10 100644 (file)
@@ -722,27 +722,10 @@ static bool pass2_cond_callback(void *ctx, fr_cond_t *c)
                         */
                        if ((map->lhs->type == TMPL_TYPE_ATTR) &&
                            (map->rhs->type == TMPL_TYPE_UNPARSED)) {
-                               /*
-                                *      RHS is hex, try to parse it as
-                                *      type-specific data.
-                                */
-                               if (map->lhs->auto_converted &&
-                                   (map->rhs->name[0] == '0') && (map->rhs->name[1] == 'x') &&
-                                   (map->rhs->len > 2) && ((map->rhs->len & 0x01) == 0)) {
-                                       vpt = map->rhs;
-                                       map->rhs = NULL;
-
-                                       if (!map_cast_from_hex(map, T_BARE_WORD, vpt->name)) {
-                                               map->rhs = vpt;
-                                               cf_log_err(map->ci, "Cannot parse RHS hex as the data type of the attribute %s", map->lhs->tmpl_da->name);
-                                               return -1;
-                                       }
-                                       talloc_free(vpt);
-
-                               } else if ((map->rhs->len > 0) ||
-                                          (map->op != T_OP_CMP_EQ) ||
-                                          (map->lhs->tmpl_da->type == PW_TYPE_STRING) ||
-                                          (map->lhs->tmpl_da->type == PW_TYPE_OCTETS)) {
+                               if ((map->rhs->len > 0) ||
+                                   (map->op != T_OP_CMP_EQ) ||
+                                   (map->lhs->tmpl_da->type == PW_TYPE_STRING) ||
+                                   (map->lhs->tmpl_da->type == PW_TYPE_OCTETS)) {
 
                                        if (tmpl_cast_in_place(map->rhs, map->lhs->tmpl_da->type, map->lhs->tmpl_da) < 0) {
                                                cf_log_err(map->ci, "Failed to parse data type %s from string: %s",
@@ -1277,27 +1260,11 @@ int unlang_fixup_update(vp_map_t *map, UNUSED void *ctx)
         *      ignore map->rhs.
         */
        if ((map->lhs->type == TMPL_TYPE_ATTR) && (map->rhs->type == TMPL_TYPE_UNPARSED)) {
-               /*
-                *      Convert it to the correct type.
-                */
-               if (map->lhs->auto_converted &&
-                   (map->rhs->name[0] == '0') && (map->rhs->name[1] == 'x') &&
-                   (map->rhs->len > 2) && ((map->rhs->len & 0x01) == 0)) {
-                       vp_tmpl_t *vpt = map->rhs;
-                       map->rhs = NULL;
-
-                       if (!map_cast_from_hex(map, T_BARE_WORD, vpt->name)) {
-                               map->rhs = vpt;
-                               cf_log_err(map->ci, "Cannot parse RHS hex as the data type of the attribute %s", map->lhs->tmpl_da->name);
-                               return -1;
-                       }
-                       talloc_free(vpt);
-
                /*
                 *      It's a literal string, just copy it.
                 *      Don't escape anything.
                 */
-               } else if (tmpl_cast_in_place(map->rhs, map->lhs->tmpl_da->type, map->lhs->tmpl_da) < 0) {
+               if (tmpl_cast_in_place(map->rhs, map->lhs->tmpl_da->type, map->lhs->tmpl_da) < 0) {
                        cf_log_err(map->ci, "%s", fr_strerror());
                        return -1;
                }