Merge pull request #35040 from rallytime/py3-ssh-module-decode

Py3: Use b64decode instead of decode on str objects
This commit is contained in:
Mike Place 2016-08-01 11:13:18 -06:00 committed by GitHub
commit 99f82040f3

View File

@ -20,6 +20,7 @@ import re
import subprocess
# Import salt libs
import salt.ext.six as six
import salt.utils
import salt.utils.files
import salt.utils.decorators as decorators
@ -32,6 +33,9 @@ from salt.ext.six.moves import range
log = logging.getLogger(__name__)
DEFAULT_SSH_PORT = 22
if six.PY3:
import base64
def __virtual__():
# TODO: This could work on windows with some love
@ -234,7 +238,10 @@ def _fingerprint(public_key):
If the key is invalid (incorrect base64 string), return None
'''
try:
raw_key = public_key.decode('base64')
if six.PY2:
raw_key = public_key.decode('base64')
else:
raw_key = base64.b64decode(public_key, validate=True) # pylint: disable=E1123
except binascii.Error:
return None
ret = hashlib.md5(raw_key).hexdigest()