Add support for xlat'd challenge in rlm_eap_gtc
authorAlexander Clouter <alex@digriz.org.uk>
Mon, 8 Nov 2010 18:29:30 +0000 (18:29 +0000)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 10 Nov 2010 16:20:41 +0000 (17:20 +0100)
The FIXME in rlm_eap_gtc.c has gone on so long unloved.  God said, let
there be xlat'ing and so there was...

This patch shamelessly steals the xlat functionality in
rlm_eap_tls.c and slaps it into rlm_eap_gtc.c, thus lettings
you do handy things such as:
----
challenge = "%{reply:Reply-Message}"
----

Signed-off-by: Alexander Clouter <alex@digriz.org.uk>
src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c

index 0972806..60e6eb2 100644 (file)
@@ -110,14 +110,17 @@ static int gtc_attach(CONF_SECTION *cs, void **instance)
  */
 static int gtc_initiate(void *type_data, EAP_HANDLER *handler)
 {
+       char challenge_str[1024];
        int length;
        EAP_DS *eap_ds = handler->eap_ds;
        rlm_eap_gtc_t *inst = (rlm_eap_gtc_t *) type_data;
 
-       /*
-        *      FIXME: call radius_xlat on the challenge
-        */
-       length = strlen(inst->challenge);
+       if (!radius_xlat(challenge_str, sizeof(challenge_str), inst->challenge, handler->request, NULL)) {
+               radlog(L_ERR, "rlm_eap_gtc: xlat failed.", inst->challenge);
+               return 0;
+       }
+
+       length = strlen(challenge_str);
 
        /*
         *      We're sending a request...
@@ -130,7 +133,7 @@ static int gtc_initiate(void *type_data, EAP_HANDLER *handler)
                return 0;
        }
 
-       memcpy(eap_ds->request->type.data, inst->challenge, length);
+       memcpy(eap_ds->request->type.data, challenge_str, length);
        eap_ds->request->type.length = length;
 
        /*