]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
more cleanups
authorAlan T. DeKok <aland@freeradius.org>
Mon, 22 May 2023 19:50:02 +0000 (15:50 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 22 May 2023 20:25:30 +0000 (16:25 -0400)
src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c

index 971431fef30bb0789e8b302b1cdca446cebd1a45..9ed54510f22d648aaa68de01d6769e09a63848a3 100644 (file)
@@ -780,6 +780,9 @@ static unlang_action_t mod_session_init(rlm_rcode_t *p_result, module_ctx_t cons
        fr_pair_list_init(&data->mppe_keys);
        fr_pair_list_init(&data->reply);
 
+       /*
+        *      Allow the administrator to set the CHAP-Challenge and Peer-Challenge attributes.
+        */
        auth_challenge = fr_pair_find_by_da(&parent->control_pairs, NULL, attr_ms_chap_challenge);
        if (auth_challenge && (auth_challenge->vp_length != MSCHAPV2_CHALLENGE_LEN)) {
                RWDEBUG("&parent.control.MS-CHAP-Challenge is incorrect length.  Ignoring it");
@@ -792,16 +795,12 @@ static unlang_action_t mod_session_init(rlm_rcode_t *p_result, module_ctx_t cons
                peer_challenge = NULL;
        }
 
-       if (auth_challenge) {
-               created_auth_challenge = false;
-
-       } else {
-               created_auth_challenge = true;
-               peer_challenge = NULL;
+       created_auth_challenge = (auth_challenge == NULL);
 
-               /*
-                *      Get a random challenge.
-                */
+       /*
+        *      if the administrator didn't set a challenge, then create one ourselves.
+        */
+       if (!auth_challenge) {
                MEM(auth_challenge = fr_pair_afrom_da(eap_session, attr_ms_chap_challenge));
                MEM(fr_pair_value_mem_alloc(auth_challenge, &p, MSCHAPV2_CHALLENGE_LEN, false) == 0);
                for (i = 0; i < MSCHAPV2_CHALLENGE_LEN; i++) p[i] = fr_rand();