]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
clean up compile_action_pair
authorAlan T. DeKok <aland@freeradius.org>
Wed, 13 Sep 2017 18:12:11 +0000 (14:12 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 13 Sep 2017 18:12:11 +0000 (14:12 -0400)
and require action over-rides to be an "actions" section

src/main/unlang_compile.c
src/tests/modules/linelog/linelog-delim.unlang
src/tests/modules/linelog/linelog-escapes.unlang
src/tests/modules/linelog/linelog-multi.unlang
src/tests/modules/linelog/linelog.unlang

index 674e819b462f990d3dce683cec7c521e2c49921f..29db9f5398218f0e3e6874de04aaa22b47b940ce 100644 (file)
@@ -1679,6 +1679,8 @@ static unlang_t *compile_children(unlang_group_t *g, UNUSED unlang_t *parent, un
         *      Loop over the children of this group.
         */
        while ((ci = cf_item_next(g->cs, ci))) {
+               if (cf_item_is_data(ci)) continue;
+
                /*
                 *      Sections are references to other groups, or
                 *      to modules with updated return codes.
@@ -1759,20 +1761,17 @@ static unlang_t *compile_children(unlang_group_t *g, UNUSED unlang_t *parent, un
                                }
                                add_child(g, single);
 
-                               /*
-                                *      Or it MUST be a module instance with action.
-                                */
-                       } else if (parent->type != UNLANG_TYPE_MODULE_CALL) {
-                               cf_log_err(ci, "Invalid location for action over-ride");
+                       } else if (!parent || (parent->type != UNLANG_TYPE_MODULE_CALL)) {
+                               cf_log_err(cp, "Invalid location for action over-ride");
                                talloc_free(c);
                                return NULL;
 
-                       } else if (!compile_action_pair(c, cp)) {
-                               talloc_free(c);
-                               return NULL;
-                       } /* else it worked */
-               } else if (cf_item_is_data(ci)) {
-                       continue;
+                       } else {
+                               if (!compile_action_pair(c, cp)) {
+                                       talloc_free(c);
+                                       return NULL;
+                               }
+                       }
                } else {
                        rad_assert(0);
                }
index 714d4220757c55b9e47a133e0d764fc856f566bc..2e96bc955f28bcca911f03ecd03167ec4ef3a981 100644 (file)
@@ -9,7 +9,14 @@ group {
        update request {
                Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_delim.log"`
        }
-       fail = 1
+
+       #
+       #  We can only over-ride actions in an "actions" subsection,
+       #  and then only as the last item in a group.
+       #
+       actions {
+               fail = 1
+       }
 }
 if (fail) {
        ok
index d80b988d318cca60d8a711e8412444ec842c7e3f..9e1f2ba11fcbbf351641e3641b0a914c14b316a1 100644 (file)
@@ -10,7 +10,10 @@ group {
        update request {
                Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_escapes.log"`
        }
-       fail = 1
+
+       actions {
+               fail = 1
+       }
 }
 if (fail) {
        ok
index ab94a1085011a4a86af7529d44ec6627b0b42279..3536a8d23ce32e678f5a09e4730dda24c8140c40 100644 (file)
@@ -9,7 +9,10 @@ group {
        update request {
                Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_multi.log"`
        }
-       fail = 1
+
+       actions {
+               fail = 1
+       }
 }
 if (fail) {
        ok
index 08d2af1ab33614eb9c256ec9a0c5bb883ae52153..29f67959a62533f1e838a49a975e99ddd24c211c 100644 (file)
@@ -9,7 +9,10 @@ group {
        update request {
                Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_a.log"`
        }
-       fail = 1
+
+       actions {
+               fail = 1
+       }
 }
 if (fail) {
        ok
@@ -138,7 +141,10 @@ group {
        update request {
                Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_b.log"`
        }
-       fail = 1
+
+       actions {
+               fail = 1
+       }
 }
 if (fail) {
        ok
@@ -160,7 +166,10 @@ group {
        update request {
                Tmp-String-0 := `/bin/sh -c "test ! -e $ENV{MODULE_TEST_DIR}/test_b.log"`
        }
-       fail = 1
+
+       actions {
+               fail = 1
+       }
 }
 if (fail) {
        test_fail
@@ -196,7 +205,10 @@ group {
        update request {
                Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_c.log"`
        }
-       fail = 1
+
+       actions {
+               fail = 1
+       }
 }
 if (fail) {
        ok
@@ -304,7 +316,10 @@ group {
        update request {
                Tmp-String-0 := `/bin/sh -c "rm $ENV{MODULE_TEST_DIR}/test_d.log"`
        }
-       fail = 1
+
+       actions {
+               fail = 1
+       }
 }
 if (fail) {
        ok