~ubuntu-branches/ubuntu/hardy/freeradius/hardy-proposed

« back to all changes in this revision

Viewing changes to src/main/modules.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2006-12-16 20:45:11 UTC
  • mfrom: (3.1.10 feisty)
  • Revision ID: james.westby@ubuntu.com-20061216204511-3pbbsu4s8jtehsor
Tags: 1.1.3-3
Fix POSIX compliance problem in init script.  Closes: #403384. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * modules.c    Radius module support.
3
3
 *
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 $
5
5
 *
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>
23
23
 */
24
24
 
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 $";
26
26
 
27
27
#include "autoconf.h"
28
28
#include "libradius.h"
470
470
}
471
471
 
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)
475
475
{
476
476
        int idx;
481
481
        static int meaningless_counter = 1;
482
482
 
483
483
        ml = compile_modgroup(comp, cs, filename);
 
484
        if (!ml) {
 
485
                return 0;
 
486
        }
484
487
 
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));
503
510
        }
515
522
                                filename, cf_section_lineno(cs),
516
523
                                subcomponent_names[comp], cf_section_name2(cs));
517
524
                modcallable_free(&ml);
518
 
                return;
 
525
                return 1;
519
526
        }
520
527
 
521
528
        subcomp->modulelist = ml;
 
529
 
 
530
        return 1;
522
531
}
523
532
 
524
533
static int load_component_section(CONF_SECTION *cs, int comp,
534
543
        for (modref=cf_item_find_next(cs, NULL);
535
544
                        modref != NULL;
536
545
                        modref=cf_item_find_next(cs, modref)) {
 
546
                CONF_PAIR *cp = NULL;
 
547
                CONF_SECTION *scs = NULL;
537
548
 
538
549
                if (cf_item_is_section(modref)) {
539
550
                        const char *sec_name;
540
 
                        CONF_SECTION *scs;
541
551
                        scs = cf_itemtosection(modref);
542
552
 
543
553
                        sec_name = cf_section_name1(scs);
 
554
 
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,
 
558
                                                               filename)) {
 
559
                                        return -1; /* FIXME: memleak? */
 
560
                                }
547
561
                                continue;
548
562
                        }
549
563
 
552
566
                         */
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,
 
570
                                                               filename)) {
 
571
                                        return -1; /* FIXME: memleak? */
 
572
                                }
556
573
                                continue;
557
574
                        }
 
575
                        cp = NULL;
558
576
                } else {
559
 
                        CONF_PAIR *cp;
560
577
                        cp = cf_itemtopair(modref);
561
578
                }
562
579
 
563
 
                /*
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.
567
 
                 */
568
580
                this = compile_modsingle(comp, modref, filename, &modname);
 
581
                if (!this) {
 
582
                        radlog(L_ERR|L_CONS,
 
583
                               "%s[%d] Failed to parse %s section.\n",
 
584
                               filename, cf_section_lineno(cs),
 
585
                               cf_section_name1(cs));
 
586
                        return -1;
 
587
                }
569
588
 
570
589
                if (comp == RLM_COMPONENT_AUTH) {
571
590
                        DICT_VALUE *dval;
 
591
                        const char *modrefname = NULL;
572
592
 
573
 
                        dval = dict_valbyname(PW_AUTH_TYPE, modname);
 
593
                        if (cp) {
 
594
                                modrefname = cf_pair_attr(cp);
 
595
                        } else {
 
596
                                modrefname = cf_section_name2(scs);
 
597
                                if (!modrefname) {
 
598
                                        radlog(L_ERR|L_CONS,
 
599
                                               "%s[%d] Failed to parse %s sub-section.\n",
 
600
                                               filename, cf_section_lineno(scs),
 
601
                                               cf_section_name1(scs));
 
602
                                        return -1;
 
603
                                }
 
604
                        }
 
605
                        
 
606
                        dval = dict_valbyname(PW_AUTH_TYPE, modrefname);
574
607
                        if (!dval) {
575
608
                                /*
576
609
                                 *      It's a section, but nothing we
577
610
                                 *      recognize.  Die!
578
611
                                 */
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]);
582
615
                                return -1;
583
616
                        }
584
617
                        idx = dval->value;
939
972
/*
940
973
 *      Do pre-proxying for ALL configured sessions
941
974
 */
942
 
int module_pre_proxy(REQUEST *request)
 
975
int module_pre_proxy(int type, REQUEST *request)
943
976
{
944
 
        return indexed_modcall(RLM_COMPONENT_PRE_PROXY, 0, request);
 
977
        return indexed_modcall(RLM_COMPONENT_PRE_PROXY, type, request);
945
978
}
946
979
 
947
980
/*
948
981
 *      Do post-proxying for ALL configured sessions
949
982
 */
950
 
int module_post_proxy(REQUEST *request)
 
983
int module_post_proxy(int type, REQUEST *request)
951
984
{
952
 
        return indexed_modcall(RLM_COMPONENT_POST_PROXY, 0, request);
 
985
        return indexed_modcall(RLM_COMPONENT_POST_PROXY, type, request);
953
986
}
954
987
 
955
988
/*