mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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 stat
|
||||
import errno
|
||||
|
||||
from ansible import utils
|
||||
from ansible.errors import AnsibleError
|
||||
|
@ -36,15 +37,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 = None
|
||||
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:
|
||||
except (IOError, OSError), e:
|
||||
if e.errno != errno.ENOENT: # file is missing, might be agent
|
||||
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 - "
|
||||
"you will probably get an SSH failure"
|
||||
% (private_key_file,))
|
||||
|
|
Loading…
Reference in a new issue