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