Skip to content

Commit 6d06678

Browse files
committed
Force "fork" method for RADIUS daemon in OTP test
The RADIUS daemon used in the OTP test relies on multiprocessing.Process. Since Python 3.14, multiprocessing changed its start method from "fork" to "forkserver". This method is not compatible with the t_otp.py test. This commit explicitly sets multiprocessing's start method to "fork" for test t_otp.py, using multiprocessing.set_start_method() (available since Python 3.4). Pull-request: krb5/krb5#1483
1 parent 4634ca1 commit 6d06678

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/tests/t_otp.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@
3838
except ImportError:
3939
skip_rest('OTP tests', 'Python pyrad module not found')
4040
try:
41-
from multiprocessing import Process, Queue
41+
import multiprocessing
4242
except ImportError:
4343
skip_rest('OTP tests', 'Python version 2.6 required')
4444

45+
# Since Python 3.14, "forkserver" replaces "fork" as default method on POSIX.
46+
# "forkserver" is not compatible with this test, so force the "fork" method.
47+
multiprocessing.set_start_method('fork', force=True)
48+
4549
# We could use a dictionary file, but since we need so few attributes,
4650
# we'll just include them here.
4751
radius_attributes = '''
@@ -52,7 +56,7 @@
5256
ATTRIBUTE Message-Authenticator 80 octets
5357
'''
5458

55-
class RadiusDaemon(Process):
59+
class RadiusDaemon(multiprocessing.Process):
5660
MAX_PACKET_SIZE = 4096
5761
DICTIONARY = dictionary.Dictionary(io.StringIO(radius_attributes))
5862

@@ -186,7 +190,7 @@ def otpconfig(toktype, username=None, indicators=None):
186190
'unix': {'server': socket_file,
187191
'strip_realm': 'false'}}}
188192

189-
queue = Queue()
193+
queue = multiprocessing.Queue()
190194

191195
realm = K5Realm(kdc_conf=conf)
192196
realm.run([kadminl, 'modprinc', '+requires_preauth', realm.user_princ])
@@ -259,7 +263,7 @@ def otpconfig(toktype, username=None, indicators=None):
259263
## tokens configured, with the first rejecting and the second
260264
## accepting. With the bug, the KDC incorrectly rejects the request
261265
## and then performs invalid memory accesses, most likely crashing.
262-
queue2 = Queue()
266+
queue2 = multiprocessing.Queue()
263267
daemon1 = UDPRadiusDaemon(args=(server_addr, secret_file, 'accept1', queue))
264268
daemon2 = UnixRadiusDaemon(args=(socket_file, None, 'accept2', queue2))
265269
daemon1.start()

0 commit comments

Comments
 (0)