New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_url checksum does not support checksum files containing *just* the checksum #54390
Comments
Files identified in the description: If these files are inaccurate, please update the |
I think I would consider this a feature request. In any case, for now you can do the following:
|
@sivel OK. In the meantime it would be great if the docs could specify exactly what the expected format of the checksum file should be - this one had me scratching my head for a while as I just assumed this would be supported. Many thanks for the workaround in the interim. |
I've had a few minutes to play with a solution, but haven't tested it extensively. diff --git a/lib/ansible/modules/net_tools/basics/get_url.py b/lib/ansible/modules/net_tools/basics/get_url.py
index ea033d9cfe..d25ae0c39c 100644
--- a/lib/ansible/modules/net_tools/basics/get_url.py
+++ b/lib/ansible/modules/net_tools/basics/get_url.py
@@ -495,12 +495,19 @@ def main():
with open(checksum_tmpsrc) as f:
lines = [line.rstrip('\n') for line in f]
os.remove(checksum_tmpsrc)
- checksum_map = {}
- for line in lines:
- parts = line.split(None, 1)
- if len(parts) == 2:
- checksum_map[parts[0]] = parts[1]
filename = url_filename(url)
+ checksum_map = {}
+ if len(lines) == 1 and len(lines[0].split()) == 1:
+ # Only a single line with a single string
+ # treat it as a checksum only file
+ checksum_map[lines[0]] = filename
+ else:
+ # The assumption here is the file is in the format of
+ # filename checksum
+ for line in lines:
+ parts = line.split(None, 1)
+ if len(parts) == 2:
+ checksum_map[parts[0]] = parts[1]
# Look through each line in the checksum file for a hash corresponding to
# the filename in the url, returning the first hash that is found. If anyone wants to take that patch, and get together a PR with a changelog fragment, and tests, please feel free to do so. I am not actively pursuing this further. |
Files identified in the description: If these files are incorrect, please update the |
Attempt to fix issue where `get_url` doesn't properly read a checksum value out of a checksum file: ansible/ansible#54390
* Fix checksum validation Attempt to fix issue where `get_url` doesn't properly read a checksum value out of a checksum file: ansible/ansible#54390
It would be great if the module's documentation would specify the format the checksum file needs to be in, and if one could have more than one checkum in one file, for a number of algorithms or files. So far, I tried "xxxxx" (the sha256sum checksum), "xxxxx filename", "sha256:xxxxx" and also "SHA256:xxxxx filename", all without success. |
checksum can also accept a checksum only file (no filename beside the checksum). fixes ansible#54390
checksum can also accept a checksum only file (no filename beside the checksum). fixes #54390 Co-authored-by: Baptiste Mille-Mathias <baptiste.millemathias@gmail.com>
SUMMARY
get_url fails to parse a checksum file when the file contains just the checksum
ISSUE TYPE
COMPONENT NAME
get_url
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
For easy reference, the contents of the checksum file is as follows:
EXPECTED RESULTS
get_url should be able to obtain the checksum from a file containing just the checksum.
At present get_url is able to handle the more complex case of parsing out the correct checksum from a file containing multiple checksums.
With the example shown above, there is no need to parse out the correct checksum. Here the checksum makes up the entirety of the file contents and all that is needed is to simply read the file.
ping @sivel as this was worked on recently in #53685
ACTUAL RESULTS
get_url fails and returns the following error
The text was updated successfully, but these errors were encountered: