[yum-commits] yum/misc.py yum/yumRepo.py

zpavlas at osuosl.org zpavlas at osuosl.org
Mon Jun 24 10:34:16 UTC 2013


 yum/misc.py    |   16 ++++++++++++++--
 yum/yumRepo.py |    3 +++
 2 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 7f8f7e2fbc127cd50e938307adf32b51e1c8f96c
Author: Zdenek Pavlas <zpavlas at redhat.com>
Date:   Wed Jun 19 14:06:32 2013 +0200

    Check for bad checksum types at runtime. BZ 902357

diff --git a/yum/misc.py b/yum/misc.py
index e51bdc5..ca00b3c 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -40,13 +40,11 @@ except ImportError:
 try:
     import hashlib
     _available_checksums = set(['md5', 'sha1', 'sha256', 'sha384', 'sha512'])
-    _default_checksums = ['sha256']
 except ImportError:
     # Python-2.4.z ... gah!
     import sha
     import md5
     _available_checksums = set(['md5', 'sha1'])
-    _default_checksums = ['sha1']
     class hashlib:
 
         @staticmethod
@@ -57,6 +55,20 @@ except ImportError:
                 return sha.new()
             raise ValueError, "Bad checksum type"
 
+# some checksum types might be disabled
+for ctype in list(_available_checksums):
+    try:
+        hashlib.new(ctype)
+    except:
+        print >> sys.stderr, 'Checksum type %s disabled' % repr(ctype)
+        _available_checksums.remove(ctype)
+for ctype in 'sha256', 'sha1':
+    if ctype in _available_checksums:
+        _default_checksums = [ctype]
+        break
+else:
+    raise ImportError, 'broken hashlib'
+
 from Errors import MiscError
 # These are API things, so we can't remove them even if they aren't used here.
 # pylint: disable-msg=W0611
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index cfe7b05..242ed66 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -638,6 +638,9 @@ class YumRepository(Repository, config.RepoConf):
                 if tries <= self.retries - len(self.urls):
                     # don't remove this mirror yet
                     action['remove'] = False
+            elif e.errno == -3:
+                # unsupported checksum type, fail now
+                action['fail'] = True
 
             # No known user of this callback, but just in case...
             cb = self.mirror_failure_obj


More information about the Yum-commits mailing list