Multiple authorize methods with python module
Arran Cudbard-Bell
a.cudbardb at freeradius.org
Mon Dec 18 18:48:32 CET 2017
> On 8 Dec 2017, at 02:53, Alan DeKok <aland at deployingradius.com> wrote:
>
> On Dec 7, 2017, at 7:46 PM, Gary Gwin <garygwin at gmail.com> wrote:
>>
>> If I reference the same python module from mypython1 and mypython2
>>
>> python mypython1 {
>> module = example
>> ...
>> }
>>
>> python mypython2 {
>> module = example
>> ...
>> }
>>
>> Then FreeRADIUS initializes and functions properly.
>
> Due to limitation in the Python interpreter, FreeRADIUS *cannot* instantiate multiple independent Python interpreters.
>
> Any module you load has to be from one global Python module space / namespace.
>
>> However, if I use a
>> different module for each, and in this test case a copy of same tested and
>> functioning python program with a different name:
>>
>> python mypython1 {
>> module = example
>> ...
>> }
>>
>> python mypython2 {
>> module = example2
>> ...
>> }
>>
>> I get the following error initializing:
>>
>> # Instantiating module "mypython2" from file
>> /etc/freeradius/3.0/mods-enabled/mypython2
>> python_function_load - Module 'example2' not found
>> <type 'exceptions.SystemError'> (null argument to internal routine)
>> python_function_load - Failed to import python function 'example2.authorize'
>> /etc/freeradius/3.0/mods-enabled/mypython2[2]: Instantiation failed for
>> module "mypython2"
>
> You should be able to load completely different Python modules, but they will both largely be running in the same interpreter.
In v3.0.x there should be different interpreter states which are swapped in and out depending on the thread and module instance.
The states should be isolated from each other, so they should act like there are multiple interpreters even though there's only one.
-Arran
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 874 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20171218/46afd393/attachment.sig>
More information about the Freeradius-Users
mailing list