freeradius-server icon indicating copy to clipboard operation
freeradius-server copied to clipboard

[defect]: incorrect detection of python 3.10 for rlm_python3 build

Open panlinux opened this issue 3 years ago • 7 comments
trafficstars

What type of defect/bug is this?

Unexpected behaviour (obvious or verified by project member)

How can the issue be reproduced?

Use a build environment that has python 3.10 as default. In the following m4 macro, ${PYTHON_VERSION} will be 3.1 instead of 3.10, and not add --embed to the python3-config call: https://github.com/FreeRADIUS/freeradius-server/blob/v3.0.x/src/modules/rlm_python3/configure.ac#L75

		AX_COMPARE_VERSION(${PYTHON_VERSION}, [ge], [3.8], [EMBED="--embed"], [])

Without --embed, python3.10's python3-config --ldflags will lack -lpython3:

$ python3-config --ldflags
-L/usr/lib/python3.10/config-3.10-x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu  -lcrypt -ldl  -lm -lm 

This will make the rlm python3 module not be linked with python3:

$ ldd /usr/lib/freeradius/rlm_python3.so
	linux-vdso.so.1 (0x00007ffef65f0000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f063fe70000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f06400ad000)

And rlm_python3 will fail to load:

Wed Mar 23 22:12:53 2022 : Error: /etc/freeradius/3.0/mods-enabled/python3[9]: Failed to link to module 'rlm_python3': /usr/lib/freeradius/rlm_python3.so: undefined symbol: PyTuple_Type 

It looks like PYTHON_VERSION is grabbed from sys.version using [:3], but that misses the fact that the minor version can be two digits.

Log output from the FreeRADIUS daemon

