2
2
* modules.c Radius module support.
4
* Version: $Id: modules.c,v 1.86 2004/04/23 19:50:29 aland Exp $
4
* Version: $Id: modules.c,v 1.86.2.1.2.4 2006/04/07 17:53:25 aland Exp $
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
22
22
* Copyright 2000 Alan Curry <pacman@world.std.com>
25
static const char rcsid[] = "$Id: modules.c,v 1.86 2004/04/23 19:50:29 aland Exp $";
25
static const char rcsid[] = "$Id: modules.c,v 1.86.2.1.2.4 2006/04/07 17:53:25 aland Exp $";
27
27
#include "autoconf.h"
28
28
#include "libradius.h"
472
472
/* Load a flat module list, as found inside an authtype{} block */
473
static void load_subcomponent_section(CONF_SECTION *cs, int comp,
473
static int load_subcomponent_section(CONF_SECTION *cs, int comp,
474
474
const char *filename)
481
481
static int meaningless_counter = 1;
483
483
ml = compile_modgroup(comp, cs, filename);
485
488
/* We must assign a numeric index to this subcomponent. For
486
489
* auth, it is generated and placed in the dictionary by
498
501
dval = dict_valbyname(PW_ACCT_TYPE, cf_section_name2(cs));
499
502
} else if (comp == RLM_COMPONENT_SESS) {
500
503
dval = dict_valbyname(PW_SESSION_TYPE, cf_section_name2(cs));
504
} else if (comp == RLM_COMPONENT_PRE_PROXY) {
505
dval = dict_valbyname(PW_PRE_PROXY_TYPE, cf_section_name2(cs));
506
} else if (comp == RLM_COMPONENT_POST_PROXY) {
507
dval = dict_valbyname(PW_POST_PROXY_TYPE, cf_section_name2(cs));
501
508
} else if (comp == RLM_COMPONENT_POST_AUTH) {
502
509
dval = dict_valbyname(PW_POST_AUTH_TYPE, cf_section_name2(cs));
515
522
filename, cf_section_lineno(cs),
516
523
subcomponent_names[comp], cf_section_name2(cs));
517
524
modcallable_free(&ml);
521
528
subcomp->modulelist = ml;
524
533
static int load_component_section(CONF_SECTION *cs, int comp,
534
543
for (modref=cf_item_find_next(cs, NULL);
536
545
modref=cf_item_find_next(cs, modref)) {
546
CONF_PAIR *cp = NULL;
547
CONF_SECTION *scs = NULL;
538
549
if (cf_item_is_section(modref)) {
539
550
const char *sec_name;
541
551
scs = cf_itemtosection(modref);
543
553
sec_name = cf_section_name1(scs);
544
555
if (strcmp(sec_name,
545
556
subcomponent_names[comp]) == 0) {
546
load_subcomponent_section(scs, comp, filename);
557
if (!load_subcomponent_section(scs, comp,
559
return -1; /* FIXME: memleak? */
553
567
if (strcmp(sec_name,
554
568
old_subcomponent_names[comp]) == 0) {
555
load_subcomponent_section(scs, comp, filename);
569
if (!load_subcomponent_section(scs, comp,
571
return -1; /* FIXME: memleak? */
560
577
cp = cf_itemtopair(modref);
564
* FIXME: This calls exit if the reference can't be
565
* found. We should instead print a better error,
566
* and return the failure code up the stack.
568
580
this = compile_modsingle(comp, modref, filename, &modname);
583
"%s[%d] Failed to parse %s section.\n",
584
filename, cf_section_lineno(cs),
585
cf_section_name1(cs));
570
589
if (comp == RLM_COMPONENT_AUTH) {
571
590
DICT_VALUE *dval;
591
const char *modrefname = NULL;
573
dval = dict_valbyname(PW_AUTH_TYPE, modname);
594
modrefname = cf_pair_attr(cp);
596
modrefname = cf_section_name2(scs);
599
"%s[%d] Failed to parse %s sub-section.\n",
600
filename, cf_section_lineno(scs),
601
cf_section_name1(scs));
606
dval = dict_valbyname(PW_AUTH_TYPE, modrefname);
576
609
* It's a section, but nothing we
577
610
* recognize. Die!
579
612
radlog(L_ERR|L_CONS, "%s[%d] Unknown Auth-Type \"%s\" in %s section.",
580
filename, cf_section_lineno(cs),
581
modname, component_names[comp]);
613
filename, cf_section_lineno(scs),
614
modrefname, component_names[comp]);
584
617
idx = dval->value;
940
973
* Do pre-proxying for ALL configured sessions
942
int module_pre_proxy(REQUEST *request)
975
int module_pre_proxy(int type, REQUEST *request)
944
return indexed_modcall(RLM_COMPONENT_PRE_PROXY, 0, request);
977
return indexed_modcall(RLM_COMPONENT_PRE_PROXY, type, request);
948
981
* Do post-proxying for ALL configured sessions
950
int module_post_proxy(REQUEST *request)
983
int module_post_proxy(int type, REQUEST *request)
952
return indexed_modcall(RLM_COMPONENT_POST_PROXY, 0, request);
985
return indexed_modcall(RLM_COMPONENT_POST_PROXY, type, request);