Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) When binding a unix socket to an empty address on Linux, the socket is automatically bound to an available address in the abstract namespace. >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.bind("") >>> s.getsockname() b'\x0075499' Since python 3.9, the socket is bound to the one address: >>> s.getsockname() b'\x00' And trying to bind multiple sockets will fail with: Traceback (most recent call last): File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind s2.bind("") OSError: [Errno 98] Address already in use Added 2 tests: - Auto binding empty address on Linux - Failing to bind an empty address on other platforms Fixes f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866) (cherry picked from commit c22f134) Co-authored-by: Nir Soffer <nsoffer@redhat.com>
- Loading branch information
1 parent
eff4aa5
commit cd0a59f
Showing
3 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Library/2022-07-14-00-43-52.gh-issue-94821.e17ghU.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix binding of unix socket to empty address on Linux to use an available | ||
address from the abstract namespace, instead of "\0". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters