From bf6a52c9368d0d04167a84635e8dd0bf49fe23a1 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Nov 08 2022 22:12:03 +0000 Subject: [PATCH 1/2] kojivmd: check for HTTP errors in getFile() kojivmd proxies files from Koji's topurl through the getFile() RPC. In some cases (misconfigurations), kojivmd can fail to download files from topurl. Prior to this change, if kojivmd failed to download a file (for example, a 404 error), it would silently cache the 404 error HTTP body contents and pass those on to verifyChecksum(). As a result, kojivmd would verify the checksum of an HTML error page, rather than checksuming the intended Koji archive file. In this scenario, it's difficult for administrators to diagnose why checksums are not matching. Check the HTTP response for errors before doing anything with the response contents. With this change, winbuild tasks will fail with an easier-to-understand "HTTP 404 not found" HTTPError, rather than a Koji BuildError about checksums. --- diff --git a/vm/kojivmd b/vm/kojivmd index 0642c9c..0853bf5 100755 --- a/vm/kojivmd +++ b/vm/kojivmd @@ -715,6 +715,7 @@ class VMExecTask(BaseTaskHandler): koji.ensuredir(os.path.dirname(localpath)) # closing needs to be used for requests < 2.18.0 with closing(requests.get(remote_url, stream=True)) as response: + response.raise_for_status() with open(localpath, 'wb') as f: for chunk in response.iter_content(chunk_size=65536): f.write(chunk) From e0682ac810cc117930da115eaf6231a87f2026e6 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Nov 08 2022 22:23:02 +0000 Subject: [PATCH 2/2] kojivmd: update example topurl The usual name for this location is "kojifiles", not "kojiroot". Update the example configuration to match what users will normally expect. --- diff --git a/vm/kojivmd.conf b/vm/kojivmd.conf index e6ae14f..bcf68da 100644 --- a/vm/kojivmd.conf +++ b/vm/kojivmd.conf @@ -15,7 +15,7 @@ ; workdir=/tmp/koji ; The url where the Koji root directory (/mnt/koji) can be accessed -topurl=http://koji.example.com/kojiroot +topurl=http://koji.example.com/kojifiles ; The URL for the xmlrpc server server=http://hub.example.com/kojihub