* hash of MS-CHAPv2 challenge, and peer challenge.
*/
if (strncasecmp(arg->vb_strvalue, "Challenge", 9) == 0) {
- chap_challenge = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap_challenge);
+ chap_challenge = fr_pair_find_by_da_nested(&request->request_pairs, NULL, attr_ms_chap_challenge);
if (!chap_challenge) {
REDEBUG("No MS-CHAP-Challenge in the request");
return XLAT_ACTION_FAIL;
char const *username_str;
size_t username_len;
- response = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap2_response);
+ response = fr_pair_find_by_da_nested(&request->request_pairs, NULL, attr_ms_chap2_response);
if (!response) {
REDEBUG("Vendor-Specific.Microsoft.CHAP2-Response is required to calculate MS-CHAPv1 challenge");
return XLAT_ACTION_FAIL;
* response.
*/
} else if (strncasecmp(arg->vb_strvalue, "NT-Response", 11) == 0) {
- response = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap_response);
- if (!response) response = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap2_response);
+ response = fr_pair_find_by_da_nested(&request->request_pairs, NULL, attr_ms_chap_response);
+ if (!response) response = fr_pair_find_by_da_nested(&request->request_pairs, NULL, attr_ms_chap2_response);
if (!response) {
REDEBUG("No MS-CHAP-Response or MS-CHAP2-Response was found in the request");
return XLAT_ACTION_FAIL;
* in MS-CHAPv1, and not often there.
*/
} else if (strncasecmp(arg->vb_strvalue, "LM-Response", 11) == 0) {
- response = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap_response);
+ response = fr_pair_find_by_da_nested(&request->request_pairs, NULL, attr_ms_chap_response);
if (!response) {
REDEBUG("No MS-CHAP-Response was found in the request");
return XLAT_ACTION_FAIL;
{
rlm_mschap_t const *inst = talloc_get_type_abort_const(mctx->inst->data, rlm_mschap_t);
fr_pair_t *challenge = NULL;
+ fr_pair_t *parent;
- challenge = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap_challenge);
+ challenge = fr_pair_find_by_da_nested(&request->request_pairs, NULL, attr_ms_chap_challenge);
if (!challenge) RETURN_MODULE_NOOP;
- if (!fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap_response) &&
- !fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap2_response) &&
- !fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap2_cpw)) {
+ /*
+ * The responses MUST be in the same group as the challenge.
+ */
+ parent = fr_pair_parent(challenge);
+ fr_assert(parent != NULL);
+
+ if (!fr_pair_find_by_da(&parent->vp_group, NULL, attr_ms_chap_response) &&
+ !fr_pair_find_by_da(&parent->vp_group, NULL, attr_ms_chap2_response) &&
+ !fr_pair_find_by_da(&parent->vp_group, NULL, attr_ms_chap2_cpw)) {
RDEBUG2("Found MS-CHAP-Challenge, but no MS-CHAP response or Change-Password");
RETURN_MODULE_NOOP;
}
fr_pair_t *challenge = NULL;
fr_pair_t *response = NULL;
fr_pair_t *cpw = NULL;
+ fr_pair_t *parent;
fr_pair_t *nt_password = NULL, *smb_ctrl;
uint8_t nthashhash[NT_DIGEST_LENGTH];
int mschap_version = 0;
* Check to see if this is a change password request, and process
* it accordingly if so.
*/
- cpw = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap2_cpw);
+ cpw = fr_pair_find_by_da_nested(&request->request_pairs, NULL, attr_ms_chap2_cpw);
if (cpw) {
uint8_t *p;
memcpy(p + 2, cpw->vp_octets + 18, 48);
}
- challenge = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap_challenge);
+ challenge = fr_pair_find_by_da_nested(&request->request_pairs, NULL, attr_ms_chap_challenge);
if (!challenge) {
REDEBUG("&control.Auth-Type = %s set for a request that does not contain &%s",
mctx->inst->name, attr_ms_chap_challenge->name);
goto finish;
}
+ /*
+ * The responses MUST be in the same group as the challenge.
+ */
+ parent = fr_pair_parent(challenge);
+ fr_assert(parent != NULL);
+
/*
* We also require an MS-CHAP-Response.
*/
- if ((response = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap_response))) {
+ if ((response = fr_pair_find_by_da(&parent->vp_group, NULL, attr_ms_chap_response))) {
mschap_process_response(&rcode,
&mschap_version, nthashhash,
inst, request,
challenge, response,
method);
if (rcode != RLM_MODULE_OK) goto finish;
- } else if ((response = fr_pair_find_by_da(&request->request_pairs, NULL, attr_ms_chap2_response))) {
+ } else if ((response = fr_pair_find_by_da_nested(&parent->vp_group, NULL, attr_ms_chap2_response))) {
mschap_process_v2_response(&rcode,
&mschap_version, nthashhash,
inst, request,