Blame SOURCES/BZ-1287610-fips-dont-pollute-stderr.patch

d2a170
diff -up yum-3.4.3/yum/Errors.py.orig yum-3.4.3/yum/Errors.py
d2a170
--- yum-3.4.3/yum/Errors.py.orig	2017-09-14 18:42:26.740558383 +0200
d2a170
+++ yum-3.4.3/yum/Errors.py	2017-09-14 18:42:30.371541754 +0200
d2a170
@@ -99,6 +99,11 @@ class ConfigError(YumBaseError):
d2a170
 class MiscError(YumBaseError):
d2a170
     pass
d2a170
 
d2a170
+class FIPSNonCompliantError(MiscError):
d2a170
+    def __init__(self, sumtype):
d2a170
+        MiscError.__init__(
d2a170
+            self, '%s algorithm is not FIPS compliant' % sumtype)
d2a170
+
d2a170
 class GroupsError(YumBaseError):
d2a170
     pass
d2a170
 
d2a170
diff -up yum-3.4.3/yum/misc.py.orig yum-3.4.3/yum/misc.py
d2a170
--- yum-3.4.3/yum/misc.py.orig	2017-09-14 18:42:26.794558135 +0200
d2a170
+++ yum-3.4.3/yum/misc.py	2017-09-14 18:42:30.372541749 +0200
d2a170
@@ -58,11 +58,20 @@ except ImportError:
d2a170
             raise ValueError, "Bad checksum type"
d2a170
 
d2a170
 # some checksum types might be disabled
d2a170
+_fips_noncompliant = set()
d2a170
 for ctype in list(_available_checksums):
d2a170
     try:
d2a170
         hashlib.new(ctype)
d2a170
-    except:
d2a170
-        print >> sys.stderr, 'Checksum type %s disabled' % repr(ctype)
d2a170
+    except Exception as e:
d2a170
+        # Print an error unless this is due to FIPS mode (in which case it's
d2a170
+        # not really an error and we don't want to pollute the output
d2a170
+        # needlessly; if someone actually tries to instantiate a Checksum with
d2a170
+        # a FIPS non-compliant ctype, we'll raise an explanatory exception
d2a170
+        # anyway).
d2a170
+        if isinstance(e, ValueError) and str(e).endswith('disabled for fips'):
d2a170
+            _fips_noncompliant.add(ctype)
d2a170
+        else:
d2a170
+            print >> sys.stderr, 'Checksum type %s disabled' % repr(ctype)
d2a170
         _available_checksums.remove(ctype)
d2a170
 for ctype in 'sha256', 'sha1':
d2a170
     if ctype in _available_checksums:
d2a170
@@ -71,7 +80,7 @@ for ctype in 'sha256', 'sha1':
d2a170
 else:
d2a170
     raise ImportError, 'broken hashlib'
d2a170
 
d2a170
-from Errors import MiscError
d2a170
+from Errors import MiscError, FIPSNonCompliantError
d2a170
 # These are API things, so we can't remove them even if they aren't used here.
d2a170
 # pylint: disable-msg=W0611
d2a170
 from i18n import to_utf8, to_unicode
d2a170
@@ -271,6 +280,8 @@ class Checksums:
d2a170
                 sumalgo = hashlib.new(sumtype)
d2a170
             elif ignore_missing:
d2a170
                 continue
d2a170
+            elif sumtype in _fips_noncompliant:
d2a170
+                raise FIPSNonCompliantError(sumtype)
d2a170
             else:
d2a170
                 raise MiscError, 'Error Checksumming, bad checksum type %s' % sumtype
d2a170
             done.add(sumtype)
d2a170
diff -up yum-3.4.3/yum/yumRepo.py.orig yum-3.4.3/yum/yumRepo.py
d2a170
--- yum-3.4.3/yum/yumRepo.py.orig	2017-09-14 18:42:26.879557746 +0200
d2a170
+++ yum-3.4.3/yum/yumRepo.py	2017-09-14 18:43:23.422298802 +0200
d2a170
@@ -497,7 +497,10 @@ class YumRepository(Repository, config.R
d2a170
         except (Errors.MiscError, EnvironmentError), e:
d2a170
             if checksum_can_fail:
d2a170
                 return None
d2a170
-            raise Errors.RepoError, 'Error opening file for checksum: %s' % e
d2a170
+            msg = 'Error opening file for checksum: %s' % e
d2a170
+            if isinstance(e, Errors.FIPSNonCompliantError):
d2a170
+                msg = str(e)
d2a170
+            raise Errors.RepoError(msg)
d2a170
 
d2a170
     def dump(self):
d2a170
         output = '[%s]\n' % self.id
d2a170
@@ -1799,7 +1802,7 @@ Insufficient space in download directory
d2a170
         except Errors.RepoError, e:
d2a170
             if check_can_fail:
d2a170
                 return None
d2a170
-            raise URLGrabError(-3, 'Error performing checksum')
d2a170
+            raise URLGrabError(-3, 'Error performing checksum: %s' % e)
d2a170
 
d2a170
         if l_csum == r_csum:
d2a170
             _xattr_set_chksum(file, r_ctype, l_csum)