Merge pull request #9509 from bcoca/no_ssh_fail_missing_keyfile

added error handling on private key stat in case it is saved in agent
pull/9510/head
Brian Coca 10 years ago
commit 219332bdae

@ -36,7 +36,14 @@ class Connector(object):
raise AnsibleError("unsupported connection type: %s" % transport)
if private_key_file:
# If private key is readable by user other than owner, flag an error
st = os.stat(private_key_file)
try:
st = os.stat(private_key_file)
except IOError, e:
if e.errno == errno.ENOENT: # file is missing, might be agent
st = { 'st_mode': False }
else:
raise(e)
if st.st_mode & (stat.S_IRGRP | stat.S_IROTH):
raise AnsibleError("private_key_file (%s) is group-readable or world-readable and thus insecure - "
"you will probably get an SSH failure"

Loading…
Cancel
Save