RLM_python patch to enable postproxy - Not work need a little help
Hi Guys I wrote the attached patch for Freeradius 1.1.7 to enabled calling python in the post-proxy, it compiles but will not run when the hook is listed in post-proxy because Freeradius complains that there is no support for post-proxy in rlm_python. My question is where in the source is the list of allowed call per module ? Once I know this I can fix this attached and supply as a tested patch. Thanks Mike --- src/modules/rlm_python/rlm_python.c.orig 2007-03-06 00:45:28.000000000 +1030 +++ src/modules/rlm_python/rlm_python.c 2007-10-10 15:36:51.000000000 +0930 @@ -54,6 +54,7 @@ char *mod_authenticate; char *mod_preacct; char *mod_accounting; + char *mod_post_proxy; char *mod_checksimul; char *mod_detach; @@ -63,6 +64,7 @@ char *func_authenticate; char *func_preacct; char *func_accounting; + char *func_post_proxy; char *func_checksimul; char *func_detach; @@ -71,6 +73,7 @@ PyObject *pModule_authenticate; PyObject *pModule_preacct; PyObject *pModule_accounting; + PyObject *pModule_post_proxy; PyObject *pModule_checksimul; PyObject *pModule_detach; @@ -80,6 +83,7 @@ PyObject *pFunc_authenticate; PyObject *pFunc_preacct; PyObject *pFunc_accounting; + PyObject *pFunc_post_proxy; PyObject *pFunc_checksimul; PyObject *pFunc_detach; }; @@ -120,6 +124,11 @@ { "func_accounting", PW_TYPE_STRING_PTR, offsetof(struct rlm_python_t, func_accounting), NULL, NULL}, + { "mod_post_proxy", PW_TYPE_STRING_PTR, + offsetof(struct rlm_python_t, mod_post_proxy), NULL, NULL}, + { "func_post_proxy", PW_TYPE_STRING_PTR, + offsetof(struct rlm_python_t, func_post_proxy), NULL, NULL}, + { "mod_checksimul", PW_TYPE_STRING_PTR, offsetof(struct rlm_python_t, mod_checksimul), NULL, NULL}, { "func_checksimul", PW_TYPE_STRING_PTR, @@ -490,6 +499,7 @@ python_objclear(&data->pFunc_authenticate); python_objclear(&data->pFunc_preacct); python_objclear(&data->pFunc_accounting); + python_objclear(&data->pFunc_post_proxy); python_objclear(&data->pFunc_checksimul); python_objclear(&data->pFunc_detach); @@ -498,6 +508,7 @@ python_objclear(&data->pModule_authenticate); python_objclear(&data->pModule_preacct); python_objclear(&data->pModule_accounting); + python_objclear(&data->pModule_post_proxy); python_objclear(&data->pModule_checksimul); python_objclear(&data->pModule_detach); } @@ -566,6 +577,12 @@ &data->pFunc_accounting) < 0) goto failed; + if (python_load_function(data->mod_post_proxy, + data->func_post_proxy, + &data->pModule_post_proxy, + &data->pFunc_post_proxy) < 0) + goto failed; + if (python_load_function(data->mod_checksimul, data->func_checksimul, &data->pModule_checksimul, @@ -633,6 +650,14 @@ "accounting"); } +static int python_post_proxy(void *instance, REQUEST *request) +{ + return python_function( + request, + ((struct rlm_python_t *)instance)->pFunc_post_proxy, + "post-proxy"); +} + static int python_checksimul(void *instance, REQUEST *request) { return python_function( @@ -663,7 +688,7 @@ python_accounting, /* accounting */ python_checksimul, /* checksimul */ NULL, /* pre-proxy */ - NULL, /* post-proxy */ + python_post_proxy, /* post-proxy */ NULL /* post-auth */ }, python_detach, /* detach */
Mike O'Connor wrote:
I wrote the attached patch for Freeradius 1.1.7 to enabled calling python in the post-proxy, it compiles but will not run when the hook is listed in post-proxy because Freeradius complains that there is no support for post-proxy in rlm_python.
You didn't install the new version of rlm_python. So it's still linking to the old rlm_python, without post-proxy support.
My question is where in the source is the list of allowed call per module ?
No. The *only* interaction is in the modules. Alan DeKok.
Alan DeKok wrote:
Mike O'Connor wrote:
I wrote the attached patch for Freeradius 1.1.7 to enabled calling python in the post-proxy, it compiles but will not run when the hook is listed in post-proxy because Freeradius complains that there is no support for post-proxy in rlm_python.
You didn't install the new version of rlm_python. So it's still linking to the old rlm_python, without post-proxy support.
Maybe I'm not getting your but even the lastest cvs does not have any post-proxy or post-auth support. module_t rlm_python = { RLM_MODULE_INIT, "python", RLM_TYPE_THREAD_SAFE, /* type */ python_instantiate, /* instantiation */ python_detach, /* detach */ { python_authenticate, /* authentication */ python_authorize, /* authorization */ python_preacct, /* preaccounting */ python_accounting, /* accounting */ python_checksimul, /* checksimul */ NULL, /* pre-proxy */ NULL, /* post-proxy */ NULL /* post-auth */ }, }; My code added the post-proxy but when I tried to use it freeradius would complain that rlm_python did not support being called from the post-auth section of radiusd.conf.
My question is where in the source is the list of allowed call per module ?
No. The *only* interaction is in the modules.
That's what I would have thought which is why what I saw did not make any senses. It would report finding my config section for the post-proxy but when added to the config it would not start freeradius. Thanks Mike
Mike O'Connor wrote:
Maybe I'm not getting your but even the lastest cvs does not have any post-proxy or post-auth support.
That's not what I meant.
My code added the post-proxy but when I tried to use it freeradius would complain that rlm_python did not support being called from the post-auth section of radiusd.conf.
Yes... because the server is using the version of rlm_python from 1.1.7, and NOT the one you built. Go delete the one installed by 1.1.7, and MAKE SURE that the one you built is installed.
That's what I would have thought which is why what I saw did not make any senses. It would report finding my config section for the post-proxy but when added to the config it would not start freeradius.
Finding the config simple means that you told it to use python for post-proxy. Finding the "post-proxy" entry in the module structure means that the server knows the module is *capable* of post-proxy. If the server is using the OLD version of rlm_python, and not the NEW version you build, it WILL NOT find that "post-proxy" entry, because the module it found is not capable of post-proxy. Alan DeKok.
Hi Alan I think I have worked it out, some how I got my self confused during my testing. The model was there but I think each time I did not have everything configured. Thanks as always for your time Mike
participants (2)
-
Alan DeKok -
Mike O'Connor