]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
verify that server.PACKET-Type exists
authorAlan T. DeKok <aland@freeradius.org>
Thu, 14 Sep 2017 17:22:51 +0000 (13:22 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 14 Sep 2017 23:30:32 +0000 (19:30 -0400)
src/include/interpreter.h
src/main/unlang_compile.c

index 006162700f32de17466189649d35b40b5732a917..6c3ef1194dc3032dd3cc082e33424f277be402f3 100644 (file)
@@ -131,11 +131,15 @@ typedef struct {
        CONF_SECTION            *cs;
        int                     num_children;
 
-       vp_map_t                *map;           //!< #UNLANG_TYPE_UPDATE, #UNLANG_TYPE_MAP.
        vp_tmpl_t               *vpt;           //!< #UNLANG_TYPE_SWITCH, #UNLANG_TYPE_MAP.
-       fr_cond_t               *cond;          //!< #UNLANG_TYPE_IF, #UNLANG_TYPE_ELSIF.
 
-       map_proc_inst_t         *proc_inst;     //!< Instantiation data for #UNLANG_TYPE_MAP.
+       vp_map_t                *map;           //!< #UNLANG_TYPE_UPDATE, #UNLANG_TYPE_MAP.
+       union {
+               fr_cond_t               *cond;          //!< #UNLANG_TYPE_IF, #UNLANG_TYPE_ELSIF.
+
+               map_proc_inst_t         *proc_inst;     //!< Instantiation data for #UNLANG_TYPE_MAP.
+               void const              *process;       //!< UNLANG_TYPE_CALL
+       };
 } unlang_group_t;
 
 /** A call to a module method
index d0461b24fef2ceab7a52106256d7a93bcd26e5b0..aee3c8c9ae0bd18e10a4ee59bbe979fb24ff3a1c 100644 (file)
@@ -2564,6 +2564,9 @@ static unlang_t *compile_call(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
        unlang_group_t *g;
        unlang_t *c;
        FR_TOKEN type;
+       char *server;
+       char *packet;
+       CONF_SECTION *server_cs, *root;
 
        name2 = cf_section_name2(cs);
        if (!name2) {
@@ -2605,8 +2608,41 @@ static unlang_t *compile_call(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
        tmpl_cast_in_place_str(g->vpt);
 
        /*
-        *      @todo - look up server && packet type
+        *      Look up server and packet type.
+        *
+        *      memcpy for const issues... we know what we're doing.
         */
+       memcpy(&server, &g->vpt->tmpl_value.datum.strvalue, sizeof(server));
+       packet = strchr(server, '.');
+       if (!packet) {
+               cf_log_err(cs, "Invalid syntax: expected server.PACKET");
+               talloc_free(g);
+               return NULL;
+       }
+
+       *packet = '\0';         /* hack */
+       root = cf_root(cs);
+       server_cs = cf_section_find(root, "server", server);
+       if (!server_cs) {
+               cf_log_err(cs, "Unknown virtual server '%s'", server);
+               talloc_free(g);
+               return NULL;
+       }
+
+       *packet = '.';
+       packet++;
+
+       /*
+        *      Verify it exists, but don't bother caching it.  We can
+        *      figure it out at run-time.
+        */
+       g->process = cf_data_find(server_cs, fr_io_process_t, packet);
+       if (!g->process) {
+               cf_log_err(cs, "Virtual server %s cannot process '%s' packets",
+                          cf_section_name2(server_cs), packet);
+               talloc_free(g);
+               return NULL;
+       }
 
        c = unlang_group_to_generic(g);
        c->name = unlang_ops[c->type].name;