]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
various fixes to allow tests to pass
authorAlan T. DeKok <aland@freeradius.org>
Thu, 10 Oct 2019 17:14:58 +0000 (13:14 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 10 Oct 2019 17:14:58 +0000 (13:14 -0400)
empty sections are now allowed.  Interpreter functions now
have to check for empty sections

src/lib/unlang/call.c
src/lib/unlang/compile.c
src/lib/unlang/load_balance.c
src/lib/unlang/subrequest.c
src/tests/keywords/else-empty [moved from src/tests/keywords/else-empty-error with 64% similarity]
src/tests/keywords/redundant-empty
src/tests/keywords/redundant-load-balance

index ab7c98655bdd2313e4a66572d86d96a1fd84749c..1806d17e327b9e1a82d96cd93c4d756a36b5b3af 100644 (file)
@@ -101,7 +101,10 @@ static unlang_action_t unlang_call(REQUEST *request, rlm_rcode_t *presult)
        void                            *process_inst;
 
        g = unlang_generic_to_group(instruction);
-       rad_assert(g->children != NULL);
+       if (!g->num_children) {
+               *presult = RLM_MODULE_NOOP;
+               return UNLANG_ACTION_CALCULATE_RESULT;
+       }
 
        server = cf_section_name2(g->server_cs);
 
index a93f0761aa10b2cfbc3a52a1aef510ab62f5e8b7..ba31922d9a4356317c8a3a047803cb467519450b 100644 (file)
@@ -1830,7 +1830,7 @@ static unlang_t *compile_empty(unlang_t *parent, unlang_compile_t *unlang_ctx, C
         *      *intepreter* type is GROUP, even if the *debug names*
         *      are something else.
         */
-       g = group_allocate(parent, cs, unlang_ops[mod_type].debug_braces ? UNLANG_TYPE_GROUP : mod_type);
+       g = group_allocate(parent, cs, mod_type);
        if (!g) return NULL;
 
        c = unlang_group_to_generic(g);
@@ -2314,11 +2314,6 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
                }
        } /* else it's a default 'case' statement */
 
-       if (!cf_item_next(cs, NULL)) {
-               talloc_free(vpt);
-               return compile_empty(parent, unlang_ctx, cs, UNLANG_TYPE_CASE, COND_TYPE_INVALID);
-       }
-
        c = compile_section(parent, unlang_ctx, cs, UNLANG_TYPE_CASE);
        if (!c) {
                talloc_free(vpt);
index e34868023ce04b8bac7eb323c8ac0274fe913366..a4ade7a4726d221e36002fbbd716b302ce8ff38e 100644 (file)
@@ -117,7 +117,10 @@ static unlang_action_t unlang_load_balance(REQUEST *request, rlm_rcode_t *presul
        uint32_t count = 0;
 
        g = unlang_generic_to_group(instruction);
-       rad_assert(g->children != NULL);
+       if (!g->num_children) {
+               *presult = RLM_MODULE_NOOP;
+               return UNLANG_ACTION_CALCULATE_RESULT;
+       }
 
        RDEBUG4("%s setting up", frame->instruction->debug_name);
 
index ec1804801f890aa7ba08204a70ce8fc44ec605f5..eed4ec91497fc60c6098f1863ea80b8acabead72 100644 (file)
@@ -159,6 +159,13 @@ static unlang_action_t unlang_subrequest_start(REQUEST *request, rlm_rcode_t *pr
        unlang_stack_frame_t            *frame = &stack->frame[stack->depth];
        unlang_frame_state_subrequest_t *state = talloc_get_type_abort(frame->state, unlang_frame_state_subrequest_t);
        REQUEST                         *child = state->child;
+       unlang_group_t                  *g;
+
+       g = unlang_generic_to_group(frame->instruction);
+       if (!g->num_children) {
+               *presult = RLM_MODULE_NOOP;
+               return UNLANG_ACTION_CALCULATE_RESULT;
+       }
 
        /*
         *      Restore state from the parent to the
@@ -192,7 +199,10 @@ static unlang_action_t unlang_subrequest_state_init(REQUEST *request, rlm_rcode_
         *      Initialize the state
         */
        g = unlang_generic_to_group(instruction);
-       rad_assert(g->children != NULL);
+       if (!g->num_children) {
+               *presult = RLM_MODULE_NOOP;
+               return UNLANG_ACTION_CALCULATE_RESULT;
+       }
 
        child = state->child = unlang_io_subrequest_alloc(request, g->dict, UNLANG_DETACHABLE);
        if (!child) {
similarity index 64%
rename from src/tests/keywords/else-empty-error
rename to src/tests/keywords/else-empty
index 4a1880f86170d31b3c900c437aac9395f1a11f53..ef77c3903cbb9489ec246ca89b933fba92862515 100644 (file)
@@ -5,6 +5,6 @@
 if (&User-Name == 'bob') {
        ok
 }
-else { # ERROR
-       # empty is not allowed
+else {
 }
+success
index bec43352b5d7b1ba6cb4eb23b02cb08dba70e0b7..a6a91e9664fba70a276c9462fafd0b427f9fab65 100644 (file)
@@ -1,6 +1,7 @@
 #
-#  Check that redundant blocks can't be empty
+#  Redundant blocks can be empry, and don't do anything
 #
-redundant {    # ERROR
+redundant {
 
 }
+success
index f5503cd79d28cc3d4605237b664ab2f021484ed2..60b5f520fbf28b578cd905b9c75ed85f893a2b02 100644 (file)
@@ -53,6 +53,9 @@ foreach &Tmp-Integer-1 {
 }
 
 if (&Tmp-Integer-0 != "%{Tmp-Integer-1[#]}") {
+   update reply {
+         &Filter-Id := "shit %{Tmp-Integer-0}"
+   }
        test_fail
 }
 else {