action_sync: handle IPv6 [ip] in SYNC some more
authorZac Medico <zmedico@gentoo.org>
Fri, 25 Feb 2011 06:29:31 +0000 (22:29 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 25 Feb 2011 06:29:31 +0000 (22:29 -0800)
This will fix bug #356375 some more.

pym/_emerge/actions.py

index 1b3b18157dd3cc2a1644ba68482cd1550de296b3..20220fc57d0f1280a38e17683b47f2bebb926488 100644 (file)
@@ -2088,13 +2088,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(
@@ -2113,7 +2123,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(