From d00ecdce359c8bc3d3520aef58d5808c7d15020b Mon Sep 17 00:00:00 2001 From: Pavel Balaev Date: Wed, 20 Mar 2024 17:35:54 +0300 Subject: process: make has_ipv6 a public function Signed-off-by: Pavel Balaev Signed-off-by: Sam James --- lib/portage/process.py | 8 ++++---- lib/portage/tests/process/test_unshare_net.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/portage/process.py b/lib/portage/process.py index 1bc0c507c..6e4e0d716 100644 --- a/lib/portage/process.py +++ b/lib/portage/process.py @@ -631,8 +631,8 @@ def spawn( fd_pipes[1] = pw fd_pipes[2] = pw - # Cache _has_ipv6() result for use in child processes. - _has_ipv6() + # Cache has_ipv6() result for use in child processes. + has_ipv6() # This caches the libc library lookup and _unshare_validator results # in the current process, so that results are cached for use in @@ -751,7 +751,7 @@ def spawn( __has_ipv6 = None -def _has_ipv6(): +def has_ipv6(): """ Test that both userland and kernel support IPv6, by attempting to create a socket and listen on any unused port of the IPv6 @@ -812,7 +812,7 @@ def _configure_loopback_interface(): ifindex = rtnl.get_link_ifindex(b"lo") rtnl.set_link_up(ifindex) rtnl.add_address(ifindex, socket.AF_INET, "10.0.0.1", 8) - if _has_ipv6(): + if has_ipv6(): rtnl.add_address(ifindex, socket.AF_INET6, "fd::1", 8) except OSError as e: writemsg( diff --git a/lib/portage/tests/process/test_unshare_net.py b/lib/portage/tests/process/test_unshare_net.py index ad3b288ef..56d96da05 100644 --- a/lib/portage/tests/process/test_unshare_net.py +++ b/lib/portage/tests/process/test_unshare_net.py @@ -42,7 +42,7 @@ class UnshareNetTestCase(TestCase): f"Unable to unshare: {errno.errorcode.get(self.ABILITY_TO_UNSHARE, '?')}" ) env = os.environ.copy() - env["IPV6"] = "1" if portage.process._has_ipv6() else "" + env["IPV6"] = "1" if portage.process.has_ipv6() else "" self.assertEqual( portage.process.spawn( [BASH_BINARY, "-c", UNSHARE_NET_TEST_SCRIPT], unshare_net=True, env=env -- cgit v1.2.3-65-gdbad