fixed ssh fix, bad test case but it should work now
This commit is contained in:
parent
219332bdae
commit
22ef830814
1 changed files with 5 additions and 5 deletions
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
|
import errno
|
||||||
|
|
||||||
from ansible import utils
|
from ansible import utils
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
|
@ -36,15 +37,14 @@ class Connector(object):
|
||||||
raise AnsibleError("unsupported connection type: %s" % transport)
|
raise AnsibleError("unsupported connection type: %s" % transport)
|
||||||
if private_key_file:
|
if private_key_file:
|
||||||
# If private key is readable by user other than owner, flag an error
|
# If private key is readable by user other than owner, flag an error
|
||||||
|
st = None
|
||||||
try:
|
try:
|
||||||
st = os.stat(private_key_file)
|
st = os.stat(private_key_file)
|
||||||
except IOError, e:
|
except (IOError, OSError), e:
|
||||||
if e.errno == errno.ENOENT: # file is missing, might be agent
|
if e.errno != errno.ENOENT: # file is missing, might be agent
|
||||||
st = { 'st_mode': False }
|
|
||||||
else:
|
|
||||||
raise(e)
|
raise(e)
|
||||||
|
|
||||||
if st.st_mode & (stat.S_IRGRP | stat.S_IROTH):
|
if st is not None and st.st_mode & (stat.S_IRGRP | stat.S_IROTH):
|
||||||
raise AnsibleError("private_key_file (%s) is group-readable or world-readable and thus insecure - "
|
raise AnsibleError("private_key_file (%s) is group-readable or world-readable and thus insecure - "
|
||||||
"you will probably get an SSH failure"
|
"you will probably get an SSH failure"
|
||||||
% (private_key_file,))
|
% (private_key_file,))
|
||||||
|
|
Loading…
Reference in a new issue