|
|
ecbd30 |
From bdba7b54224814055185513de1e7ff6619031553 Mon Sep 17 00:00:00 2001
|
|
|
ecbd30 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
ecbd30 |
Date: Thu, 15 Mar 2018 13:21:40 +0100
|
|
|
ecbd30 |
Subject: [PATCH 1/2] tests/http_pipe.py: migrate to Python 3
|
|
|
ecbd30 |
|
|
|
ecbd30 |
---
|
|
|
ecbd30 |
tests/http_pipe.py | 4 ++--
|
|
|
ecbd30 |
tests/runtests.pl | 2 +-
|
|
|
ecbd30 |
2 files changed, 3 insertions(+), 3 deletions(-)
|
|
|
ecbd30 |
|
|
|
ecbd30 |
diff --git a/tests/http_pipe.py b/tests/http_pipe.py
|
|
|
ecbd30 |
index bc32173..75ac165 100755
|
|
|
ecbd30 |
--- a/tests/http_pipe.py
|
|
|
ecbd30 |
+++ b/tests/http_pipe.py
|
|
|
ecbd30 |
@@ -383,13 +383,13 @@ class PipelineRequestHandler(socketserver.BaseRequestHandler):
|
|
|
ecbd30 |
self.request.setblocking(True)
|
|
|
ecbd30 |
if not new_data:
|
|
|
ecbd30 |
return
|
|
|
ecbd30 |
- new_requests = self._request_parser.ParseAdditionalData(new_data)
|
|
|
ecbd30 |
+ new_requests = self._request_parser.ParseAdditionalData(new_data.decode('utf8'))
|
|
|
ecbd30 |
self._response_builder.QueueRequests(
|
|
|
ecbd30 |
new_requests, self._request_parser.were_all_requests_http_1_1)
|
|
|
ecbd30 |
self._num_queued += len(new_requests)
|
|
|
ecbd30 |
self._last_queued_time = time.time()
|
|
|
ecbd30 |
elif fileno in wlist:
|
|
|
ecbd30 |
- num_bytes_sent = self.request.send(self._send_buffer[0:4096])
|
|
|
ecbd30 |
+ num_bytes_sent = self.request.send(self._send_buffer[0:4096].encode('utf8'))
|
|
|
ecbd30 |
self._send_buffer = self._send_buffer[num_bytes_sent:]
|
|
|
ecbd30 |
time.sleep(0.05)
|
|
|
ecbd30 |
|
|
|
ecbd30 |
diff --git a/tests/runtests.pl b/tests/runtests.pl
|
|
|
ecbd30 |
index d6aa5ca..4d395ef 100755
|
|
|
ecbd30 |
--- a/tests/runtests.pl
|
|
|
ecbd30 |
+++ b/tests/runtests.pl
|
|
|
ecbd30 |
@@ -1439,7 +1439,7 @@ sub runhttpserver {
|
|
|
ecbd30 |
elsif($alt eq "pipe") {
|
|
|
ecbd30 |
# basically the same, but another ID
|
|
|
ecbd30 |
$idnum = 3;
|
|
|
ecbd30 |
- $exe = "python $srcdir/http_pipe.py";
|
|
|
ecbd30 |
+ $exe = "python3 $srcdir/http_pipe.py";
|
|
|
ecbd30 |
$verbose_flag .= "1 ";
|
|
|
ecbd30 |
}
|
|
|
ecbd30 |
elsif($alt eq "unix") {
|
|
|
ecbd30 |
--
|
|
|
ecbd30 |
2.14.3
|
|
|
ecbd30 |
|
|
|
ecbd30 |
|
|
|
ecbd30 |
From 3c4c7340e455b7256c0786759422f34ec3e2d440 Mon Sep 17 00:00:00 2001
|
|
|
ecbd30 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
ecbd30 |
Date: Thu, 15 Mar 2018 14:49:56 +0100
|
|
|
ecbd30 |
Subject: [PATCH 2/2] tests/{negtelnet,smb}server.py: migrate to Python 3
|
|
|
ecbd30 |
|
|
|
ecbd30 |
Unfortunately, smbserver.py does not work with Python 3 because
|
|
|
ecbd30 |
there is no 'impacket' module available for Python 3:
|
|
|
ecbd30 |
|
|
|
ecbd30 |
https://github.com/CoreSecurity/impacket/issues/61
|
|
|
ecbd30 |
---
|
|
|
ecbd30 |
tests/negtelnetserver.py | 12 ++++++------
|
|
|
ecbd30 |
tests/smbserver.py | 4 ++--
|
|
|
ecbd30 |
2 files changed, 8 insertions(+), 8 deletions(-)
|
|
|
ecbd30 |
|
|
|
ecbd30 |
diff --git a/tests/negtelnetserver.py b/tests/negtelnetserver.py
|
|
|
ecbd30 |
index 8cfd409..72ee771 100755
|
|
|
ecbd30 |
--- a/tests/negtelnetserver.py
|
|
|
ecbd30 |
+++ b/tests/negtelnetserver.py
|
|
|
ecbd30 |
@@ -23,7 +23,7 @@ IDENT = "NTEL"
|
|
|
ecbd30 |
|
|
|
ecbd30 |
# The strings that indicate the test framework is checking our aliveness
|
|
|
ecbd30 |
VERIFIED_REQ = b"verifiedserver"
|
|
|
ecbd30 |
-VERIFIED_RSP = b"WE ROOLZ: {pid}"
|
|
|
ecbd30 |
+VERIFIED_RSP = "WE ROOLZ: {pid}"
|
|
|
ecbd30 |
|
|
|
ecbd30 |
|
|
|
ecbd30 |
def telnetserver(options):
|
|
|
ecbd30 |
@@ -34,7 +34,7 @@ def telnetserver(options):
|
|
|
ecbd30 |
if options.pidfile:
|
|
|
ecbd30 |
pid = os.getpid()
|
|
|
ecbd30 |
with open(options.pidfile, "w") as f:
|
|
|
ecbd30 |
- f.write(b"{0}".format(pid))
|
|
|
ecbd30 |
+ f.write("{0}".format(pid))
|
|
|
ecbd30 |
|
|
|
ecbd30 |
local_bind = (HOST, options.port)
|
|
|
ecbd30 |
log.info("Listening on %s", local_bind)
|
|
|
ecbd30 |
@@ -73,11 +73,11 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
|
|
|
ecbd30 |
response_data = VERIFIED_RSP.format(pid=os.getpid())
|
|
|
ecbd30 |
else:
|
|
|
ecbd30 |
log.debug("Received normal request - echoing back")
|
|
|
ecbd30 |
- response_data = data.strip()
|
|
|
ecbd30 |
+ response_data = data.decode('utf8').strip()
|
|
|
ecbd30 |
|
|
|
ecbd30 |
if response_data:
|
|
|
ecbd30 |
log.debug("Sending %r", response_data)
|
|
|
ecbd30 |
- self.request.sendall(response_data)
|
|
|
ecbd30 |
+ self.request.sendall(response_data.encode('utf8'))
|
|
|
ecbd30 |
|
|
|
ecbd30 |
except IOError:
|
|
|
ecbd30 |
log.exception("IOError hit during request")
|
|
|
ecbd30 |
@@ -132,7 +132,7 @@ class Negotiator(object):
|
|
|
ecbd30 |
return buffer
|
|
|
ecbd30 |
|
|
|
ecbd30 |
def byte_to_int(self, byte):
|
|
|
ecbd30 |
- return struct.unpack(b'B', byte)[0]
|
|
|
ecbd30 |
+ return int(byte)
|
|
|
ecbd30 |
|
|
|
ecbd30 |
def no_neg(self, byte, byte_int, buffer):
|
|
|
ecbd30 |
# Not negotiating anything thus far. Check to see if we
|
|
|
ecbd30 |
@@ -197,7 +197,7 @@ class Negotiator(object):
|
|
|
ecbd30 |
self.tcp.sendall(packed_message)
|
|
|
ecbd30 |
|
|
|
ecbd30 |
def pack(self, arr):
|
|
|
ecbd30 |
- return struct.pack(b'{0}B'.format(len(arr)), *arr)
|
|
|
ecbd30 |
+ return struct.pack('{0}B'.format(len(arr)), *arr)
|
|
|
ecbd30 |
|
|
|
ecbd30 |
def send_iac(self, arr):
|
|
|
ecbd30 |
message = [NegTokens.IAC]
|
|
|
ecbd30 |
diff --git a/tests/smbserver.py b/tests/smbserver.py
|
|
|
ecbd30 |
index 195ae39..b09cd44 100755
|
|
|
ecbd30 |
--- a/tests/smbserver.py
|
|
|
ecbd30 |
+++ b/tests/smbserver.py
|
|
|
ecbd30 |
@@ -24,7 +24,7 @@
|
|
|
ecbd30 |
from __future__ import (absolute_import, division, print_function)
|
|
|
ecbd30 |
# unicode_literals)
|
|
|
ecbd30 |
import argparse
|
|
|
ecbd30 |
-import ConfigParser
|
|
|
ecbd30 |
+import configparser
|
|
|
ecbd30 |
import os
|
|
|
ecbd30 |
import sys
|
|
|
ecbd30 |
import logging
|
|
|
ecbd30 |
@@ -58,7 +58,7 @@ def smbserver(options):
|
|
|
ecbd30 |
f.write("{0}".format(pid))
|
|
|
ecbd30 |
|
|
|
ecbd30 |
# Here we write a mini config for the server
|
|
|
ecbd30 |
- smb_config = ConfigParser.ConfigParser()
|
|
|
ecbd30 |
+ smb_config = configparser.ConfigParser()
|
|
|
ecbd30 |
smb_config.add_section("global")
|
|
|
ecbd30 |
smb_config.set("global", "server_name", "SERVICE")
|
|
|
ecbd30 |
smb_config.set("global", "server_os", "UNIX")
|
|
|
ecbd30 |
--
|
|
|
ecbd30 |
2.14.3
|
|
|
ecbd30 |
|