from k5test import *
from queue import Empty
-from io import StringIO
+import io
import struct
try:
class RadiusDaemon(Process):
MAX_PACKET_SIZE = 4096
- DICTIONARY = dictionary.Dictionary(StringIO.StringIO(radius_attributes))
+ DICTIONARY = dictionary.Dictionary(io.StringIO(radius_attributes))
def listen(self, addr):
raise NotImplementedError()
def run(self):
addr = self._args[0]
- secr = self._args[1]
+ secrfile = self._args[1]
pswd = self._args[2]
outq = self._args[3]
- if secr:
- with open(secr) as file:
+ if secrfile:
+ with open(secrfile, 'rb') as file:
secr = file.read().strip()
+ else:
+ secr = b''
data = self.listen(addr)
outq.put("started")
passwd = []
for key in pkt.keys():
if key == 'User-Password':
- passwd = map(pkt.PwDecrypt, pkt[key])
+ passwd = list(map(pkt.PwDecrypt, pkt[key]))
elif key == 'User-Name':
usernm = pkt[key]
sock.close()
os.remove(addr)
- buf = ""
+ buf = b''
remain = RadiusDaemon.MAX_PACKET_SIZE
while True:
buf += conn.recv(remain)
# https://github.com/wichert/pyrad/pull/18
try:
auth = packet.Packet.CreateAuthenticator()
- packet.Packet(authenticator=auth, secret="").ReplyPacket()
+ packet.Packet(authenticator=auth, secret=b'').ReplyPacket()
except AssertionError:
skip_rest('OTP UNIX domain socket tests', 'pyrad assertion bug detected')
## Test Unix fail / custom username
mark('Unix socket fail / custom username')
-daemon = UnixRadiusDaemon(args=(socket_file, '', 'accept', queue))
+daemon = UnixRadiusDaemon(args=(socket_file, None, 'accept', queue))
daemon.start()
queue.get()
realm.run([kadminl, 'setstr', realm.user_princ, 'otp',
## Test Unix success / standard username
mark('Unix socket success / standard username')
-daemon = UnixRadiusDaemon(args=(socket_file, '', 'accept', queue))
+daemon = UnixRadiusDaemon(args=(socket_file, None, 'accept', queue))
daemon.start()
queue.get()
realm.run([kadminl, 'setstr', realm.user_princ, 'otp', otpconfig('unix')])
## accepting. With the bug, the KDC incorrectly rejects the request
## and then performs invalid memory accesses, most likely crashing.
daemon1 = UDPRadiusDaemon(args=(server_addr, secret_file, 'accept1', queue))
-daemon2 = UnixRadiusDaemon(args=(socket_file, '', 'accept2', queue))
+daemon2 = UnixRadiusDaemon(args=(socket_file, None, 'accept2', queue))
daemon1.start()
queue.get()
daemon2.start()
# Skip this test if we're missing proxy functionality or parts of the proxy.
if runenv.tls_impl == 'no':
skip_rest('HTTP proxy tests', 'TLS build support not enabled')
-try:
- from paste import httpserver
-except:
- skip_rest('HTTP proxy tests', 'Python paste module not found')
try:
import kdcproxy
except:
def start_proxy(realm, keycertpem):
proxy_conf_path = os.path.join(realm.testdir, 'kdcproxy.conf')
- proxy_exec_path = os.path.join(srctop, 'util', 'paste-kdcproxy.py')
+ proxy_exec_path = os.path.join(srctop, 'util', 'wsgiref-kdcproxy.py')
conf = open(proxy_conf_path, 'w')
conf.write('[%s]\n' % realm.realm)
conf.write('kerberos = kerberos://localhost:%d\n' % realm.portbase)