apt_key: Validate key_id and accept a leading '0x'

pull/4544/head
Maykel Moya 11 years ago
parent afa781d628
commit 1a79d9ae58

@ -76,8 +76,8 @@ EXAMPLES = '''
# Remove an Apt signing key, uses whichever key is at the URL # Remove an Apt signing key, uses whichever key is at the URL
- apt_key: url=https://ftp-master.debian.org/keys/archive-key-6.0.asc state=absent - apt_key: url=https://ftp-master.debian.org/keys/archive-key-6.0.asc state=absent
# Remove a Apt specific signing key # Remove a Apt specific signing key, leading 0x is valid
- apt_key: id=473041FA state=absent - apt_key: id=0x473041FA state=absent
# Add a key from a file on the Ansible server # Add a key from a file on the Ansible server
- apt_key: data="{{ lookup('file', 'apt.gpg') }}" state=present - apt_key: data="{{ lookup('file', 'apt.gpg') }}" state=present
@ -188,6 +188,12 @@ def main():
state = module.params['state'] state = module.params['state']
changed = False changed = False
try:
_ = int(key_id, 16)
key_id = key_id.lstrip('0x')
except ValueError:
module.fail_json("Invalid key_id")
# FIXME: I think we have a common facility for this, if not, want # FIXME: I think we have a common facility for this, if not, want
check_missing_binaries(module) check_missing_binaries(module)

Loading…
Cancel
Save