# freeradius -X
FreeRADIUS Version 3.0.26
Copyright (C) 1999-2021 The FreeRADIUS server project and contributors
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE
You may redistribute copies of FreeRADIUS under the terms of the
GNU General Public License
For more information about these matters, see the file named COPYRIGHT
Starting - reading configuration files ...
including dictionary file /usr/share/freeradius/dictionary
including dictionary file /usr/share/freeradius/dictionary.dhcp
including dictionary file /usr/share/freeradius/dictionary.vqp
including dictionary file /etc/freeradius/3.0/dictionary
including configuration file /etc/freeradius/3.0/radiusd.conf
including configuration file /etc/freeradius/3.0/proxy.conf
including configuration file /etc/freeradius/3.0/clients.conf
including files in directory /etc/freeradius/3.0/mods-enabled/
including configuration file /etc/freeradius/3.0/mods-enabled/dynamic_clients
including configuration file /etc/freeradius/3.0/mods-enabled/mschap
including configuration file /etc/freeradius/3.0/mods-enabled/ntlm_auth
including configuration file /etc/freeradius/3.0/mods-enabled/detail
including configuration file /etc/freeradius/3.0/mods-enabled/unix
including configuration file /etc/freeradius/3.0/mods-enabled/exec
including configuration file /etc/freeradius/3.0/mods-enabled/digest
including configuration file /etc/freeradius/3.0/mods-enabled/cache_eap
including configuration file /etc/freeradius/3.0/mods-enabled/unpack
including configuration file /etc/freeradius/3.0/mods-enabled/expr
including configuration file /etc/freeradius/3.0/mods-enabled/soh
including configuration file /etc/freeradius/3.0/mods-enabled/chap
including configuration file /etc/freeradius/3.0/mods-enabled/realm
including configuration file /etc/freeradius/3.0/mods-enabled/sradutmp
including configuration file /etc/freeradius/3.0/mods-enabled/expiration
including configuration file /etc/freeradius/3.0/mods-enabled/utf8
including configuration file /etc/freeradius/3.0/mods-enabled/replicate
including configuration file /etc/freeradius/3.0/mods-enabled/preprocess
including configuration file /etc/freeradius/3.0/mods-enabled/files
including configuration file /etc/freeradius/3.0/mods-enabled/linelog
including configuration file /etc/freeradius/3.0/mods-enabled/radutmp
including configuration file /etc/freeradius/3.0/mods-enabled/python3
including configuration file /etc/freeradius/3.0/mods-enabled/attr_filter
including configuration file /etc/freeradius/3.0/mods-enabled/pap
including configuration file /etc/freeradius/3.0/mods-enabled/eap
including configuration file /etc/freeradius/3.0/mods-enabled/always
including configuration file /etc/freeradius/3.0/mods-enabled/passwd
including configuration file /etc/freeradius/3.0/mods-enabled/echo
including configuration file /etc/freeradius/3.0/mods-enabled/detail.log
including configuration file /etc/freeradius/3.0/mods-enabled/logintime
including files in directory /etc/freeradius/3.0/policy.d/
including configuration file /etc/freeradius/3.0/policy.d/canonicalization
including configuration file /etc/freeradius/3.0/policy.d/debug
including configuration file /etc/freeradius/3.0/policy.d/operator-name
including configuration file /etc/freeradius/3.0/policy.d/rfc7542
including configuration file /etc/freeradius/3.0/policy.d/control
including configuration file /etc/freeradius/3.0/policy.d/filter
including configuration file /etc/freeradius/3.0/policy.d/accounting
including configuration file /etc/freeradius/3.0/policy.d/moonshot-targeted-ids
including configuration file /etc/freeradius/3.0/policy.d/dhcp
including configuration file /etc/freeradius/3.0/policy.d/eap
including configuration file /etc/freeradius/3.0/policy.d/abfab-tr
including configuration file /etc/freeradius/3.0/policy.d/cui
including files in directory /etc/freeradius/3.0/sites-enabled/
including configuration file /etc/freeradius/3.0/sites-enabled/default
including configuration file /etc/freeradius/3.0/sites-enabled/inner-tunnel
main {
 security {
 	user = "freerad"
 	group = "freerad"
 	allow_core_dumps = no
 }
	name = "freeradius"
	prefix = "/usr"
	localstatedir = "/var"
	logdir = "/var/log/freeradius"
	run_dir = "/var/run/freeradius"
}
main {
	name = "freeradius"
	prefix = "/usr"
	localstatedir = "/var"
	sbindir = "/usr/sbin"
	logdir = "/var/log/freeradius"
	run_dir = "/var/run/freeradius"
	libdir = "/usr/lib/freeradius"
	radacctdir = "/var/log/freeradius/radacct"
	hostname_lookups = no
	max_request_time = 30
	cleanup_delay = 5
	max_requests = 16384
	postauth_client_lost = no
	pidfile = "/var/run/freeradius/freeradius.pid"
	checkrad = "/usr/sbin/checkrad"
	debug_level = 0
	proxy_requests = yes
 log {
 	stripped_names = no
 	auth = no
 	auth_badpass = no
 	auth_goodpass = no
 	colourise = yes
 	msg_denied = "You are already logged in - access denied"
 }
 resources {
 }
 security {
 	max_attributes = 200
 	reject_delay = 1.000000
 	status_server = yes
 }
}
radiusd: #### Loading Realms and Home Servers ####
 proxy server {
 	retry_delay = 5
 	retry_count = 3
 	default_fallback = no
 	dead_time = 120
 	wake_all_if_all_dead = no
 }
 home_server localhost {
 	ipaddr = 127.0.0.1
 	port = 1812
 	type = "auth"
 	secret = <<< secret >>>
 	response_window = 20.000000
 	response_timeouts = 1
 	max_outstanding = 65536
 	zombie_period = 40
 	status_check = "status-server"
 	ping_interval = 30
 	check_interval = 30
 	check_timeout = 4
 	num_answers_to_alive = 3
 	revive_interval = 120
  limit {
  	max_connections = 16
  	max_requests = 0
  	lifetime = 0
  	idle_timeout = 0
  }
  coa {
  	irt = 2
  	mrt = 16
  	mrc = 5
  	mrd = 30
  }
 }
 home_server_pool my_auth_failover {
	type = fail-over
	home_server = localhost
 }
 realm example.com {
	auth_pool = my_auth_failover
 }
 realm LOCAL {
 }
radiusd: #### Loading Clients ####
 client localhost {
 	ipaddr = 127.0.0.1
 	require_message_authenticator = no
 	secret = <<< secret >>>
 	nas_type = "other"
 	proto = "*"
  limit {
  	max_connections = 16
  	lifetime = 0
  	idle_timeout = 30
  }
 }
 client localhost_ipv6 {
 	ipv6addr = ::1
 	require_message_authenticator = no
 	secret = <<< secret >>>
  limit {
  	max_connections = 16
  	lifetime = 0
  	idle_timeout = 30
  }
 }
