From c2d2a0f19ef8d2f9145608643103475af8ec61b2 Mon Sep 17 00:00:00 2001 From: aland Date: Mon, 2 Jul 2007 22:08:39 +0000 Subject: [PATCH] Copy inst->xlat_name from module name Set xlat name to inst->xlat_name, and don't set it for "mschap". If the user doesn't configure "mschap", then lots of other things will break. Don't free inst->xlat_name, as we're no longer strdup'ing it. --- src/modules/rlm_mschap/rlm_mschap.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/modules/rlm_mschap/rlm_mschap.c b/src/modules/rlm_mschap/rlm_mschap.c index a3232ad..bdb09c3 100644 --- a/src/modules/rlm_mschap/rlm_mschap.c +++ b/src/modules/rlm_mschap/rlm_mschap.c @@ -617,7 +617,6 @@ static int mschap_detach(void *instance){ #define inst ((rlm_mschap_t *)instance) if (inst->xlat_name) { xlat_unregister(inst->xlat_name, mschap_xlat); - free(inst->xlat_name); } free(instance); return 0; @@ -630,7 +629,6 @@ static int mschap_detach(void *instance){ */ static int mschap_instantiate(CONF_SECTION *conf, void **instance) { - const char *xlat_name; rlm_mschap_t *inst; inst = *instance = rad_malloc(sizeof(*inst)); @@ -659,21 +657,17 @@ static int mschap_instantiate(CONF_SECTION *conf, void **instance) /* * Create the dynamic translation. */ - if (cf_section_name1(conf)) - xlat_register(cf_section_name1(conf),mschap_xlat, inst); - - if ((xlat_name = cf_section_name2(conf)) != NULL) - xlat_register(xlat_name, mschap_xlat, inst); - if (xlat_name == NULL) - xlat_name = cf_section_name1(conf); - if (xlat_name) - inst->xlat_name = strdup(xlat_name); + inst->xlat_name = cf_section_name2(conf); + if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf); + xlat_register(inst->xlat_name, mschap_xlat, inst); /* * For backwards compatibility */ if (!dict_valbyname(PW_AUTH_TYPE, inst->xlat_name)) { inst->auth_type = "MS-CHAP"; + } else { + inst->auth_type = inst->xlat_name; } return 0; -- 2.1.4