cannot import math module in rlm_python
    Chinnapaiyan, Nagamani 
    nagamani.chinnapaiyan at viasat.com
       
    Wed Jun 19 15:53:45 UTC 2024
    
    
  
Hi,
We are using latest master branch(#933d82589741cf7e70150eb01744735be3380f5c).
built the rpms on alma8 using redhat/freeradius.spec, noticed python was compiled successfully and installed on an alma8 machine.
we see following error when using python module.(when importing math in example.py).
# radiusd -X
Info  : Copyright 1999-2024 The FreeRADIUS server project and contributors
Info  : There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
Info  : PARTICULAR PURPOSE
Info  : You may redistribute copies of FreeRADIUS under the terms of the
Info  : GNU General Public License
Info  : For more information about these matters, see the file named COPYRIGHT
Info  : Starting - reading configuration files ...
Debug : Including dictionary file "/etc/raddb/dictionary"
Debug : including configuration file /etc/raddb/radiusd.conf
Debug : Including files in directory "/etc/raddb/template.d/"
Debug : including configuration file /etc/raddb/template.d/default
Debug : including configuration file /etc/raddb/clients.conf
Debug : Including files in directory "/etc/raddb/global.d/"
Debug : including configuration file /etc/raddb/global.d/ldap
Debug : including configuration file /etc/raddb/global.d/python
Debug : Including files in directory "/etc/raddb/mods-enabled/"
Debug : including configuration file /etc/raddb/mods-enabled/always
Debug : including configuration file /etc/raddb/mods-enabled/python
Debug : Including files in directory "/etc/raddb/policy.d/"
Debug : including configuration file /etc/raddb/policy.d/abfab-tr
Debug : including configuration file /etc/raddb/policy.d/accounting
Debug : including configuration file /etc/raddb/policy.d/canonicalisation
Debug : including configuration file /etc/raddb/policy.d/control
Debug : including configuration file /etc/raddb/policy.d/cui
Debug : including configuration file /etc/raddb/policy.d/debug
Debug : including configuration file /etc/raddb/policy.d/dhcp
Debug : including configuration file /etc/raddb/policy.d/eap
Debug : including configuration file /etc/raddb/policy.d/filter
Debug : including configuration file /etc/raddb/policy.d/operator-name
Debug : including configuration file /etc/raddb/policy.d/time
Debug : including configuration file /etc/raddb/policy.d/vendor
Debug : Including files in directory "/etc/raddb/sites-enabled/"
Debug : including configuration file /etc/raddb/sites-enabled/dhcp
Debug : Loaded module process_dhcpv4
Debug : Parsing initial logging configuration.
Debug : main {
Debug :   prefix = /usr
Debug :   log {
Debug :     destination = files
Debug :     syslog_facility = daemon
Debug :     local_state_dir = "/usr/var"
Debug :     logdir = "/usr/var/log"
Debug :     file = /var/log/radius/radius.log
Debug :     suppress_secrets = no
Debug :   }
Debug : }
Debug : Parsing security rules to bootstrap UID / GID / chroot / etc.
Debug : main {
Debug :   log {
Debug :   }
Debug :   security {
Debug :     allow_core_dumps = no
Debug :     allow_vulnerable_openssl = no
Debug :     openssl_fips_mode = no
Debug :   }
Debug :   name = radiusd
Debug :   local_state_dir = "/usr/var"
Debug :   run_dir = /var/run/radiusd
Debug : }
Debug : Parsing main configuration
Debug : main {
Debug :   server dhcp {
Debug :     namespace = dhcpv4
Debug : Loaded module proto_dhcpv4
Debug :     listen {
Debug :       type = Discover
Debug :       type = Request
Debug :       type = Inform
Debug :       type = Release
Debug :       type = Decline
Debug :       transport = udp
Debug : Loaded module proto_dhcpv4_udp
Debug :       udp {
Debug :         ipaddr = 127.0.0.1
Debug :         port = 6700
Debug :         broadcast = no
Debug :         networks {
Debug :         }
Debug :         max_packet_size = 4096
Debug :         max_attributes = 255
Debug :       }
Debug :       limit {
Debug :         cleanup_delay = 5.0
Debug :         idle_timeout = 30.0
Debug :         nak_lifetime = 30.0
Debug :         max_connections = 1024
Debug :         max_clients = 256
Debug :         max_pending_packets = 256
Debug :         priority {
Debug :           Discover = normal
Debug :           Request = normal
Debug :           Decline = normal
Debug :           Release = normal
Debug :           Inform = normal
Debug :           Lease-Query = low
Debug :           Bulk-Lease-Query = low
Debug :         }
Debug :       }
Debug :     }
Debug :   }
Debug :   log {
Debug :     colourise = yes
Debug :   }
Debug :   security {
Debug :   }
Debug :   sbin_dir = "/usr/sbin"
Debug :   logdir = /var/log/radius
Debug :   radacctdir = /var/log/radius/radacct
Debug :   reverse_lookups = no
Debug :   hostname_lookups = yes
Debug :   max_request_time = 30
Debug :   pidfile = /var/run/radiusd/radiusd.pid
Debug :   debug_level = 0
Debug :   max_requests = 16384
Debug :   resources {
Debug :   }
Debug :   thread pool {
Debug :     num_networks = 1
Info  : Dynamically determined thread.workers = 2
Debug :     num_workers = 2
Debug :     openssl_async_pool_init = 64
Debug :     openssl_async_pool_max = 1024
Debug :   }
Debug :   migrate {
Debug :     rewrite_update = false
Debug :     forbid_update = false
Debug :   }
Debug : }
Info  : Switching to configured log settings
Debug :   log debug {
Debug :     destination = null
Debug :     timestamp = yes
Debug :     colourise = no
Debug :   }
Debug : radiusd: #### Loading Clients ####
Debug :   client localhost {
Debug :     ipaddr = 127.0.0.1
Debug :     secret = <<< secret >>>
Debug :     require_message_authenticator = no
Debug :     proto = *
Debug :     limit {
Debug :       max_connections = 16
Debug :       lifetime = 0
Debug :       idle_timeout = 30
Debug :     }
Debug :   }
Debug :   client localhost_ipv6 {
Debug :     ipv6addr = ::1
Debug :     secret = <<< secret >>>
Debug :     limit {
Debug :       max_connections = 16
Debug :       lifetime = 0
Debug :       idle_timeout = 30s
Debug :     }
Debug :   }
Debug :   client public_network {
Debug :     ipv4addr = 0.0.0.0/0
Debug :     shortname = allowAll
Debug :     limit {
Debug :       max_connections = 16
Debug :       lifetime = 0
Debug :       idle_timeout = 30s
Debug :     }
Debug :   }
Info  : Debugger not attached
Info  : systemd watchdog is disabled
Info  : pre-suid-down capabilities: =ep
Warn  : trigger { ... } subsection not found, triggers will be disabled
Debug : #### Instantiating libraries ####
Debug : #### Bootstrapping process modules ####
Debug : #### Bootstrapping protocol modules ####
Debug : #### Instantiating libraries ####
Debug : #### Bootstrapping static modules ####
Debug :  modules {
Debug :     static {
Debug : Loaded module rlm_always
Debug :     always reject {
Debug :       rcode = reject
Debug :     }
Debug :     always fail {
Debug :       rcode = fail
Debug :     }
Debug :     always ok {
Debug :       rcode = ok
Debug :     }
Debug :     always handled {
Debug :       rcode = handled
Debug :     }
Debug :     always invalid {
Debug :       rcode = invalid
Debug :     }
Debug :     always disallow {
Debug :       rcode = disallow
Debug :     }
Debug :     always notfound {
Debug :       rcode = notfound
Debug :     }
Debug :     always noop {
Debug :       rcode = noop
Debug :     }
Debug :     always updated {
Debug :       rcode = updated
Debug :     }
Debug : Instantiating python
Debug :     python {
Debug :       path = /etc/raddb/mods-config/python
Debug :     }
Info  : rlm_python - Python version: 3.8.17 (default, Oct 17 2023, 14:11:04)  [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)]
Warn  : rlm_python - Failed loading libpython symbols into global symbol table: Can't resolve symbol Py_IsInitialized
Info  : rlm_python - Python path set to "/etc/raddb/mods-config/python:/usr/lib64/python38.zip:/usr/lib64/python3.8:/usr/lib64/python3.8/lib-dynload"
Debug : Loaded module rlm_python
Debug :     python {
Debug :       mod_instantiate = "example"
Debug :       func_instantiate = instantiate
Debug :       mod_authorize = "example"
Debug :       func_authorize = authorize
Debug :       mod_authenticate = "example"
Debug :       mod_preacct = "example"
Debug :       mod_accounting = "example"
Debug :       mod_post_auth = "example"
Debug :       func_post_auth = post_auth
Debug :       mod_detach = "example"
Debug :       func_detach = detach
Debug :     }
Debug :     } # static
Debug : #### Bootstrapping rlm modules ####
Debug : Bootstrapping rlm_always "disallow"
Debug : Bootstrapping rlm_always "fail"
Debug : Bootstrapping rlm_always "handled"
Debug : Bootstrapping rlm_always "invalid"
Debug : Bootstrapping rlm_always "noop"
Debug : Bootstrapping rlm_always "notfound"
Debug : Bootstrapping rlm_always "ok"
Debug : Bootstrapping rlm_always "reject"
Debug : Bootstrapping rlm_always "updated"
Debug : #### Instantiating listeners ####
Debug : Compiling policies in server dhcp { ... }
Debug : Compiling policies in - recv Discover {...}
Debug : Compiling policies in - recv Request {...}
Debug : Compiling policies in - recv Decline {...}
Debug : Compiling policies in - recv Release {...}
Debug : Compiling policies in - recv Inform {...}
Debug : Compiling policies in - recv Lease-Query {...}
Warn  : /etc/raddb/sites-enabled/dhcp[296]: Skipping remaining instructions due to 'return'
Warn  : /etc/raddb/sites-enabled/dhcp[308]: Skipping remaining instructions due to 'return'
Warn  : dhcpv4  { ... } section is unused
Debug : #### Instantiating process modules ####
Debug : #### Instantiating protocol modules ####
Debug : Instantiating proto_dhcpv4 "dhcp.dhcpv4"
Debug : Instantiating proto_dhcpv4_udp "dhcp.dhcpv4.udp"
Debug : #### Instantiating rlm modules ####
Debug : Instantiating rlm_always "disallow"
Debug : Instantiating rlm_always "fail"
Debug : Instantiating rlm_always "handled"
Debug : Instantiating rlm_always "invalid"
Debug : Instantiating rlm_always "noop"
Debug : Instantiating rlm_always "notfound"
Debug : Instantiating rlm_always "ok"
Debug : Instantiating rlm_python "python"
Error : python - python_function_load - Module 'example' load failed
Error : python - <class 'ImportError'> (/usr/lib64/python3.8/lib-dynload/math.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyExc_ValueError)
Error : python - [0] /etc/raddb/mods-config/python/example.py:9 at <module>()
Error : /etc/raddb/mods-enabled/python[1]: Instantiation failed for module "python"
Fatal Python error: PyInterpreterState_Delete: remaining subinterpreters
Python runtime state: finalizing (tstate=0x162cf00)
CAUGHT SIGNAL: Aborted
No panic action set
I could actually import math module when running python3.8 separately without any error,
# python3.8
Python 3.8.17 (default, Oct 17 2023, 14:11:04)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>>
Regards,
Nagamani Chinnapaiyan
    
    
More information about the Freeradius-Users
mailing list