Navigation



Ignore:
Timestamp:
Apr 16, 2010, 4:57:39 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Ported the auth plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_radgw/rgw_plugins.c

    r255 r256  
    5454        unsigned char           *cc;            /* array of command codes, or NULL for all cc */
    5555        size_t                   cc_len;        /* size of the previous array */
    56        
    57         char                    *plgname;       /* basename of the plugin, for debug messages. To be freed when object is detroyed */
    58         char                    *conffile;      /* configuration file passed to the extension, or "(null)". To be freed when object is destroyed */
    5956};
    6057
     
    177174        struct plg_descr * new;
    178175        int ret = 0;
    179         char * tmp;
    180176       
    181177        TRACE_ENTRY("%p %p %d %p %zi", plgfile, conffile, type, codes_array, codes_sz);
    182178       
    183179        CHECK_PARAMS( plgfile && type && codes_array && (cache_started == 0) );
    184        
    185         CHECK_MALLOC( tmp = strdup(plgfile) );
    186180       
    187181        CHECK_MALLOC( new = malloc(sizeof(struct plg_descr)) );
     
    189183       
    190184        fd_list_init(&new->chain, new);
    191        
    192         /* Copy names, for debug */
    193         CHECK_MALLOC( new->plgname = strdup(basename(tmp)) ); /* basename is a stupid function :( */
    194         free(tmp);
    195         CHECK_MALLOC( new->conffile = conffile ?: strdup("(null)") );
    196185       
    197186        /* Try and load the plugin */
     
    212201        }
    213202       
    214         /* Now parse the configuration file, this will initialize all extension states and store it in the returned pointer (the subextensions must be re-entrant) */
     203        TRACE_DEBUG(FULL, "Plugin '%s' found in file '%s'", new->descriptor->rgwp_name, plgfile);
     204       
     205        /* Now parse the configuration file, this will initialize all plugin states and store it in the "cs" pointer (the plugin must be re-entrant, so no global state) */
    215206        if (new->descriptor->rgwp_conf_parse) {
    216                 TRACE_DEBUG(FULL, "Parsing plugin conf file: %s", new->conffile );
    217                 new->cs = (*(new->descriptor->rgwp_conf_parse))(conffile);
    218                 if (new->cs == NULL) {
    219                         fd_log_debug("An error occurred while parsing configuration file '%s' in plugin '%s', aborting...\n", new->conffile, new->plgname);
    220                         goto error;
    221                 }
    222                 TRACE_DEBUG(INFO, "RADIUS/Diameter gateway plugin '%s%s%s%s' initialized.", new->plgname, conffile ? " (" : "",  conffile ? new->conffile : "", conffile ? ")" : "");
     207                CHECK_FCT_DO( (*(new->descriptor->rgwp_conf_parse))(conffile, &new->cs),
     208                        {
     209                                fd_log_debug("An error occurred while parsing configuration file '%s' in plugin '%s', aborting...\n", conffile, plgfile);
     210                                goto error;
     211                        } );
    223212        }
    224213       
     
    283272                plg = (struct plg_descr *)ptr;
    284273               
    285                 fd_log_debug("  %-25s ( %-25s ) - types: %s%s, codes: ",
    286                                 plg->plgname,
    287                                 basename(plg->conffile),
     274                fd_log_debug("  %-25s ( %p ) - types: %s%s, codes: ",
     275                                plg->descriptor->rgwp_name,
     276                                plg->cs,
    288277                                plg->type & RGW_PLG_TYPE_AUTH ? "Au" : "  ",
    289278                                plg->type & RGW_PLG_TYPE_ACCT ? "Ac" : "  ");
     
    317306                for (ptr = accel->plugins.next; ptr != &accel->plugins; ptr = ptr->next) {
    318307                        struct plg_accel_item * item = (struct plg_accel_item *)ptr;
    319                         fd_log_debug("     %-15s (%s)\n", item->plg->plgname, basename(item->plg->conffile));
     308                        fd_log_debug("     %-15s (%p)\n", item->plg->descriptor->rgwp_name, item->plg->cs);
    320309                }
    321310        }
     
    326315                for (ptr = accel->plugins.next; ptr != &accel->plugins; ptr = ptr->next) {
    327316                        struct plg_accel_item * item = (struct plg_accel_item *)ptr;
    328                         fd_log_debug("     %-15s (%s)\n", item->plg->plgname, basename(item->plg->conffile));
     317                        fd_log_debug("     %-15s (%p)\n", item->plg->descriptor->rgwp_name, item->plg->cs);
    329318                }
    330319        }
     
    359348               
    360349                if (plg->descriptor->rgwp_rad_req) {
    361                         TRACE_DEBUG(ANNOYING, "Calling next plugin: %s", plg->plgname);
     350                        TRACE_DEBUG(ANNOYING, "Calling next plugin: %s", plg->descriptor->rgwp_name);
    362351                        ret = (*plg->descriptor->rgwp_rad_req)(plg->cs, *session, &(*rad)->radius, &rad_ans, diam_msg, cli);
    363352                        if (ret)
    364353                                break;
    365354                } else {
    366                         TRACE_DEBUG(ANNOYING, "Skipping extension '%s' (NULL callback)", plg->plgname);
     355                        TRACE_DEBUG(ANNOYING, "Skipping extension '%s' (NULL callback)", plg->descriptor->rgwp_name);
    367356                }                                       
    368357        }
     
    420409               
    421410                if (plg->descriptor->rgwp_diam_ans) {
    422                         TRACE_DEBUG(ANNOYING, "Calling next plugin: %s", plg->plgname);
     411                        TRACE_DEBUG(ANNOYING, "Calling next plugin: %s", plg->descriptor->rgwp_name);
    423412                        ret = (*plg->descriptor->rgwp_diam_ans)(plg->cs, session, diam_ans, rad_ans, (void *)cli);
    424413                        if (ret)
    425414                                break;
    426415                } else {
    427                         TRACE_DEBUG(ANNOYING, "Skipping extension '%s' (NULL callback)", plg->plgname);
     416                        TRACE_DEBUG(ANNOYING, "Skipping extension '%s' (NULL callback)", plg->descriptor->rgwp_name);
    428417                }                                       
    429418        }
     
    493482                struct plg_descr * plg = (struct plg_descr *) plg_list.next;
    494483                fd_list_unlink(&plg->chain);
    495                 free(plg->conffile);
    496484                free(plg->cc);
    497                 if (plg->cs && plg->descriptor && plg->descriptor->rgwp_conf_free ) {
    498                         TRACE_DEBUG(INFO, "RADIUS/Diameter gateway plugin '%s' cleaning up...", plg->plgname);
     485                if (plg->descriptor && plg->descriptor->rgwp_conf_free ) {
     486                        TRACE_DEBUG(INFO, "RADIUS/Diameter gateway plugin '%s' cleaning up...", plg->descriptor->rgwp_name);
    499487                        (*plg->descriptor->rgwp_conf_free)(plg->cs);
    500488                }
    501                 free(plg->plgname);
    502                 dlclose(plg->dlo);
     489                if (plg->dlo)
     490                        dlclose(plg->dlo);
    503491                free(plg);
    504492        }
Note: See TracChangeset for help on using the changeset viewer.