rlm_python in v3.0.x

Arran Cudbard-Bell a.cudbardb at freeradius.org
Thu May 5 16:06:06 CEST 2016

rlm_python from v3.1.x has been backported to the v3.0.x branch.

This addresses all but 1 of the ~7 rlm_python issues that had accumulated in the issue tracker.


- Instantiation and destruction with multiple instances is always clean, and should never result in a SEGV.
- The module is 'threaded', without any side effects (race conditions or crashes).
- Thread Local Storage is now distinct between instances of rlm_python
- Multiple sub interpreters can be used, but this is disabled by default in v3.0.x because of compatibility issues with some C extensions to python.
- Double quotes are no longer escaped.
- Constants are synced with the server constants.

In v3.1.x I also added conversion to proper Python types, i.e. unsigned/signed integers get converted to Python Long numbers, floats get converted to decimals, strings get converted from UTF-8 to UTF-16 (and are binary safe), octet strings are left in their original form (not converted to hex).

Conversion back to C types is still done with string parsing.  That can be addressed by someone sufficiently motivated.  I don't think it's significantly more difficult than conversion to Python types.

Encourage anyone that depends on Python in v3.0.x to test *before* 3.0.12 is released and report any issues.

Thanks to Guillaume Pannatier for all the recent testing and automated test cases, and to all those that opened issues against rlm_python.

No thanks to the Python team for creating an extraordinarily obtuse C API.

My favourite, lease favourite part is this:

		 *	Initialise a new module, with our default methods
		inst->module = Py_InitModule3("radiusd", module_methods, "FreeRADIUS python module");
		if (!inst->module) {
			return -1;

		 *	Py_InitModule3 returns a borrowed ref, the actual
		 *	module is owned by sys.modules, so we also need
		 *	to own the module to prevent it being freed early.

Just wow...


Arran Cudbard-Bell <a.cudbardb at freeradius.org>
FreeRADIUS Development Team

FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 872 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20160505/2b0ab235/attachment.sig>

More information about the Freeradius-Users mailing list