Debugger not attached
systemd watchdog is disabled
 # Creating Auth-Type = mschap
 # Creating Auth-Type = digest
 # Creating Auth-Type = eap
 # Creating Auth-Type = PAP
 # Creating Auth-Type = CHAP
 # Creating Auth-Type = MS-CHAP
 # Creating Autz-Type = New-TLS-Connection
radiusd: #### Instantiating modules ####
 modules {
  # Loaded module rlm_dynamic_clients
  # Loading module "dynamic_clients" from file /etc/freeradius/3.0/mods-enabled/dynamic_clients
  # Loaded module rlm_mschap
  # Loading module "mschap" from file /etc/freeradius/3.0/mods-enabled/mschap
  mschap {
  	use_mppe = yes
  	require_encryption = no
  	require_strong = no
  	with_ntdomain_hack = yes
   passchange {
   }
  	allow_retry = yes
  	winbind_retry_with_normalised_username = no
  }
  # Loaded module rlm_exec
  # Loading module "ntlm_auth" from file /etc/freeradius/3.0/mods-enabled/ntlm_auth
  exec ntlm_auth {
  	wait = yes
  	program = "/path/to/ntlm_auth --request-nt-key --domain=MYDOMAIN --username=%{mschap:User-Name} --password=%{User-Password}"
  	shell_escape = yes
  }
  # Loaded module rlm_detail
  # Loading module "detail" from file /etc/freeradius/3.0/mods-enabled/detail
  detail {
  	filename = "/var/log/freeradius/radacct/%{%{Packet-Src-IP-Address}:-%{Packet-Src-IPv6-Address}}/detail-%Y%m%d"
  	header = "%t"
  	permissions = 384
  	locking = no
  	escape_filenames = no
  	log_packet_header = no
  }
  # Loaded module rlm_unix
  # Loading module "unix" from file /etc/freeradius/3.0/mods-enabled/unix
  unix {
  	radwtmp = "/var/log/freeradius/radwtmp"
  }
Creating attribute Unix-Group
  # Loading module "exec" from file /etc/freeradius/3.0/mods-enabled/exec
  exec {
  	wait = no
  	input_pairs = "request"
  	shell_escape = yes
  	timeout = 10
  }
  # Loaded module rlm_digest
  # Loading module "digest" from file /etc/freeradius/3.0/mods-enabled/digest
  # Loaded module rlm_cache
  # Loading module "cache_eap" from file /etc/freeradius/3.0/mods-enabled/cache_eap
  cache cache_eap {
  	driver = "rlm_cache_rbtree"
  	key = "%{%{control:State}:-%{%{reply:State}:-%{State}}}"
  	ttl = 15
  	max_entries = 0
  	epoch = 0
  	add_stats = no
  }
  # Loaded module rlm_unpack
  # Loading module "unpack" from file /etc/freeradius/3.0/mods-enabled/unpack
  # Loaded module rlm_expr
  # Loading module "expr" from file /etc/freeradius/3.0/mods-enabled/expr
  expr {
  	safe_characters = "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /äéöüàâæçèéêëîïôœùûüaÿÄÉÖÜßÀÂÆÇÈÉÊËÎÏÔŒÙÛÜŸ"
  }
  # Loaded module rlm_soh
  # Loading module "soh" from file /etc/freeradius/3.0/mods-enabled/soh
  soh {
  	dhcp = yes
  }
  # Loaded module rlm_chap
  # Loading module "chap" from file /etc/freeradius/3.0/mods-enabled/chap
  # Loaded module rlm_realm
  # Loading module "IPASS" from file /etc/freeradius/3.0/mods-enabled/realm
  realm IPASS {
  	format = "prefix"
  	delimiter = "/"
  	ignore_default = no
  	ignore_null = no
  }
  # Loading module "suffix" from file /etc/freeradius/3.0/mods-enabled/realm
  realm suffix {
  	format = "suffix"
  	delimiter = "@"
  	ignore_default = no
  	ignore_null = no
  }
  # Loading module "bangpath" from file /etc/freeradius/3.0/mods-enabled/realm
  realm bangpath {
  	format = "prefix"
  	delimiter = "!"
  	ignore_default = no
  	ignore_null = no
  }
  # Loading module "realmpercent" from file /etc/freeradius/3.0/mods-enabled/realm
  realm realmpercent {
  	format = "suffix"
  	delimiter = "%"
  	ignore_default = no
  	ignore_null = no
  }
  # Loading module "ntdomain" from file /etc/freeradius/3.0/mods-enabled/realm
  realm ntdomain {
  	format = "prefix"
  	delimiter = "\\"
  	ignore_default = no
  	ignore_null = no
  }
  # Loaded module rlm_radutmp
  # Loading module "sradutmp" from file /etc/freeradius/3.0/mods-enabled/sradutmp
  radutmp sradutmp {
  	filename = "/var/log/freeradius/sradutmp"
  	username = "%{User-Name}"
  	case_sensitive = yes
  	check_with_nas = yes
  	permissions = 420
  	caller_id = no
  }
  # Loaded module rlm_expiration
  # Loading module "expiration" from file /etc/freeradius/3.0/mods-enabled/expiration
  # Loaded module rlm_utf8
  # Loading module "utf8" from file /etc/freeradius/3.0/mods-enabled/utf8
  # Loaded module rlm_replicate
  # Loading module "replicate" from file /etc/freeradius/3.0/mods-enabled/replicate
  # Loaded module rlm_preprocess
  # Loading module "preprocess" from file /etc/freeradius/3.0/mods-enabled/preprocess
  preprocess {
  	huntgroups = "/etc/freeradius/3.0/mods-config/preprocess/huntgroups"
  	hints = "/etc/freeradius/3.0/mods-config/preprocess/hints"
  	with_ascend_hack = no
  	ascend_channels_per_line = 23
  	with_ntdomain_hack = no
  	with_specialix_jetstream_hack = no
  	with_cisco_vsa_hack = no
  	with_alvarion_vsa_hack = no
  }
  # Loaded module rlm_files
  # Loading module "files" from file /etc/freeradius/3.0/mods-enabled/files
  files {
  	filename = "/etc/freeradius/3.0/mods-config/files/authorize"
  	acctusersfile = "/etc/freeradius/3.0/mods-config/files/accounting"
  	preproxy_usersfile = "/etc/freeradius/3.0/mods-config/files/pre-proxy"
  }
  # Loaded module rlm_linelog
  # Loading module "linelog" from file /etc/freeradius/3.0/mods-enabled/linelog
  linelog {
  	filename = "/var/log/freeradius/linelog"
  	escape_filenames = no
  	syslog_severity = "info"
  	permissions = 384
  	format = "This is a log message for %{User-Name}"
  	reference = "messages.%{%{reply:Packet-Type}:-default}"
  }
  # Loading module "log_accounting" from file /etc/freeradius/3.0/mods-enabled/linelog
  linelog log_accounting {
  	filename = "/var/log/freeradius/linelog-accounting"
  	escape_filenames = no
  	syslog_severity = "info"
  	permissions = 384
  	format = ""
  	reference = "Accounting-Request.%{%{Acct-Status-Type}:-unknown}"
  }
  # Loading module "radutmp" from file /etc/freeradius/3.0/mods-enabled/radutmp
  radutmp {
  	filename = "/var/log/freeradius/radutmp"
  	username = "%{User-Name}"
  	case_sensitive = yes
  	check_with_nas = yes
  	permissions = 384
  	caller_id = yes
  }
/etc/freeradius/3.0/mods-enabled/python3[9]: Failed to link to module 'rlm_python3': /usr/lib/freeradius/rlm_python3.so: undefined symbol: PyTuple_Type

Relevant log output from client utilities

No response

Backtrace from LLDB or GDB

No response

panlinux avatar Mar 23 '22 22:03 panlinux

When I run autoreconf in that directory, the code to get the python version is changed like this:

-  am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"`
+  am_cv_python_version=`$PYTHON -c "import sys; print ('%u.%u' % sys.version_info[:2])"`

So this depends on whatever autoconf version was installed when configure was generated I guess.

panlinux avatar Mar 23 '22 22:03 panlinux

Afaict, this is caused by src/modules//rlm_python3/configure having been generated with old AM_PATH_PYTHON.

I am wondering how this was generated BTW, the makefile system does have any hook for re-generating the subdirectory ./configure scripts.

ametzler avatar Apr 18 '22 16:04 ametzler

I am wondering how this was generated BTW, the makefile system does have any hook for re-generating the subdirectory ./configure scripts.

Correct, it looks like configure and others from the modules directories are only re-generated when somebody thinks of it, and then whatever is on the developer's environment is used.

panlinux avatar Apr 18 '22 17:04 panlinux

makefile system does have any hook for re-generating the subdirectory ./configure scripts.

It's there. It's not just there in each subdirectory. All of the make rules are handled at the top:

$ make reconfigure

That's it.

alandekok avatar Apr 18 '22 18:04 alandekok

@alandekok wrote

makefile system does have any hook for re-generating the subdirectory ./configure scripts.

It's there. It's not just there in each subdirectory. All of the make rules are handled at the top:

$ make reconfigure

That's it.

You seem to be looking at a different source code than I do.

(sid)ametzler@argenau:/tmp/FREE/freeradius-server-3.0.25$ make reconfigure
make: *** No rule to make target 'reconfigure'.  Stop.
(sid)ametzler@argenau:/tmp/FREE/freeradius-server-3.0.25$ date ; ls src/modules/
rlm_python3/configure -l
Tue Apr 19 05:07:41 UTC 2022
-rwxrwxr-x 1 ametzler ametzler 134684 Oct  7  2021 src/modules/rlm_python3/configure
(sid)ametzler@argenau:/tmp/FREE/freeradius-server-3.0.25$ grep -rl reconfigure
share/dictionary.zyxel
src/modules/rlm_always/rlm_always.c
raddb/sites-available/dhcp
doc/rfc/rfc6614.txt
doc/rfc/rfc6930.txt
doc/antora/modules/howto/pages/protocols/proxy/enable_proxy_protocol.adoc
.github/workflows/ci.yml

ametzler avatar Apr 19 '22 05:04 ametzler

try make reconfig

alandekok avatar Apr 19 '22 18:04 alandekok

try make reconfig

It does not work though:

(sid)ametzler@argenau:/tmp/FREE/freeradius-server-3.0.25$ date ; ls -l src/modules/rlm_python3/configure configure
Tue Apr 19 19:09:28 UTC 2022
-rwxrwxr-x 1 ametzler ametzler 403693 Oct  7  2021 configure
-rwxrwxr-x 1 ametzler ametzler 134684 Oct  7  2021 src/modules/rlm_python3/configure
(sid)ametzler@argenau:/tmp/FREE/freeradius-server-3.0.25$ make reconfig
make: Nothing to be done for 'reconfig'.

Okay, so lets force things:

(sid)ametzler@argenau:/tmp/FREE/freeradius-server-3.0.25$ find -name configure -delete
(sid)ametzler@argenau:/tmp/FREE/freeradius-server-3.0.25$ make reconfig
[...]
AUTOCONF src/modules/rlm_python3/
cd src/modules/rlm_python3/ && /bin/sh /tmp/FREE/freeradius-server-3.0.25/missing autoconf -I /tmp/FREE/freeradius-server-3.0.25 -I /tmp/FREE/freeradius-server-3.0.25/m4 -I /tmp/FREE/freeradius-server-3.0.25/src/modules/rlm_python3/m4
[... warnings ...]
configure.ac:112: warning: AC_OUTPUT should be used without arguments.
configure.ac:112: You should run autoupdate.
configure.ac:13: error: possibly undefined macro: AM_PATH_PYTHON
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
make: *** [src/modules/all.mk:25: src/modules/rlm_python3/configure] Error 1

Afaict the python configure script would need aclocal to be run. However that does seem what the authors had in mind, since the usages of m4_include() break aclocal invocation, -I statements have no effect for these with aclocal, but e.g. ax_with_prog.m4 is not present directly in src/modules/rlm_ruby/ but in the m4 subdirectory.

ametzler avatar Apr 19 '22 19:04 ametzler

Fixed

mcnewton avatar Sep 28 '22 23:09 mcnewton