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. 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." 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 Was rlm_python3 made obsolete as 2.7 was EOL back in Jan of 2020 and everything is now simply under rlm_python? 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 ? 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/ Are my assumptions wildly incorrect or am I missing something super obvious? Thank you, Jonathan
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.
On 23/11/2021 22:20, Alan DeKok wrote:
On Nov 23, 2021, at 5:10 PM, Jonathan Davis <jonathan@prioritycolo.com> wrote:
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.
Actually it's an artefact of how the web site is generated. The module information comes from the master branch. The metadata has never been added to v3 AFAIK. Most cases it's fine as the modules do the same thing, or don't exist in one or the other version. Python is one of those few where the naming and behaviour are subtly different between v3 and v4. I think this is the first question about it in 4 years since it's been up...
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.
Saw this last week and looked at updating it. Just very busy right now. Hopefully later this week. I need to be careful that adding python3 lib dependencies to the v3 freeradius package doesn't cause unexpected problems, especially for older systems. (Adding the module itself to the package is a noop unless it's used in the config, so that side is safe at least). -- Matthew
Thank you both Alan and Matthew for the response. As an aside, under Ubuntu there is a freeradius-python3 package. When I had tried to install that one one of our Ubuntu servers, I got dependency issues: freeradius-python3 : Depends: freeradius (= 3.0.20+dfsg-3build1) but 3.0.25-2 is to be installed However, looking at it now, that is maintained by the Ubuntu Developers. For my current issue on AlmaLinux release 8.5, I think the quickest solution for me is rewrite the portions of my python script to work under 2.7 until python3 is added to the networkradius packages, then switch them to my python3 script. It is still very good to know the reasons behind the problems I was running into. Thank you, Jonathan Davis - Priority Colo Inc. jonathan@prioritycolo.com -https://www.prioritycolo.com 1-888-AS-30176 (1-888-273-0176) x304 On 2021-11-23 5:35 p.m., Matthew Newton wrote:
On 23/11/2021 22:20, Alan DeKok wrote:
On Nov 23, 2021, at 5:10 PM, Jonathan Davis <jonathan@prioritycolo.com> wrote:
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.
Actually it's an artefact of how the web site is generated.
The module information comes from the master branch. The metadata has never been added to v3 AFAIK.
Most cases it's fine as the modules do the same thing, or don't exist in one or the other version. Python is one of those few where the naming and behaviour are subtly different between v3 and v4.
I think this is the first question about it in 4 years since it's been up...
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.
Saw this last week and looked at updating it. Just very busy right now. Hopefully later this week.
I need to be careful that adding python3 lib dependencies to the v3 freeradius package doesn't cause unexpected problems, especially for older systems. (Adding the module itself to the package is a noop unless it's used in the config, so that side is safe at least).
participants (3)
-
Alan DeKok -
Jonathan Davis -
Matthew Newton