On Nov 23, 2021, at 5:10 PM, Jonathan Davis <jonathan@prioritycolo.com> wrote:
I am looking to better understand the python modules under FreeRADIUS. My initial assumption was rlm_python was for 2.7.x and rlm_python3 was for 3.x.
Yes, that's true.
However I am confused about the information at https://freeradius.org/modules/
- rlm_python3 is listed as obsolete with the view documentation link taking you to https://networkradius.com/doc/current/raddb/mods-available/home.html where there is neither python or python3 - rlm_python is listed as not obsolete, with "Allows the server to call a persistent, embedded Python script."
Yeah, that's out of date. We'll have to update it. Both Python modules are supported in the 3.x releases.
Installed FreeRADIUS 3.0.25 from the networkRADIUS packages at https://networkradius.com/packages/
In the FreeRADIUS dir, I see there is both python and python3 under mods-available, and under mods-config only a python dir
Hmm.. the git repo doesn't have mods-config/python. I'm not sure where that comes from.
Was rlm_python3 made obsolete as 2.7 was EOL back in Jan of 2020 and everything is now simply under rlm_python?
No. The web page needs to be updated. rlm_python is for Python 2. rlm_python3 is for Python 3. Both modules are supported.
Looking at the latest examples on https://github.com/FreeRADIUS/freeradius-server/blob/master/src/modules/rlm_... I see both example.py and prepaid.py look to be executed as python3, both have #! /usr/bin/env python3 in their headers:
Create the symlink in mods-enabled/python to mods-available/python and try with the example provided, which works, then I switch it over to my own script, start radiusd -Xx and get the following error:
Tue Nov 23 16:02:41 2021 : Info: Python version: 2.7.18 (default, Oct 11 2021, 11:39:27) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]a Tue Nov 23 16:02:41 2021 : Error: python_function_load - Module 'dr_yubikey' not found Tue Nov 23 16:02:41 2021 : Error: <type 'exceptions.ImportError'> (No module named requests) Tue Nov 23 16:02:41 2021 : Error: [0] /etc/raddb/mods-config/python/dr_yubikey.py:13 at <module>() Tue Nov 23 16:02:41 2021 : Error: python_function_load - Failed to import python function 'dr_yubikey.authorize' Tue Nov 23 16:02:41 2021 : Error: /etc/raddb/mods-enabled/python[9]: Instantiation failed for module "python"
I'm aware the above is failing because requests can't be imported, but request is installed under python3, and that first info line is not python3, but Python 2.7.18 ?
If you enable the mods-available/python module, it will be using Python 2.
python2 pip install requests does get me to Tue Nov 23 16:19:55 2021 : Info: Ready to process requests when starting debug.
Trying with python3 symlinked in mods-enabled, and creating mods-config/python3 and dropping my .py in there:
Tue Nov 23 17:02:11 2021 : Error: /etc/raddb/mods-enabled/python3[9]: Failed to link to module 'rlm_python3': /usr/lib64/freeradius/rlm_python3.so: cannot open shared object file: No such file or directory
Which is true, there is no rlm_python3.so that exists under /usr/lib64/freeradius/
That isn't in the v3 packages. We'll update it.
Are my assumptions wildly incorrect or am I missing something super obvious?
You're pretty much correct. * rlm_python is for Python2 * rlm_python3 is for Python3 * both are supported in our v3 releases. * the current RPM / DEB files we distribute don't have rlm_python3 installed. We'll see if we can fix that. Alan DeKok.