Check http return code from license server

This change verifies that the HTTP returning code from license server is
a 200 otherwise any code returned by the server will be accepted as a
successful response and the returned error page will be interpreted as a
valid license hash.

Additonally this change narrows the exception emitted by pycurl perform
method from Exception to pycurl.error.

Signed-off-by: Alex Jaramillo <alex.v.jaramillo@intel.com>
This commit is contained in:
Alex Jaramillo
2018-11-01 10:33:28 -07:00
committed by William Douglas
parent 6a04257351
commit fdfded7916
+8 -4
View File
@@ -97,13 +97,17 @@ def license_from_copying_hash(copying, srcdir):
c.setopt(c.FOLLOWLOCATION, 1)
try:
c.perform()
except Exception as excep:
code = c.getinfo(pycurl.HTTP_CODE)
if code != 200:
print_fatal("Fetching license from {} returned {}"
.format(config.license_fetch, code))
exit(1)
except pycurl.error as excep:
print_fatal("Failed to fetch license from {}: {}"
.format(config.license_fetch, excep))
exit(1)
finally:
c.close()
sys.exit(1)
c.close()
response = buffer.getvalue()
page = response.decode('utf-8').strip()