]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
hack together "call"
authorAlan T. DeKok <aland@freeradius.org>
Thu, 14 Sep 2017 23:29:58 +0000 (19:29 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 14 Sep 2017 23:30:32 +0000 (19:30 -0400)
it doesn't do yeild, and it overloads things it shouldn't overload
but it works.  It can be cleaned up later

src/include/interpreter.h
src/main/unlang_compile.c
src/main/unlang_interpret.c

index 6c3ef1194dc3032dd3cc082e33424f277be402f3..2979fc02d082062dfc981bd9db5e6f22ca5469db 100644 (file)
@@ -140,6 +140,7 @@ typedef struct {
                map_proc_inst_t         *proc_inst;     //!< Instantiation data for #UNLANG_TYPE_MAP.
                void const              *process;       //!< UNLANG_TYPE_CALL
        };
+       CONF_SECTION            *server_cs;             //!< UNLANG_TYPE_CALL
 } unlang_group_t;
 
 /** A call to a module method
index e2517f8581d3c08633002416eb6a8b6a01446e9c..79ca132c18b1e3a3f99df8ed0a5a055abc5bbc1c 100644 (file)
@@ -2661,10 +2661,11 @@ static unlang_t *compile_call(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
        }
 
        g->process = *process_p;
+       g->server_cs = server_cs;
 
        c = unlang_group_to_generic(g);
        c->name = unlang_ops[c->type].name;
-       c->debug_name = c->name;
+       c->debug_name = talloc_asprintf(c, "%s %s", c->name, server);
 
        return compile_children(g, parent, unlang_ctx, group_type, parentgroup_type);
 }
index 4c543346cc21fce7e26e0730f7551964e726bff3..aff6c9289e99501a8a0a488405c52fd7ee29f41f 100644 (file)
@@ -713,14 +713,50 @@ static unlang_action_t unlang_call(REQUEST *request, unlang_stack_t *stack,
        unlang_stack_frame_t    *frame = &stack->frame[stack->depth];
        unlang_t                *instruction = frame->instruction;
        unlang_group_t          *g;
+       int                     indent;
+       fr_io_final_t           final;
+       unlang_stack_t          *current;
+       CONF_SECTION            *server_cs;
 
        g = unlang_generic_to_group(instruction);
        rad_assert(g->children != NULL);
 
        rad_assert(request->async->process == unlang_process_continue);
+       rad_assert(stack == request->stack); /* probably want to just remove the 'stack' parameter */
 
-       RDEBUG("FAKING CALL TO %s", g->vpt->name);
+       indent = request->log.unlang_indent;
+       request->log.unlang_indent = 0; /* the process function expects this */
 
+       current = request->stack;
+       request->stack = talloc_zero(request, unlang_stack_t);
+
+       server_cs = request->server_cs;
+       request->server_cs = g->server_cs;
+
+       request->async->process = g->process;
+
+       RDEBUG("server %s {", cf_section_name2(g->server_cs));
+
+       final = request->async->process(request, FR_IO_ACTION_RUN);
+
+       RDEBUG("} # server %s", cf_section_name2(g->server_cs));
+
+       /*
+        *      @todo - handle other return codes later.
+        */
+       rad_assert(final == FR_IO_REPLY);
+
+       request->log.unlang_indent = indent;
+       request->async->process = unlang_process_continue;
+       talloc_free(request->stack);
+       request->stack = current;
+       request->server_cs = server_cs;
+
+       RDEBUG("Continuing with contents of %s { ...", instruction->debug_name);
+
+       /*
+        *      And then call the children to process the answer.
+        */
        unlang_push(stack, g->children, frame->result, UNLANG_NEXT_CONTINUE, UNLANG_SUB_FRAME);
        return UNLANG_ACTION_PUSHED_CHILD;
 }