[issue25541] Wrong usage of sockaddr_un struct for abstract namespace unix sockets
anthony shaw
report at bugs.python.org
Thu May 9 04:04:33 EDT 2019
anthony shaw <anthonyshaw at apache.org> added the comment:
The existing tests in place add the null-termination bytes in the test string:
def testLinuxAbstractNamespace(self):
address = b"\x00python-test-hello\x00\xff"
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s1:
s1.bind(address)
s1.listen()
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s2:
s2.connect(s1.getsockname())
with s1.accept()[0] as s3:
self.assertEqual(s1.getsockname(), address)
self.assertEqual(s2.getpeername(), address)
So that answers your initial question, it does work, but you have to add the null termination bytes in the address string.
This isn't documented, so the documentation needs fixing.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue25541>
_______________________________________
More information about the Python-bugs-list
mailing list