mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-40121: Fixes audit event raised on creating a new socket (GH-19238)
This commit is contained in:
parent
ef67512b40
commit
63ba5cccf4
4 changed files with 39 additions and 3 deletions
|
@ -327,6 +327,28 @@ def test_winreg():
|
|||
CloseKey(kv)
|
||||
|
||||
|
||||
def test_socket():
|
||||
import socket
|
||||
|
||||
def hook(event, args):
|
||||
if event.startswith("socket."):
|
||||
print(event, *args)
|
||||
|
||||
sys.addaudithook(hook)
|
||||
|
||||
socket.gethostname()
|
||||
|
||||
# Don't care if this fails, we just want the audit message
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
# Don't care if this fails, we just want the audit message
|
||||
sock.bind(('127.0.0.1', 8080))
|
||||
except error:
|
||||
pass
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from test.libregrtest.setup import suppress_msvcrt_asserts
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue