Gentoo Archives: gentoo-commits

From: "Christian Ruppert (idl0r)" <idl0r@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-portage/mirrorselect/files: 0002-Check-for-a-valid-mirrorselect-test-file.patch
Date: Sun, 01 Aug 2010 21:02:48
Message-Id: 20100801201224.B1FE42CE15@corvid.gentoo.org
1 idl0r 10/08/01 20:12:24
2
3 Added: 0002-Check-for-a-valid-mirrorselect-test-file.patch
4 Log:
5 Check for a valid mirrorselect-test file, fixes bug 330611, thanks to Soren Harward <stharward@×××××.com>.
6 (Portage version: 2.2_rc67/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 app-portage/mirrorselect/files/0002-Check-for-a-valid-mirrorselect-test-file.patch
10
11 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-portage/mirrorselect/files/0002-Check-for-a-valid-mirrorselect-test-file.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-portage/mirrorselect/files/0002-Check-for-a-valid-mirrorselect-test-file.patch?rev=1.1&content-type=text/plain
13
14 Index: 0002-Check-for-a-valid-mirrorselect-test-file.patch
15 ===================================================================
16 From 88521c86907819486e0e18bffcb1674ae180341e Mon Sep 17 00:00:00 2001
17 From: Christian Ruppert <idl0r@g.o>
18 Date: Sun, 1 Aug 2010 21:35:11 +0200
19 Subject: [PATCH] Check for a valid mirrorselect-test file, fixes bug 330611, thanks to Soren Harward <stharward@×××××.com>.
20
21 ---
22 main.py | 17 +++++++----------
23 1 files changed, 7 insertions(+), 10 deletions(-)
24
25 diff --git a/main.py b/main.py
26 index dd3386e..f5f35be 100755
27 --- a/main.py
28 +++ b/main.py
29 @@ -36,6 +36,7 @@ import sys
30 import time
31 import urllib
32 import urlparse
33 +import hashlib
34 from optparse import IndentedHelpFormatter, OptionParser
35 from mirrorselect.mirrorparser3 import MirrorParser3, MIRRORS_3_XML, MIRRORS_RSYNC_DATA
36 import codecs
37 @@ -336,8 +337,6 @@ class Shallow(object):
38 class Deep(object):
39 """handles deep mode mirror selection."""
40
41 - _bufsize = 4096
42 -
43 def __init__(self, hosts, options):
44 self.urls = []
45 self._hosts = hosts
46 @@ -457,10 +456,9 @@ class Deep(object):
47
48 for ip in ips:
49 try:
50 - ip_url = url.replace(url_parts.hostname, ip, 1)
51 try:
52 signal.alarm(self._connect_timeout)
53 - f = urllib.urlopen(ip_url)
54 + f = urllib.urlopen(url)
55 break
56 finally:
57 signal.alarm(0)
58 @@ -480,14 +478,12 @@ class Deep(object):
59 return (None, True)
60
61 try:
62 -
63 # Close the initial "wake up" connection.
64 try:
65 signal.alarm(self._connect_timeout)
66 f.close()
67 finally:
68 signal.alarm(0)
69 -
70 except EnvironmentError, e:
71 output.write(('deeptime(): close connection to host %s ' + \
72 'failed for ip %s: %s\n') % \
73 @@ -498,16 +494,17 @@ class Deep(object):
74 (url_parts.hostname, ip), 2)
75
76 try:
77 -
78 # The first connection serves to "wake up" the route between
79 # the local and remote machines. A second connection is used
80 # for the timed run.
81 try:
82 signal.alarm(int(math.ceil(maxtime)))
83 stime = time.time()
84 - f = urllib.urlopen(ip_url)
85 - while f.read(self._bufsize):
86 - pass
87 + f = urllib.urlopen(url)
88 +
89 + if hashlib.md5(f.read()).hexdigest() != "bdf077b2e683c506bf9e8f2494eeb044":
90 + return (None, True)
91 +
92 delta = time.time() - stime
93 f.close()
94 finally:
95 --
96 1.7.1