2 * modules.c Radius module support.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * Copyright 2003,2006 The FreeRADIUS server project
21 * Copyright 2000 Alan DeKok <aland@ox.org>
22 * Copyright 2000 Alan Curry <pacman@world.std.com>
25 #include <freeradius-devel/ident.h>
28 #include <freeradius-devel/radiusd.h>
29 #include <freeradius-devel/modpriv.h>
30 #include <freeradius-devel/modcall.h>
31 #include <freeradius-devel/rad_assert.h>
33 extern int check_config;
35 typedef struct indexed_modcallable {
39 modcallable *modulelist;
40 } indexed_modcallable;
43 * For each component, keep an ordered list of ones to call.
45 static rbtree_t *components = NULL;
47 static rbtree_t *module_tree = NULL;
49 static rbtree_t *instance_tree = NULL;
51 typedef struct section_type_value_t {
55 } section_type_value_t;
57 struct fr_module_hup_t {
58 module_instance_t *mi;
61 fr_module_hup_t *next;
66 * Ordered by component
68 static const section_type_value_t section_type_value[RLM_COMPONENT_COUNT] = {
69 { "authenticate", "Auth-Type", PW_AUTH_TYPE },
70 { "authorize", "Autz-Type", PW_AUTZ_TYPE },
71 { "preacct", "Pre-Acct-Type", PW_PRE_ACCT_TYPE },
72 { "accounting", "Acct-Type", PW_ACCT_TYPE },
73 { "session", "Session-Type", PW_SESSION_TYPE },
74 { "pre-proxy", "Pre-Proxy-Type", PW_PRE_PROXY_TYPE },
75 { "post-proxy", "Post-Proxy-Type", PW_POST_PROXY_TYPE },
76 { "post-auth", "Post-Auth-Type", PW_POST_AUTH_TYPE },
80 #ifdef WITHOUT_LIBLTDL
81 typedef struct lt_dlmodule_t {
87 * Define modules here.
89 extern module_t rlm_pap;
90 extern module_t rlm_chap;
91 extern module_t rlm_eap;
94 * EAP structures are defined elsewhere.
96 typedef struct eap_type_t EAP_TYPE;
99 * And so on for other EAP types.
101 extern EAP_TYPE rlm_eap_md5;
103 static const lt_dlmodule_t lt_dlmodules[] = {
104 { "rlm_pap", &rlm_pap },
105 { "rlm_chap", &rlm_chap },
106 { "rlm_eap", &rlm_eap },
107 { "rlm_eap_md5", &rlm_eap_md5 },
110 * Add other modules here.
117 lt_dlhandle lt_dlopenext(const char *name)
121 for (i = 0; lt_dlmodules[i].name != NULL; i++) {
122 if (strcmp(name, lt_dlmodules[i].name) == 0) {
123 return lt_dlmodules[i].ref;
130 void *lt_dlsym(lt_dlhandle handle, UNUSED const char *symbol)
134 #endif /* WITHOUT_LIBLTDL */
137 static void indexed_modcallable_free(void *data)
139 indexed_modcallable *c = data;
141 modcallable_free(&c->modulelist);
145 static int indexed_modcallable_cmp(const void *one, const void *two)
148 const indexed_modcallable *a = one;
149 const indexed_modcallable *b = two;
151 if (a->server && !b->server) return -1;
152 if (!a->server && b->server) return +1;
153 if (a->server && b->server) {
154 rcode = strcmp(a->server, b->server);
155 if (rcode != 0) return rcode;
158 if (a->comp < b->comp) return -1;
159 if (a->comp > b->comp) return +1;
161 return a->idx - b->idx;
166 * Compare two module entries
168 static int module_instance_cmp(const void *one, const void *two)
170 const module_instance_t *a = one;
171 const module_instance_t *b = two;
173 return strcmp(a->name, b->name);
177 static void module_instance_free_old(CONF_SECTION *cs, module_instance_t *node,
180 fr_module_hup_t *mh, **last;
183 * Walk the list, freeing up old instances.
190 * Free only every 60 seconds.
192 if ((when - mh->when) < 60) {
197 cf_section_parse_free(cs, mh->insthandle);
199 if (node->entry->module->detach) {
200 (node->entry->module->detach)(mh->insthandle);
202 free(mh->insthandle);
212 * Free a module instance.
214 static void module_instance_free(void *data)
216 module_instance_t *this = data;
218 module_instance_free_old(this->cs, this, time(NULL) + 100);
220 if (this->entry->module->detach) {
221 (this->entry->module->detach)(this->insthandle);
224 #ifdef HAVE_PTHREAD_H
228 * The mutex MIGHT be locked...
229 * we'll check for that later, I guess.
231 pthread_mutex_destroy(this->mutex);
235 memset(this, 0, sizeof(*this));
241 * Compare two module entries
243 static int module_entry_cmp(const void *one, const void *two)
245 const module_entry_t *a = one;
246 const module_entry_t *b = two;
248 return strcmp(a->name, b->name);
252 * Free a module entry.
254 static void module_entry_free(void *data)
256 module_entry_t *this = data;
258 lt_dlclose(this->handle); /* ignore any errors */
259 memset(this, 0, sizeof(*this));
265 * Remove the module lists.
267 int detach_modules(void)
269 rbtree_free(instance_tree);
270 rbtree_free(components);
271 rbtree_free(module_tree);
280 * Find a module on disk or in memory, and link to it.
282 static module_entry_t *linkto_module(const char *module_name,
285 module_entry_t myentry;
286 module_entry_t *node;
288 char module_struct[256];
290 const module_t *module;
292 strlcpy(myentry.name, module_name, sizeof(myentry.name));
293 node = rbtree_finddata(module_tree, &myentry);
294 if (node) return node;
297 * Keep the handle around so we can dlclose() it.
299 handle = lt_dlopenext(module_name);
300 if (handle == NULL) {
301 cf_log_err(cf_sectiontoitem(cs),
302 "Failed to link to module '%s': %s\n",
303 module_name, lt_dlerror());
308 * Link to the module's rlm_FOO{} module structure.
310 * The module_name variable has the version number
311 * embedded in it, and we don't want that here.
313 strcpy(module_struct, module_name);
314 p = strrchr(module_struct, '-');
317 DEBUG3(" (Loaded %s, checking if it's valid)", module_name);
320 * libltld MAY core here, if the handle it gives us contains
323 module = lt_dlsym(handle, module_struct);
325 cf_log_err(cf_sectiontoitem(cs),
326 "Failed linking to %s structure: %s\n",
327 module_name, lt_dlerror());
332 * Before doing anything else, check if it's sane.
334 if (module->magic != RLM_MODULE_MAGIC_NUMBER) {
336 cf_log_err(cf_sectiontoitem(cs),
337 "Invalid version in module '%s'",
343 /* make room for the module type */
344 node = rad_malloc(sizeof(*node));
345 memset(node, 0, sizeof(*node));
346 strlcpy(node->name, module_name, sizeof(node->name));
347 node->module = module;
348 node->handle = handle;
350 cf_log_module(cs, "Linked to module %s", module_name);
353 * Add the module as "rlm_foo-version" to the configuration
356 if (!rbtree_insert(module_tree, node)) {
357 radlog(L_ERR, "Failed to cache module %s", module_name);
367 * Find a module instance.
369 module_instance_t *find_module_instance(CONF_SECTION *modules,
370 const char *instname, int do_link)
373 const char *name1, *name2;
374 module_instance_t *node, myNode;
375 char module_name[256];
377 if (!modules) return NULL;
380 * Module instances are declared in the modules{} block
381 * and referenced later by their name, which is the
382 * name2 from the config section, or name1 if there was
385 cs = cf_section_sub_find_name2(modules, NULL, instname);
387 radlog(L_ERR, "ERROR: Cannot find a configuration entry for module \"%s\".\n", instname);
392 * If there's already a module instance, return it.
394 strlcpy(myNode.name, instname, sizeof(myNode.name));
395 node = rbtree_finddata(instance_tree, &myNode);
396 if (node) return node;
398 if (!do_link) return NULL;
400 name1 = cf_section_name1(cs);
401 name2 = cf_section_name2(cs);
404 * Found the configuration entry.
406 node = rad_malloc(sizeof(*node));
407 memset(node, 0, sizeof(*node));
409 node->insthandle = NULL;
413 * Names in the "modules" section aren't prefixed
414 * with "rlm_", so we add it here.
416 snprintf(module_name, sizeof(module_name), "rlm_%s", name1);
418 node->entry = linkto_module(module_name, cs);
421 /* linkto_module logs any errors */
425 if (check_config && (node->entry->module->instantiate) &&
426 (node->entry->module->type & RLM_TYPE_CHECK_CONFIG_SAFE) == 0) {
427 cf_log_module(cs, "Skipping instantiation of %s", instname);
429 cf_log_module(cs, "Instantiating %s", instname);
433 * Call the module's instantiation routine.
435 if ((node->entry->module->instantiate) &&
437 ((node->entry->module->type & RLM_TYPE_CHECK_CONFIG_SAFE) != 0)) &&
438 ((node->entry->module->instantiate)(cs, &node->insthandle) < 0)) {
439 cf_log_err(cf_sectiontoitem(cs),
440 "Instantiation failed for module \"%s\"",
447 * We're done. Fill in the rest of the data structure,
448 * and link it to the module instance list.
450 strlcpy(node->name, instname, sizeof(node->name));
452 #ifdef HAVE_PTHREAD_H
454 * If we're threaded, check if the module is thread-safe.
456 * If it isn't, we create a mutex.
458 if ((node->entry->module->type & RLM_TYPE_THREAD_UNSAFE) != 0) {
459 node->mutex = (pthread_mutex_t *) rad_malloc(sizeof(pthread_mutex_t));
461 * Initialize the mutex.
463 pthread_mutex_init(node->mutex, NULL);
466 * The module is thread-safe. Don't give it a mutex.
472 rbtree_insert(instance_tree, node);
477 static indexed_modcallable *lookup_by_index(const char *server, int comp,
480 indexed_modcallable myc;
486 return rbtree_finddata(components, &myc);
490 * Create a new sublist.
492 static indexed_modcallable *new_sublist(const char *server, int comp, int idx)
494 indexed_modcallable *c;
496 c = lookup_by_index(server, comp, idx);
498 /* It is an error to try to create a sublist that already
499 * exists. It would almost certainly be caused by accidental
500 * duplication in the config file.
502 * index 0 is the exception, because it is used when we want
503 * to collect _all_ listed modules under a single index by
504 * default, which is currently the case in all components
505 * except authenticate. */
513 c = rad_malloc(sizeof(*c));
514 c->modulelist = NULL;
519 if (!rbtree_insert(components, c)) {
527 int indexed_modcall(int comp, int idx, REQUEST *request)
530 indexed_modcallable *this;
531 modcallable *list = NULL;
533 this = lookup_by_index(request->server, comp, idx);
535 if (idx != 0) DEBUG2(" WARNING: Unknown value specified for %s. Cannot perform requested action.",
536 section_type_value[comp].typename);
538 list = this->modulelist;
541 request->component = section_type_value[comp].section;
543 rcode = modcall(comp, list, request);
545 request->module = "";
546 request->component = "";
551 * Load a sub-module list, as found inside an Auth-Type foo {}
554 static int load_subcomponent_section(modcallable *parent, CONF_SECTION *cs,
555 const char *server, int attr, int comp)
557 indexed_modcallable *subcomp;
560 const char *name2 = cf_section_name2(cs);
562 rad_assert(comp >= RLM_COMPONENT_AUTH);
563 rad_assert(comp < RLM_COMPONENT_COUNT);
569 cf_log_err(cf_sectiontoitem(cs),
570 "No name specified for %s block",
571 section_type_value[comp].typename);
578 ml = compile_modgroup(parent, comp, cs);
584 * We must assign a numeric index to this subcomponent.
585 * It is generated and placed in the dictionary
586 * automatically. If it isn't found, it's a serious
589 dval = dict_valbyname(attr, name2);
591 cf_log_err(cf_sectiontoitem(cs),
592 "%s %s Not previously configured",
593 section_type_value[comp].typename, name2);
594 modcallable_free(&ml);
598 subcomp = new_sublist(server, comp, dval->value);
600 modcallable_free(&ml);
604 subcomp->modulelist = ml;
608 static int define_type(const DICT_ATTR *dattr, const char *name)
614 * If the value already exists, don't
617 dval = dict_valbyname(dattr->attr, name);
621 * Create a new unique value with a
622 * meaningless number. You can't look at
623 * it from outside of this code, so it
624 * doesn't matter. The only requirement
625 * is that it's unique.
628 value = fr_rand() & 0x00ffffff;
629 } while (dict_valbyattr(dattr->attr, value));
631 if (dict_addvalue(name, dattr->name, value) < 0) {
632 radlog(L_ERR, "%s", fr_strerror());
639 static int load_component_section(CONF_SECTION *cs,
640 const char *server, int comp)
645 indexed_modcallable *subcomp;
647 const char *visiblename;
648 const DICT_ATTR *dattr;
651 * Find the attribute used to store VALUEs for this section.
653 dattr = dict_attrbyvalue(section_type_value[comp].attr);
655 cf_log_err(cf_sectiontoitem(cs),
656 "No such attribute %s",
657 section_type_value[comp].typename);
662 * Loop over the entries in the named section, loading
663 * the sections this time.
665 for (modref = cf_item_find_next(cs, NULL);
667 modref = cf_item_find_next(cs, modref)) {
669 CONF_PAIR *cp = NULL;
670 CONF_SECTION *scs = NULL;
672 if (cf_item_is_section(modref)) {
673 scs = cf_itemtosection(modref);
675 name1 = cf_section_name1(scs);
678 section_type_value[comp].typename) == 0) {
679 if (!load_subcomponent_section(NULL, scs,
683 return -1; /* FIXME: memleak? */
690 } else if (cf_item_is_pair(modref)) {
691 cp = cf_itemtopair(modref);
694 continue; /* ignore it */
698 * Try to compile one entry.
700 this = compile_modsingle(NULL, comp, modref, &modname);
702 cf_log_err(cf_sectiontoitem(cs),
703 "Errors parsing %s section.\n",
704 cf_section_name1(cs));
709 * Look for Auth-Type foo {}, which are special
710 * cases of named sections, and allowable ONLY
713 * i.e. They're not allowed in a "group" or "redundant"
716 if (comp == RLM_COMPONENT_AUTH) {
718 const char *modrefname = NULL;
720 modrefname = cf_pair_attr(cp);
722 modrefname = cf_section_name2(scs);
724 modcallable_free(&this);
725 cf_log_err(cf_sectiontoitem(cs),
726 "Errors parsing %s sub-section.\n",
727 cf_section_name1(scs));
732 dval = dict_valbyname(PW_AUTH_TYPE, modrefname);
735 * It's a section, but nothing we
738 modcallable_free(&this);
739 cf_log_err(cf_sectiontoitem(cs),
740 "Unknown Auth-Type \"%s\" in %s sub-section.",
741 modrefname, section_type_value[comp].section);
746 /* See the comment in new_sublist() for explanation
747 * of the special index 0 */
751 subcomp = new_sublist(server, comp, idx);
752 if (subcomp == NULL) {
753 modcallable_free(&this);
757 /* If subcomp->modulelist is NULL, add_to_modcallable will
759 visiblename = cf_section_name2(cs);
760 if (visiblename == NULL)
761 visiblename = cf_section_name1(cs);
762 add_to_modcallable(&subcomp->modulelist, this,
769 static int load_byserver(CONF_SECTION *cs)
772 const char *server = cf_section_name2(cs);
774 cf_log_info(cs, " modules {");
777 * Define types first.
779 for (comp = 0; comp < RLM_COMPONENT_COUNT; ++comp) {
784 subcs = cf_section_sub_find(cs,
785 section_type_value[comp].section);
786 if (!subcs) continue;
788 if (cf_item_find_next(subcs, NULL) == NULL) continue;
791 * Find the attribute used to store VALUEs for this section.
793 dattr = dict_attrbyvalue(section_type_value[comp].attr);
795 cf_log_err(cf_sectiontoitem(subcs),
796 "No such attribute %s",
797 section_type_value[comp].typename);
798 cf_log_info(cs, " }");
803 * Define dynamic types, so that others can reference
806 for (modref = cf_item_find_next(subcs, NULL);
808 modref = cf_item_find_next(subcs, modref)) {
810 CONF_SECTION *subsubcs;
813 * Create types for simple references
814 * only when parsing the authenticate
817 if ((section_type_value[comp].attr == PW_AUTH_TYPE) &&
818 cf_item_is_pair(modref)) {
819 CONF_PAIR *cp = cf_itemtopair(modref);
820 if (!define_type(dattr, cf_pair_attr(cp))) {
827 if (!cf_item_is_section(modref)) continue;
829 subsubcs = cf_itemtosection(modref);
830 name1 = cf_section_name1(subsubcs);
832 if (strcmp(name1, section_type_value[comp].typename) == 0) {
833 if (!define_type(dattr,
834 cf_section_name2(subsubcs))) {
835 cf_log_info(cs, " }");
840 } /* loop over components */
843 * Loop over all of the known components, finding their
844 * configuration section, and loading it.
847 for (comp = 0; comp < RLM_COMPONENT_COUNT; ++comp) {
850 subcs = cf_section_sub_find(cs,
851 section_type_value[comp].section);
852 if (!subcs) continue;
854 if (cf_item_find_next(subcs, NULL) == NULL) continue;
856 cf_log_module(cs, "Checking %s {...} for more modules to load",
857 section_type_value[comp].section);
859 if (load_component_section(subcs, server, comp) < 0) {
860 cf_log_info(cs, " }");
864 } /* loop over components */
867 * We haven't loaded any of the normal sections. Maybe we're
868 * supposed to load the vmps section.
870 * This is a bit of a hack...
875 subcs = cf_section_sub_find(cs, "vmps");
877 cf_log_module(cs, "Checking vmps {...} for more modules to load");
878 if (load_component_section(subcs, server,
879 RLM_COMPONENT_POST_AUTH) < 0) {
887 const DICT_ATTR *dattr;
889 dattr = dict_attrbyname("DHCP-Message-Type");
891 radlog(L_ERR, "No DHCP-Message-Type attribute");
896 * Handle each DHCP Message type separately.
898 for (subcs = cf_subsection_find_next(cs, NULL,
901 subcs = cf_subsection_find_next(cs, subcs,
903 const char *name2 = cf_section_name2(subcs);
905 DEBUG2(" Module: Checking dhcp %s {...} for more modules to load", name2);
906 if (!load_subcomponent_section(NULL, subcs,
909 RLM_COMPONENT_POST_AUTH)) {
910 return -1; /* FIXME: memleak? */
918 cf_log_info(cs, " }");
920 if (!flag && server) {
921 DEBUG("WARNING: Server %s is empty, and will do nothing!",
929 int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when)
931 void *insthandle = NULL;
935 !node->entry->module->instantiate ||
936 ((node->entry->module->type & RLM_TYPE_HUP_SAFE) == 0)) {
940 cf_log_module(cs, "Trying to reload module \"%s\"", node->name);
942 if ((node->entry->module->instantiate)(cs, &insthandle) < 0) {
943 cf_log_err(cf_sectiontoitem(cs),
944 "HUP failed for module \"%s\". Using old configuration.",
949 radlog(L_INFO, " Module: Reloaded module \"%s\"", node->name);
951 module_instance_free_old(cs, node, when);
954 * Save the old instance handle for later deletion.
956 mh = rad_malloc(sizeof(*mh));
959 mh->insthandle = node->insthandle;
963 node->insthandle = insthandle;
966 * FIXME: Set a timeout to come back in 60s, so that
967 * we can pro-actively clean up the old instances.
974 int module_hup(CONF_SECTION *modules)
979 module_instance_t *node;
981 if (!modules) return 0;
986 * Loop over the modules
988 for (ci=cf_item_find_next(modules, NULL);
990 ci=cf_item_find_next(modules, ci)) {
991 const char *instname;
992 module_instance_t myNode;
995 * If it's not a section, ignore it.
997 if (!cf_item_is_section(ci)) continue;
999 cs = cf_itemtosection(ci);
1000 instname = cf_section_name2(cs);
1001 if (!instname) instname = cf_section_name1(cs);
1003 strlcpy(myNode.name, instname, sizeof(myNode.name));
1004 node = rbtree_finddata(instance_tree, &myNode);
1006 module_hup_module(cs, node, when);
1014 * Parse the module config sections, and load
1015 * and call each module's init() function.
1017 * Libtool makes your life a LOT easier, especially with libltdl.
1018 * see: http://www.gnu.org/software/libtool/
1020 int setup_modules(int reload, CONF_SECTION *config)
1022 CONF_SECTION *cs, *modules;
1023 rad_listen_t *listener;
1024 int null_server = FALSE;
1026 if (reload) return 0;
1029 * If necessary, initialize libltdl.
1033 * Set the default list of preloaded symbols.
1034 * This is used to initialize libltdl's list of
1035 * preloaded modules.
1037 * i.e. Static modules.
1039 LTDL_SET_PRELOADED_SYMBOLS();
1041 if (lt_dlinit() != 0) {
1042 radlog(L_ERR, "Failed to initialize libraries: %s\n",
1048 * Set the search path to ONLY our library directory.
1049 * This prevents the modules from being found from
1050 * any location on the disk.
1052 lt_dlsetsearchpath(radlib_dir);
1055 * Set up the internal module struct.
1057 module_tree = rbtree_create(module_entry_cmp,
1058 module_entry_free, 0);
1060 radlog(L_ERR, "Failed to initialize modules\n");
1064 instance_tree = rbtree_create(module_instance_cmp,
1065 module_instance_free, 0);
1066 if (!instance_tree) {
1067 radlog(L_ERR, "Failed to initialize modules\n");
1072 components = rbtree_create(indexed_modcallable_cmp,
1073 indexed_modcallable_free, 0);
1075 radlog(L_ERR, "Failed to initialize components\n");
1080 * Remember where the modules were stored.
1082 modules = cf_section_sub_find(config, "modules");
1084 radlog(L_ERR, "Cannot find a \"modules\" section in the configuration file!");
1088 DEBUG2("%s: #### Instantiating modules ####", mainconfig.name);
1091 * Look for the 'instantiate' section, which tells us
1092 * the instantiation order of the modules, and also allows
1093 * us to load modules with no authorize/authenticate/etc.
1096 cs = cf_section_sub_find(config, "instantiate");
1100 module_instance_t *module;
1103 cf_log_info(cs, " instantiate {");
1106 * Loop over the items in the 'instantiate' section.
1108 for (ci=cf_item_find_next(cs, NULL);
1110 ci=cf_item_find_next(cs, ci)) {
1113 * Skip sections and "other" stuff.
1114 * Sections will be handled later, if
1115 * they're referenced at all...
1117 if (!cf_item_is_pair(ci)) {
1121 cp = cf_itemtopair(ci);
1122 name = cf_pair_attr(cp);
1123 module = find_module_instance(modules, name, 1);
1127 } /* loop over items in the subsection */
1129 cf_log_info(cs, " }");
1130 } /* if there's an 'instantiate' section. */
1133 * Loop over the listeners, figuring out which sections
1136 for (listener = mainconfig.listen;
1138 listener = listener->next) {
1141 if (listener->type == RAD_LISTEN_PROXY) continue;
1143 cs = cf_section_sub_find_name2(config,
1144 "server", listener->server);
1145 if (!cs && (listener->server != NULL)) {
1146 listener->print(listener, buffer, sizeof(buffer));
1148 radlog(L_ERR, "No server has been defined for %s", buffer);
1153 DEBUG2("%s: #### Loading Virtual Servers ####", mainconfig.name);
1156 * Load all of the virtual servers.
1158 for (cs = cf_subsection_find_next(config, NULL, "server");
1160 cs = cf_subsection_find_next(config, cs, "server")) {
1161 const char *name2 = cf_section_name2(cs);
1164 cf_log_info(cs, "server %s {", name2);
1166 cf_log_info(cs, "server {");
1169 if (load_byserver(cs) < 0) {
1170 cf_log_info(cs, "}");
1173 cf_log_info(cs, "}");
1177 * No empty server defined. Try to load an old-style
1178 * one for backwards compatibility.
1181 cf_log_info(cs, "server {");
1182 if (load_byserver(config) < 0) {
1183 cf_log_info(cs, "}");
1186 cf_log_info(cs, "}");
1193 * Call all authorization modules until one returns
1194 * somethings else than RLM_MODULE_OK
1196 int module_authorize(int autz_type, REQUEST *request)
1198 return indexed_modcall(RLM_COMPONENT_AUTZ, autz_type, request);
1202 * Authenticate a user/password with various methods.
1204 int module_authenticate(int auth_type, REQUEST *request)
1206 return indexed_modcall(RLM_COMPONENT_AUTH, auth_type, request);
1209 #ifdef WITH_ACCOUNTING
1211 * Do pre-accounting for ALL configured sessions
1213 int module_preacct(REQUEST *request)
1215 return indexed_modcall(RLM_COMPONENT_PREACCT, 0, request);
1219 * Do accounting for ALL configured sessions
1221 int module_accounting(int acct_type, REQUEST *request)
1223 return indexed_modcall(RLM_COMPONENT_ACCT, acct_type, request);
1227 #ifdef WITH_SESSION_MGMT
1229 * See if a user is already logged in.
1231 * Returns: 0 == OK, 1 == double logins, 2 == multilink attempt
1233 int module_checksimul(int sess_type, REQUEST *request, int maxsimul)
1237 if(!request->username)
1240 request->simul_count = 0;
1241 request->simul_max = maxsimul;
1242 request->simul_mpp = 1;
1244 rcode = indexed_modcall(RLM_COMPONENT_SESS, sess_type, request);
1246 if (rcode != RLM_MODULE_OK) {
1247 /* FIXME: Good spot for a *rate-limited* warning to the log */
1251 return (request->simul_count < maxsimul) ? 0 : request->simul_mpp;
1257 * Do pre-proxying for ALL configured sessions
1259 int module_pre_proxy(int type, REQUEST *request)
1261 return indexed_modcall(RLM_COMPONENT_PRE_PROXY, type, request);
1265 * Do post-proxying for ALL configured sessions
1267 int module_post_proxy(int type, REQUEST *request)
1269 return indexed_modcall(RLM_COMPONENT_POST_PROXY, type, request);
1274 * Do post-authentication for ALL configured sessions
1276 int module_post_auth(int postauth_type, REQUEST *request)
1278 return indexed_modcall(RLM_COMPONENT_POST_AUTH, postauth_type, request);