Accessing REQUEST structure data outside FreeRADIUS module
Hello and thanks for replies I'm using FreeRADIUS v1.1.0. I'm developping some modules and I try to access auth_req structure (REQUEST) data from an external function (out of my module) and it fails. All works fine when accessing this data from the module itself but when i call an external function with the address of REQUEST, it doesn't work. Code which works /***********************************************************************/ static int wcp_lt_vms_authorize(void *pt_instance, REQUEST *pt_request) { VALUE_PAIR *lpt_value_pair = NULL; ... if ((lpt_value_pair = pairfind(pt_request->packet->vps, PW_USER_NAME)) == NULL ) { WCP_DEBUG("User-Name not found !"); } else { WCP_DEBUG("RADIUS attribute name %s, value: [%s]", lpt_value_pair->name, lpt_value_pair->strvalue); } ... } /***********************************************************************/ This works fine, when the server receive a request Tue Apr 11 16:05:03 2006 : wcp_lt_vms_authorize: RADIUS attribute name User-Name, value: [330001] The problem comes when doing the same thing but by calling a function. /***********************************************************************/ static int wcp_lt_vms_authorize(void *pt_instance, REQUEST *pt_request) { ... lib_com_filter_traffic(pt_request); ... } /***********************************************************************/ and in anotherfile, lib_com.c int lib_com_filter_traffic(REQUEST *pt_request) { VALUE_PAIR *lpt_value_pair = NULL; ... if ((lpt_value_pair = pairfind(pt_request->packet->vps, PW_USER_NAME)) == NULL ) { WCP_DEBUG("User-Name not found !"); } else { WCP_DEBUG("RADIUS attribute name %s, value: [%s]", lpt_value_pair->name, lpt_value_pair->strvalue); } /***********************************************************************/ This doesn't work. when receiving one request, FreeRADIUS takes a lot of processor time and then the server crashes. Tue Apr 11 17:00:30 2006 : Error: WARNING: Unresponsive child (id 3) for request 0 I don't understand why all works when accessing REQUEST data inside the module and not in the lib function. It's like the lib can't accessed to this memory. Any help would be appreciated.
"Nicolas Castel" <nicolas.castel@gmail.com> wrote:
I'm using FreeRADIUS v1.1.0. I'm developping some modules and I try to access auth_req structure (REQUEST) data from an external function (out of my module) and it fails. All works fine when accessing this data from the module itself but when i call an external function with the address of REQUEST, it doesn't work.
It's possible. Lots and lots of modules do it. The problem is most likely that you're passing different compile-time flags to the different C files. As a result, the "magic" entry at the top of the REQUEST structure is used in one C file, but not in another. There is no such magic in the RADIUS_PACKET structure, so that always works. The solution is to build your module either as you're building the server, or pass -DNDEBUG as an option to the compiler. Alan DeKok.
2006/4/12, Alan DeKok <aland@nitros9.org>:
"Nicolas Castel" <nicolas.castel@gmail.com> wrote:
I'm using FreeRADIUS v1.1.0. I'm developping some modules and I try to access auth_req structure (REQUEST) data from an external function (out of my module) and it fails. All works fine when accessing this data from the module itself but when i call an external function with the address of REQUEST, it doesn't work.
It's possible. Lots and lots of modules do it.
The problem is most likely that you're passing different compile-time flags to the different C files. As a result, the "magic" entry at the top of the REQUEST structure is used in one C file, but not in another. There is no such magic in the RADIUS_PACKET structure, so that always works.
The solution is to build your module either as you're building the server, or pass -DNDEBUG as an option to the compiler.
Alan DeKok. - Hello,
Thanks a lot for this solution. As a matter of fact, the module compilation already have the DBDEBUG flag but i didn't compile my library with this flag. I passed this famous flag to my lib compilation and all works fine ! No more problem to access every fields of structure REQUEST. Once again thanks !
participants (2)
-
Alan DeKok -
Nicolas Castel