From: Alan T. DeKok Date: Thu, 22 Jun 2017 20:05:33 +0000 (-0400) Subject: split into bootstrap / instantiate. And compile "process" sections X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7014a3150cb79f4569a9cc3037bb368d155cea5b;p=thirdparty%2Ffreeradius-server.git split into bootstrap / instantiate. And compile "process" sections --- diff --git a/src/modules/proto_radius/proto_radius_auth.c b/src/modules/proto_radius/proto_radius_auth.c index 9a8ed6c8804..e7509cfa558 100644 --- a/src/modules/proto_radius/proto_radius_auth.c +++ b/src/modules/proto_radius/proto_radius_auth.c @@ -607,7 +607,7 @@ static int auth_listen_compile(CONF_SECTION *server_cs, UNUSED CONF_SECTION *lis return 0; } -static int mod_instantiate(UNUSED void *instance, CONF_SECTION *listen_cs) +static int mod_bootstrap(UNUSED void *instance, CONF_SECTION *listen_cs) { CONF_SECTION *subcs = NULL;; CONF_SECTION *server_cs; @@ -618,8 +618,6 @@ static int mod_instantiate(UNUSED void *instance, CONF_SECTION *listen_cs) server_cs = cf_item_to_section(cf_parent(listen_cs)); rad_assert(strcmp(cf_section_name1(server_cs), "server") == 0); - if (auth_listen_compile(server_cs, listen_cs) < 0) return -1; - da = fr_dict_attr_by_num(NULL, 0, FR_AUTH_TYPE); if (!da) { cf_log_err(server_cs, "Failed finding dictionary definition for Auth-Type"); @@ -664,10 +662,43 @@ static int mod_instantiate(UNUSED void *instance, CONF_SECTION *listen_cs) return 0; } +static int mod_instantiate(UNUSED void *instance, CONF_SECTION *listen_cs) +{ + CONF_SECTION *subcs = NULL;; + CONF_SECTION *server_cs; + + rad_assert(listen_cs); + + server_cs = cf_item_to_section(cf_parent(listen_cs)); + rad_assert(strcmp(cf_section_name1(server_cs), "server") == 0); + + if (auth_listen_compile(server_cs, listen_cs) < 0) return -1; + + while ((subcs = cf_section_find_next(server_cs, subcs, "process", CF_IDENT_ANY))) { + int rcode; + char const *name2; + + name2 = cf_section_name2(subcs); + if (!name2) { + cf_log_err(subcs, "Invalid 'process { ... }' section, it must have a name"); + return -1; + } + + rcode = auth_compile_section(server_cs, "process", name2, MOD_AUTHENTICATE); + if (rcode < 0) { + cf_log_err(subcs, "Failed compiling 'process %s { ... }' section", name2); + return -1; + } + } + + return 0; +} + extern fr_app_process_t proto_radius_auth; fr_app_process_t proto_radius_auth = { .magic = RLM_MODULE_INIT, .name = "radius_auth", + .bootstrap = mod_bootstrap, .instantiate = mod_instantiate, .process = mod_process, };