mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-02-11 02:07:37 -08:00
152 lines
4.6 KiB
Diff
152 lines
4.6 KiB
Diff
From 58168139adcaa4bf12448904137cd77812636b18 Mon Sep 17 00:00:00 2001
|
|
From: Ron Frederick <ronf@timeheart.net>
|
|
Date: Sat, 23 Dec 2023 10:25:14 -0800
|
|
Subject: [PATCH] Guard against possible UNIX domain socket cleanup in Python
|
|
3.13
|
|
|
|
This commit adds guards around code which cleans up UNIX domain
|
|
sockets, to protect against a change proposed at
|
|
https://github.com/python/cpython/issues/111246
|
|
which would cause the socket to clean itself up on close.
|
|
---
|
|
tests/test_agent.py | 5 ++++-
|
|
tests/test_forward.py | 50 +++++++++++++++++++++++++++++++++----------
|
|
2 files changed, 43 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/tests/test_agent.py b/tests/test_agent.py
|
|
index 28ca730..2f0b83c 100644
|
|
--- a/tests/test_agent.py
|
|
+++ b/tests/test_agent.py
|
|
@@ -85,7 +85,10 @@ async def stop(self):
|
|
self._server.close()
|
|
await self._server.wait_closed()
|
|
|
|
- os.remove(self._path)
|
|
+ try:
|
|
+ os.remove(self._path)
|
|
+ except OSError:
|
|
+ pass
|
|
|
|
|
|
class _TestAgent(AsyncTestCase):
|
|
diff --git a/tests/test_forward.py b/tests/test_forward.py
|
|
index cae199d..4d30eda 100644
|
|
--- a/tests/test_forward.py
|
|
+++ b/tests/test_forward.py
|
|
@@ -651,7 +651,10 @@ async def test_forward_local_path_to_port(self):
|
|
async with conn.forward_local_path_to_port('local', '', 7):
|
|
await self._check_local_unix_connection('local')
|
|
|
|
- os.remove('local')
|
|
+ try:
|
|
+ os.remove('local')
|
|
+ except OSError:
|
|
+ pass
|
|
|
|
@unittest.skipIf(sys.platform == 'win32',
|
|
'skip UNIX domain socket tests on Windows')
|
|
@@ -665,7 +668,10 @@ async def test_forward_local_path_to_port_failure(self):
|
|
with self.assertRaises(OSError):
|
|
await conn.forward_local_path_to_port('local', '', 7)
|
|
|
|
- os.remove('local')
|
|
+ try:
|
|
+ os.remove('local')
|
|
+ except OSError:
|
|
+ pass
|
|
|
|
@asynctest
|
|
async def test_forward_local_port_pause(self):
|
|
@@ -798,7 +804,11 @@ async def test_forward_remote_port_to_path(self):
|
|
|
|
server.close()
|
|
await server.wait_closed()
|
|
- os.remove('local')
|
|
+
|
|
+ try:
|
|
+ os.remove('local')
|
|
+ except OSError:
|
|
+ pass
|
|
|
|
@asynctest
|
|
async def test_forward_remote_specific_port(self):
|
|
@@ -1020,7 +1030,10 @@ async def test_unix_server(self):
|
|
await listener.wait_closed()
|
|
listener.close()
|
|
|
|
- os.remove('echo')
|
|
+ try:
|
|
+ os.remove('echo')
|
|
+ except OSError:
|
|
+ pass
|
|
|
|
@asynctest
|
|
async def test_unix_server_open(self):
|
|
@@ -1053,7 +1066,10 @@ async def test_unix_server_non_async(self):
|
|
async with conn.start_unix_server(_unix_listener_non_async, path):
|
|
await self._check_local_unix_connection('echo')
|
|
|
|
- os.remove('echo')
|
|
+ try:
|
|
+ os.remove('echo')
|
|
+ except OSError:
|
|
+ pass
|
|
|
|
@asynctest
|
|
async def test_unix_server_failure(self):
|
|
@@ -1071,7 +1087,10 @@ async def test_forward_local_path(self):
|
|
async with conn.forward_local_path('local', '/echo'):
|
|
await self._check_local_unix_connection('local')
|
|
|
|
- os.remove('local')
|
|
+ try:
|
|
+ os.remove('local')
|
|
+ except OSError:
|
|
+ pass
|
|
|
|
@asynctest
|
|
async def test_forward_local_port_to_path_accept_handler(self):
|
|
@@ -1149,8 +1168,11 @@ async def test_forward_remote_path(self):
|
|
server.close()
|
|
await server.wait_closed()
|
|
|
|
- os.remove('echo')
|
|
- os.remove('local')
|
|
+ try:
|
|
+ os.remove('echo')
|
|
+ os.remove('local')
|
|
+ except OSError:
|
|
+ pass
|
|
|
|
@asynctest
|
|
async def test_forward_remote_path_to_port(self):
|
|
@@ -1167,11 +1189,14 @@ async def test_forward_remote_path_to_port(self):
|
|
path, '127.0.0.1', server_port):
|
|
await self._check_local_unix_connection('echo')
|
|
|
|
- os.remove('echo')
|
|
-
|
|
server.close()
|
|
await server.wait_closed()
|
|
|
|
+ try:
|
|
+ os.remove('echo')
|
|
+ except OSError:
|
|
+ pass
|
|
+
|
|
@asynctest
|
|
async def test_forward_remote_path_failure(self):
|
|
"""Test failure of forwarding a remote UNIX domain path"""
|
|
@@ -1184,7 +1209,10 @@ async def test_forward_remote_path_failure(self):
|
|
with self.assertRaises(asyncssh.ChannelListenError):
|
|
await conn.forward_remote_path(path, 'local')
|
|
|
|
- os.remove('echo')
|
|
+ try:
|
|
+ os.remove('echo')
|
|
+ except OSError:
|
|
+ pass
|
|
|
|
@asynctest
|
|
async def test_forward_remote_path_not_permitted(self):
|