>  Probably better to do something like:
> 
> for algo in _available_checksums:
>  try:
>    hashlist.new(algo)
>  except: # remove it......
> 
> on bootup

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
_______________________________________________
Yum-devel mailing list
Yum-devel@lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to