diff options
author | Brian C. Lane <bcl@redhat.com> | 2012-08-21 13:26:46 -0700 |
---|---|---|
committer | Brian C. Lane <bcl@redhat.com> | 2012-08-21 13:31:18 -0700 |
commit | 7da36e86a19b823521bfa91b564fd6423c3ebd62 (patch) | |
tree | e68a7a7fc5622cc3f521d88546a32e73abfde351 /pyanaconda/packaging | |
parent | e7acf84236e2afedc747e48f87b271ef02cc6e3e (diff) | |
download | anaconda-7da36e86a19b823521bfa91b564fd6423c3ebd62.tar.gz anaconda-7da36e86a19b823521bfa91b564fd6423c3ebd62.tar.xz anaconda-7da36e86a19b823521bfa91b564fd6423c3ebd62.zip |
verify package checksums against metadata
Anaconda uses yum's getPackage() function to grab packages. It needs to
have a function passed to it in order to verify the package checksum
against the metadata.
Diffstat (limited to 'pyanaconda/packaging')
-rw-r--r-- | pyanaconda/packaging/yumpayload.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py index 89c1ddb31..28f728da4 100644 --- a/pyanaconda/packaging/yumpayload.py +++ b/pyanaconda/packaging/yumpayload.py @@ -1291,7 +1291,18 @@ class RPMCallback(object): while self.package_file is None: try: - package_path = repo.getPackage(txmbr.po) + # checkfunc gets passed to yum's use of URLGrabber which + # then calls it with the file being fetched. verifyPkg + # makes sure the checksum matches the one in the metadata. + # + # From the URLGrab documents: + # checkfunc=(function, ('arg1', 2), {'kwarg': 3}) + # results in a callback like: + # function(obj, 'arg1', 2, kwarg=3) + # obj.filename = '/tmp/stuff' + # obj.url = 'http://foo.com/stuff' + checkfunc = (self._yum.verifyPkg, (txmbr.po, 1), {}) + package_path = repo.getPackage(txmbr.po, checkfunc=checkfunc) except (yum.Errors.NoMoreMirrorsRepoError, IOError): if os.path.exists(txmbr.po.localPkg()): os.unlink(txmbr.po.localPkg()) @@ -1302,6 +1313,11 @@ class RPMCallback(object): raise exn except yum.Errors.RepoError: continue + except URLGrabError as e: + log.error("URLGrabError: %s" % (e,)) + exn = PayloadInstallError("failed to get package") + if errorHandler.cb(exn, txmbr.po) == ERROR_RAISE: + raise exn self.package_file = open(package_path) |