diff --git a/vm/kojikamid b/vm/kojikamid index b62906d0..58599d69 100755 --- a/vm/kojikamid +++ b/vm/kojikamid @@ -380,11 +380,14 @@ class WindowsBuild(object): def fetchFile(self, basedir, buildinfo, fileinfo, type=None): """Download the file from buildreq, at filepath, into the basedir""" - destpath = os.path.join(basedir, fileinfo['relpath'], fileinfo['filename']) + if type == 'win': + destpath = os.path.join(basedir, fileinfo['relpath'], fileinfo['filename']) + else: + raise BuildError, 'unsupported file type: %s' % type ensuredir(os.path.dirname(destpath)) destfile = file(destpath, 'w') offset = 0 - checksum = hashlib.sha1() + checksum = hashlib.md5() while True: encoded = self.server.getFile(buildinfo, fileinfo, encode_int(offset), 1048576, type) if not encoded: @@ -396,8 +399,10 @@ class WindowsBuild(object): checksum.update(data) destfile.close() digest = checksum.hexdigest() - self.server.verifyBuildReq(buildinfo, fileinfo, type, digest, 'sha1') - self.logger.info('Retrieved %s (%s bytes, sha1: %s)', destpath, offset, digest) + if digest != fileinfo['md5sum']: + raise BuildError, 'md5 checksum validation failed for %s, %s (computed) != %s (provided)' % \ + (destpath, digest, fileinfo['md5sum']) + self.logger.info('Retrieved %s (%s bytes, md5sum: %s)', destpath, offset, digest) def fetchBuildReqs(self): """Retrieve buildrequires listed in the spec file""" diff --git a/vm/kojivmd b/vm/kojivmd index c60da603..2d9f5d48 100755 --- a/vm/kojivmd +++ b/vm/kojivmd @@ -520,15 +520,6 @@ class VMExecTask(BaseTaskHandler): finally: fileobj.close() - def verifyBuildReq(self, buildinfo, archiveinfo, type, checksum, algo='sha1'): - """ - Verify the checksum of a build requirement. The in-VM daemon calls this - method to verify that the file it has downloaded is valid. - """ - fileobj = self.localCache(buildinfo, archiveinfo, type) - fileobj.close() - return self.verifyChecksum(fileobj.name, checksum, algo) - def upload(self, path, offset, contents): local_path = os.path.abspath(os.path.join(self.output_dir, path)) if not local_path.startswith(self.output_dir): @@ -562,12 +553,8 @@ class VMExecTask(BaseTaskHandler): md5sum, offset, data) def verifyChecksum(self, path, checksum, algo='sha1'): - if path.startswith('/'): - # Only happens when called by verifyBuildReq() - local_path = os.path.abspath(path) - else: - local_path = os.path.abspath(os.path.join(self.output_dir, path)) - if not local_path.startswith(self.workdir): + local_path = os.path.abspath(os.path.join(self.output_dir, path)) + if not local_path.startswith(self.output_dir): raise koji.BuildError, 'invalid path: %s' % path if not os.path.isfile(local_path): raise koji.BuildError, '%s does not exist' % local_path @@ -614,7 +601,6 @@ class VMExecTask(BaseTaskHandler): self.server.register_function(self.getLatestBuild) self.server.register_function(self.getFileList) self.server.register_function(self.getFile) - self.server.register_function(self.verifyBuildReq) self.server.register_function(self.upload) self.server.register_function(self.uploadDirect) self.server.register_function(self.verifyChecksum)