mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix authorized_key crash in Python3 with remote key file (#20037)
* Decode downloaded keys bytes if Python3 * Fixes #20007 * Thanks @georgepsarakis
This commit is contained in:
parent
b8ee80ac4e
commit
fafe5bba59
1 changed files with 4 additions and 0 deletions
|
@ -227,6 +227,7 @@ import re
|
|||
import shlex
|
||||
from operator import itemgetter
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
|
@ -537,6 +538,9 @@ def enforce_state(module, params):
|
|||
except Exception:
|
||||
module.fail_json(msg=error_msg % key)
|
||||
|
||||
# resp.read gives bytes on python3, convert to native string type
|
||||
key = to_native(key, errors='surrogate_or_strict')
|
||||
|
||||
# extract individual keys into an array, skipping blank lines and comments
|
||||
new_keys = [s for s in key.splitlines() if s and not s.startswith('#')]
|
||||
|
||||
|
|
Loading…
Reference in a new issue