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
1ce1c52f
Commit
1ce1c52f
authored
Jun 15, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
centralized bad password handling, fixed outputing of become method
parent
b89071e4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
7 deletions
+5
-7
lib/ansible/plugins/connections/__init__.py
+2
-1
lib/ansible/plugins/connections/ssh.py
+3
-6
No files found.
lib/ansible/plugins/connections/__init__.py
View file @
1ce1c52f
...
...
@@ -130,5 +130,6 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
def
check_incorrect_password
(
self
,
output
,
prompt
):
incorrect_password
=
gettext
.
dgettext
(
self
.
_connection_info
.
become_method
,
C
.
BECOME_ERROR_STRINGS
[
self
.
_connection_info
.
become_method
])
return
output
.
endswith
(
incorrect_password
)
if
output
.
endswith
(
incorrect_password
):
raise
AnsibleError
(
'Incorrect
%
s password'
%
self
.
_connection_info
.
become_method
)
lib/ansible/plugins/connections/ssh.py
View file @
1ce1c52f
...
...
@@ -174,9 +174,7 @@ class Connection(ConnectionBase):
# fail early if the become password is wrong
if
self
.
_connection_info
.
become
and
sudoable
:
if
self
.
_connection_info
.
become_pass
:
if
self
.
check_incorrect_password
(
stdout
,
prompt
):
raise
AnsibleError
(
'Incorrect
%
s password'
,
self
.
_connection_info
.
become_method
)
self
.
check_incorrect_password
(
stdout
,
prompt
)
elif
self
.
check_password_prompt
(
stdout
,
prompt
):
raise
AnsibleError
(
'Missing
%
s password'
,
self
.
_connection_info
.
become_method
)
...
...
@@ -324,7 +322,7 @@ class Connection(ConnectionBase):
while
True
:
if
self
.
check_become_success
(
become_output
,
success_key
)
or
\
self
.
check_password_prompt
(
become_output
,
prompt
):
self
.
check_password_prompt
(
become_output
,
prompt
):
break
rfd
,
wfd
,
efd
=
select
.
select
([
p
.
stdout
,
p
.
stderr
],
[],
[
p
.
stdout
],
self
.
_connection_info
.
timeout
)
if
p
.
stderr
in
rfd
:
...
...
@@ -333,8 +331,7 @@ class Connection(ConnectionBase):
raise
AnsibleError
(
'ssh connection closed waiting for privilege escalation password prompt'
)
become_errput
+=
chunk
if
self
.
check_incorrect_password
(
become_errput
,
prompt
):
raise
AnsibleError
(
'Incorrect
%
s password'
,
self
.
_connection_info
.
become_method
)
self
.
check_incorrect_password
(
become_errput
,
prompt
)
if
p
.
stdout
in
rfd
:
chunk
=
p
.
stdout
.
read
()
...
...
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