summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2020-11-09 14:00:43 +0100
committerAndreas Schneider <asn@cryptomilk.org>2024-10-10 14:01:04 +0000
commit444f9c6624f5c997dfdc4ae0bfb8823a56fbef70 (patch)
tree44f97670a8086caa182eeb56397b28fbcca0fa03 /python
parent0acbbeab4db0c8bc8ff655d652e249fecb3c4ef9 (diff)
downloadsamba-444f9c6624f5c997dfdc4ae0bfb8823a56fbef70.tar.gz
samba-444f9c6624f5c997dfdc4ae0bfb8823a56fbef70.tar.bz2
samba-444f9c6624f5c997dfdc4ae0bfb8823a56fbef70.zip
RawDCERPCTest: split prepare_pdu() and send_pdu_blob() out of send_pdu()
This will make it possible to alter pdus before sending them to the server. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14356 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/dcerpc/raw_testcase.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/python/samba/tests/dcerpc/raw_testcase.py b/python/samba/tests/dcerpc/raw_testcase.py
index c2871909abc..aaf063c2179 100644
--- a/python/samba/tests/dcerpc/raw_testcase.py
+++ b/python/samba/tests/dcerpc/raw_testcase.py
@@ -677,34 +677,45 @@ class RawDCERPCTest(TestCase):
self.secondary_address = None
self.connect()
- def send_pdu(self, req, ndr_print=None, hexdump=None):
+ def prepare_pdu(self, req, ndr_print=None, hexdump=None):
if ndr_print is None:
ndr_print = self.do_ndr_print
if hexdump is None:
hexdump = self.do_hexdump
+ req_pdu = ndr_pack(req)
+ if ndr_print:
+ sys.stderr.write("prepare_pdu: %s" % samba.ndr.ndr_print(req))
+ if hexdump:
+ sys.stderr.write("prepare_pdu: %d\n%s" % (len(req_pdu), self.hexdump(req_pdu)))
+ return req_pdu
+
+ def send_pdu_blob(self, req_pdu, hexdump=None):
+ if hexdump is None:
+ hexdump = self.do_hexdump
try:
- req_pdu = ndr_pack(req)
- if ndr_print:
- sys.stderr.write("send_pdu: %s" % samba.ndr.ndr_print(req))
if hexdump:
- sys.stderr.write("send_pdu: %d\n%s" % (len(req_pdu), self.hexdump(req_pdu)))
+ sys.stderr.write("send_pdu_blob: %d\n%s" % (len(req_pdu), self.hexdump(req_pdu)))
while True:
sent = self.s.send(req_pdu, 0)
if sent == len(req_pdu):
break
req_pdu = req_pdu[sent:]
except socket.error as e:
- self._disconnect("send_pdu: %s" % e)
+ self._disconnect("send_pdu_blob: %s" % e)
raise
except IOError as e:
- self._disconnect("send_pdu: %s" % e)
+ self._disconnect("send_pdu_blob: %s" % e)
raise
except NTSTATUSError as e:
- self._disconnect("send_pdu: %s" % e)
+ self._disconnect("send_pdu_blob: %s" % e)
raise
finally:
pass
+ def send_pdu(self, req, ndr_print=None, hexdump=None):
+ req_pdu = self.prepare_pdu(req, ndr_print=ndr_print, hexdump=False)
+ return self.send_pdu_blob(req_pdu, hexdump=hexdump)
+
def recv_raw(self, hexdump=None, timeout=None):
rep_pdu = None
if hexdump is None: