commit:     a671334b7c7b64bc779f1c2bfb4ed659d97c0d19
Author:     Pavel Balaev <mail <AT> void <DOT> so>
AuthorDate: Mon Mar 18 11:29:34 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun May 26 23:27:08 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a671334b

sync: don't use ipv6 for rsync when it's disabled

socket.has_ipv6 gives a false result:

$ sysctl net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.all.disable_ipv6 = 1
$ python
Python 3.11.8 (main, Feb 24 2024, 17:10:38) [GCC 13.2.1 20240210] on linux
>>> import socket
>>> socket.has_ipv6
True

This patch uses the portage.process.has_ipv6() function,
which returns the correct result.

Bug: https://bugs.gentoo.org/927241
Signed-off-by: Pavel Balaev <mail <AT> void.so>
Closes: https://github.com/gentoo/portage/pull/1309
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/rsync/rsync.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/portage/sync/modules/rsync/rsync.py 
b/lib/portage/sync/modules/rsync/rsync.py
index 15c3eb4da5..e89221ebc9 100644
--- a/lib/portage/sync/modules/rsync/rsync.py
+++ b/lib/portage/sync/modules/rsync/rsync.py
@@ -19,6 +19,7 @@ from portage import _unicode_decode
 from portage import os
 from portage.const import VCS_DIRS, TIMESTAMP_FORMAT, RSYNC_PACKAGE_ATOM
 from portage.output import create_color_func, yellow, blue, bold
+from portage.process import has_ipv6
 from portage.sync.getaddrinfo_validate import getaddrinfo_validate
 from portage.sync.syncbase import NewBase
 from portage.util import writemsg, writemsg_level, writemsg_stdout
@@ -252,9 +253,7 @@ class RsyncSync(NewBase):
             family = socket.AF_UNSPEC
             if "-4" in all_rsync_opts or "--ipv4" in all_rsync_opts:
                 family = socket.AF_INET
-            elif socket.has_ipv6 and (
-                "-6" in all_rsync_opts or "--ipv6" in all_rsync_opts
-            ):
+            elif has_ipv6() and ("-6" in all_rsync_opts or "--ipv6" in 
all_rsync_opts):
                 family = socket.AF_INET6
 
             addrinfos = None
@@ -278,7 +277,7 @@ class RsyncSync(NewBase):
             if addrinfos:
                 AF_INET = socket.AF_INET
                 AF_INET6 = None
-                if socket.has_ipv6:
+                if has_ipv6():
                     AF_INET6 = socket.AF_INET6
 
                 ips_v4 = []

Reply via email to