Skip to content

Commit

Permalink
Pass nested attributes to Python functions (fixes #5456)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndptech committed Jan 2, 2025
1 parent 5278fee commit b5cfaf8
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/modules/rlm_python/rlm_python.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,39 @@ static int mod_populate_vptuple(module_ctx_t const *mctx, request_t *request, Py
break;

case FR_TYPE_NON_LEAF:
return 0;
{
fr_pair_t *child_vp;
int child_len, i = 0;

child_len = fr_pair_list_num_elements(&vp->vp_group);
if (child_len == 0) {
Py_INCREF(Py_None);
value = Py_None;
break;
}

if ((value = PyTuple_New(child_len)) == NULL) goto error;

for (child_vp = fr_pair_list_head(&vp->vp_group);
child_vp;
child_vp = fr_pair_list_next(&vp->vp_group, child_vp), i++) {
PyObject *child_pp;

if ((child_pp = PyTuple_New(2)) == NULL) {
Py_DECREF(value);
goto error;
}

if (mod_populate_vptuple(mctx, request, child_pp, child_vp) == 0) {
PyTuple_SET_ITEM(value, i, child_pp);
} else {
Py_INCREF(Py_None);
PyTuple_SET_ITEM(value, i, Py_None);
Py_DECREF(child_pp);
}
}
}
break;
}

if (value == NULL) goto error;
Expand Down

0 comments on commit b5cfaf8

Please sign in to comment.