From: Alan T. DeKok Date: Wed, 13 Sep 2017 18:12:11 +0000 (-0400) Subject: clean up compile_action_pair X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a98e97dcfab12ce33b994c56d43ae98abbcbf8e1;p=thirdparty%2Ffreeradius-server.git clean up compile_action_pair and require action over-rides to be an "actions" section --- diff --git a/src/main/unlang_compile.c b/src/main/unlang_compile.c index 674e819b462..29db9f53982 100644 --- a/src/main/unlang_compile.c +++ b/src/main/unlang_compile.c @@ -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); } diff --git a/src/tests/modules/linelog/linelog-delim.unlang b/src/tests/modules/linelog/linelog-delim.unlang index 714d4220757..2e96bc955f2 100644 --- a/src/tests/modules/linelog/linelog-delim.unlang +++ b/src/tests/modules/linelog/linelog-delim.unlang @@ -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 diff --git a/src/tests/modules/linelog/linelog-escapes.unlang b/src/tests/modules/linelog/linelog-escapes.unlang index d80b988d318..9e1f2ba11fc 100644 --- a/src/tests/modules/linelog/linelog-escapes.unlang +++ b/src/tests/modules/linelog/linelog-escapes.unlang @@ -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 diff --git a/src/tests/modules/linelog/linelog-multi.unlang b/src/tests/modules/linelog/linelog-multi.unlang index ab94a108501..3536a8d23ce 100644 --- a/src/tests/modules/linelog/linelog-multi.unlang +++ b/src/tests/modules/linelog/linelog-multi.unlang @@ -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 diff --git a/src/tests/modules/linelog/linelog.unlang b/src/tests/modules/linelog/linelog.unlang index 08d2af1ab33..29f67959a62 100644 --- a/src/tests/modules/linelog/linelog.unlang +++ b/src/tests/modules/linelog/linelog.unlang @@ -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