Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
496186f5
Commit
496186f5
authored
Jul 30, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
makes ssh plugin resilient against invalid entries in hosts file
fixes #10238
parent
e3490043
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
lib/ansible/plugins/connections/ssh.py
+16
-14
No files found.
lib/ansible/plugins/connections/ssh.py
View file @
496186f5
...
...
@@ -243,21 +243,23 @@ class Connection(ConnectionBase):
tokens
=
line
.
split
()
if
not
tokens
:
continue
if
tokens
[
0
]
.
find
(
self
.
HASHED_KEY_MAGIC
)
==
0
:
# this is a hashed known host entry
try
:
(
kn_salt
,
kn_host
)
=
tokens
[
0
][
len
(
self
.
HASHED_KEY_MAGIC
):]
.
split
(
"|"
,
2
)
hash
=
hmac
.
new
(
kn_salt
.
decode
(
'base64'
),
digestmod
=
sha1
)
hash
.
update
(
host
)
if
hash
.
digest
()
==
kn_host
.
decode
(
'base64'
):
if
isinstance
(
tokens
,
list
)
and
tokens
:
# skip invalid hostlines
if
tokens
[
0
]
.
find
(
self
.
HASHED_KEY_MAGIC
)
==
0
:
# this is a hashed known host entry
try
:
(
kn_salt
,
kn_host
)
=
tokens
[
0
][
len
(
self
.
HASHED_KEY_MAGIC
):]
.
split
(
"|"
,
2
)
hash
=
hmac
.
new
(
kn_salt
.
decode
(
'base64'
),
digestmod
=
sha1
)
hash
.
update
(
host
)
if
hash
.
digest
()
==
kn_host
.
decode
(
'base64'
):
return
False
except
:
# invalid hashed host key, skip it
continue
else
:
# standard host file entry
if
host
in
tokens
[
0
]:
return
False
except
:
# invalid hashed host key, skip it
continue
else
:
# standard host file entry
if
host
in
tokens
[
0
]:
return
False
if
(
hfiles_not_found
==
len
(
host_file_list
)):
self
.
_display
.
vvv
(
"EXEC previous known host file not found for {0}"
.
format
(
host
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment