summaryrefslogtreecommitdiff
path: root/lib/ansible/modules
diff options
context:
space:
mode:
authorAbhijeet Kasurde <akasurde@redhat.com>2021-07-09 22:08:16 +0530
committerGitHub <noreply@github.com>2021-07-09 11:38:16 -0500
commite0cb0671afe4b4256914260a33929ffa8dc7b5c1 (patch)
treea35a9d8168183aa9a2dad4e05d5b8ebab1df16f2 /lib/ansible/modules
parent9e5091ab5cf3b69e0c9c3c6b07e62e16aa2301a4 (diff)
downloadansible-e0cb0671afe4b4256914260a33929ffa8dc7b5c1.tar.gz
[bp-2.10] get_url - Allow checksum file to be local file:// (#75052)
This would be a partial solution for #69364 in that the SHASUMS file can be downloaded and gpg verified but then used from the downloaded location to verify the get_url's file. * Make checksum url parsing more explicit Use urlsplit to test if the checksum string has a (currently tested and) supported url scheme. (cherry picked from commit eb8b3a8479ec82ad622f86ac46f3e9cc083952b8) Co-authored-by: Edwin Hermans <edwin@madtech.cx>
Diffstat (limited to 'lib/ansible/modules')
-rw-r--r--lib/ansible/modules/get_url.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ansible/modules/get_url.py b/lib/ansible/modules/get_url.py
index 9036b35438..501704034e 100644
--- a/lib/ansible/modules/get_url.py
+++ b/lib/ansible/modules/get_url.py
@@ -416,6 +416,14 @@ def extract_filename_from_headers(headers):
return res
+def is_url(checksum):
+ """
+ Returns True if checksum value has supported URL scheme, else False."""
+ supported_schemes = ('http', 'https', 'ftp', 'file')
+
+ return urlsplit(checksum).scheme in supported_schemes
+
+
# ==============================================================
# main
@@ -487,7 +495,7 @@ def main():
except ValueError:
module.fail_json(msg="The checksum parameter has to be in format <algorithm>:<checksum>", **result)
- if checksum.startswith('http://') or checksum.startswith('https://') or checksum.startswith('ftp://'):
+ if is_url(checksum):
checksum_url = checksum
# download checksum file to checksum_tmpsrc
checksum_tmpsrc, checksum_info = url_get(module, checksum_url, dest, use_proxy, last_mod_time, force, timeout, headers, tmp_dest)