From fe71c29eb3c0bd67886482c3cd394945e0b373e9 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 24 Feb 2011 22:29:31 -0800 Subject: [PATCH] action_sync: handle IPv6 [ip] in SYNC some more This will fix bug #356375 some more. --- pym/_emerge/actions.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 471adb310..ea8fc42fc 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -2067,13 +2067,23 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): maxretries = -1 #default number of retries retries=0 - proto, user_name, hostname, port = re.split( - r"(rsync|ssh)://([^:/]+@)?(\[[:\da-fA-F]*\]|[^:/]*)(:[0-9]+)?", - syncuri, maxsplit=4)[1:5] + try: + proto, user_name, hostname, port = re.split( + r"(rsync|ssh)://([^:/]+@)?(\[[:\da-fA-F]*\]|[^:/]*)(:[0-9]+)?", + syncuri, maxsplit=4)[1:5] + except ValueError: + writemsg_level("!!! SYNC is invalid: %s\n" % syncuri, + noiselevel=-1, level=logging.ERROR) + return 1 if port is None: port="" if user_name is None: user_name="" + if re.match(r"^\[[:\da-fA-F]*\]$", hostname) is None: + getaddrinfo_host = hostname + else: + # getaddrinfo needs the brackets stripped + getaddrinfo_host = hostname[1:-1] updatecache_flg=True all_rsync_opts = set(rsync_opts) extra_rsync_opts = portage.util.shlex_split( @@ -2092,7 +2102,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): try: addrinfos = getaddrinfo_validate( - socket.getaddrinfo(hostname, None, + socket.getaddrinfo(getaddrinfo_host, None, family, socket.SOCK_STREAM)) except socket.error as e: writemsg_level( -- 2.26.2