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
7fba952a
Commit
7fba952a
authored
Mar 16, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slight changes to allow for checksum and other commands to work correctly with quoting
parent
103dc018
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
14 deletions
+12
-14
lib/ansible/runner/connection_plugins/ssh.py
+8
-10
lib/ansible/utils/__init__.py
+4
-4
No files found.
lib/ansible/runner/connection_plugins/ssh.py
View file @
7fba952a
...
@@ -306,7 +306,7 @@ class Connection(object):
...
@@ -306,7 +306,7 @@ class Connection(object):
no_prompt_out
=
''
no_prompt_out
=
''
no_prompt_err
=
''
no_prompt_err
=
''
if
s
elf
.
runner
.
become
and
sudoabl
e
and
self
.
runner
.
become_pass
:
if
s
udoable
and
self
.
runner
.
becom
e
and
self
.
runner
.
become_pass
:
# several cases are handled for escalated privileges with password
# several cases are handled for escalated privileges with password
# * NOPASSWD (tty & no-tty): detect success_key on stdout
# * NOPASSWD (tty & no-tty): detect success_key on stdout
# * without NOPASSWD:
# * without NOPASSWD:
...
@@ -319,11 +319,10 @@ class Connection(object):
...
@@ -319,11 +319,10 @@ class Connection(object):
become_output
=
''
become_output
=
''
become_errput
=
''
become_errput
=
''
while
success_key
not
in
become_output
:
while
True
:
if
success_key
in
become_output
or
\
if
prompt
and
become_output
.
endswith
(
prompt
):
(
prompt
and
become_output
.
endswith
(
prompt
))
or
\
break
utils
.
su_prompts
.
check_su_prompt
(
become_output
):
if
utils
.
su_prompts
.
check_su_prompt
(
become_output
):
break
break
rfd
,
wfd
,
efd
=
select
.
select
([
p
.
stdout
,
p
.
stderr
],
[],
rfd
,
wfd
,
efd
=
select
.
select
([
p
.
stdout
,
p
.
stderr
],
[],
...
@@ -351,12 +350,11 @@ class Connection(object):
...
@@ -351,12 +350,11 @@ class Connection(object):
stdout
=
p
.
communicate
()
stdout
=
p
.
communicate
()
raise
errors
.
AnsibleError
(
'ssh connection error while waiting for
%
s password prompt'
%
self
.
runner
.
become_method
)
raise
errors
.
AnsibleError
(
'ssh connection error while waiting for
%
s password prompt'
%
self
.
runner
.
become_method
)
if
success_key
not
in
become_output
:
if
success_key
in
become_output
:
if
sudoable
:
stdin
.
write
(
self
.
runner
.
become_pass
+
'
\n
'
)
else
:
no_prompt_out
+=
become_output
no_prompt_out
+=
become_output
no_prompt_err
+=
become_errput
no_prompt_err
+=
become_errput
elif
sudoable
:
stdin
.
write
(
self
.
runner
.
become_pass
+
'
\n
'
)
(
returncode
,
stdout
,
stderr
)
=
self
.
_communicate
(
p
,
stdin
,
in_data
,
sudoable
=
sudoable
,
prompt
=
prompt
)
(
returncode
,
stdout
,
stderr
)
=
self
.
_communicate
(
p
,
stdin
,
in_data
,
sudoable
=
sudoable
,
prompt
=
prompt
)
...
...
lib/ansible/utils/__init__.py
View file @
7fba952a
...
@@ -1241,8 +1241,8 @@ def make_become_cmd(cmd, user, shell, method, flags=None, exe=None):
...
@@ -1241,8 +1241,8 @@ def make_become_cmd(cmd, user, shell, method, flags=None, exe=None):
# sudo prompt set with the -p option.
# sudo prompt set with the -p option.
prompt
=
'[sudo via ansible, key=
%
s] password: '
%
randbits
prompt
=
'[sudo via ansible, key=
%
s] password: '
%
randbits
exe
=
exe
or
C
.
DEFAULT_SUDO_EXE
exe
=
exe
or
C
.
DEFAULT_SUDO_EXE
becomecmd
=
'
%
s -k &&
%
s
%
s -S -p "
%
s" -u
%
s
%
s -c
"
%
s"
'
%
\
becomecmd
=
'
%
s -k &&
%
s
%
s -S -p "
%
s" -u
%
s
%
s -c
%
s
'
%
\
(
exe
,
exe
,
flags
or
C
.
DEFAULT_SUDO_FLAGS
,
prompt
,
user
,
shell
,
'echo
%
s;
%
s'
%
(
success_key
,
cmd
))
(
exe
,
exe
,
flags
or
C
.
DEFAULT_SUDO_FLAGS
,
prompt
,
user
,
shell
,
pipes
.
quote
(
'echo
%
s;
%
s'
%
(
success_key
,
cmd
)
))
elif
method
==
'su'
:
elif
method
==
'su'
:
exe
=
exe
or
C
.
DEFAULT_SU_EXE
exe
=
exe
or
C
.
DEFAULT_SU_EXE
...
@@ -1252,13 +1252,13 @@ def make_become_cmd(cmd, user, shell, method, flags=None, exe=None):
...
@@ -1252,13 +1252,13 @@ def make_become_cmd(cmd, user, shell, method, flags=None, exe=None):
elif
method
==
'pbrun'
:
elif
method
==
'pbrun'
:
exe
=
exe
or
'pbrun'
exe
=
exe
or
'pbrun'
flags
=
flags
or
''
flags
=
flags
or
''
becomecmd
=
'
%
s -b -l
%
s -u
%
s "
%
s"'
%
(
exe
,
flags
,
user
,
'echo
%
s;
%
s'
%
(
success_key
,
cmd
))
becomecmd
=
'
%
s -b -l
%
s -u
%
s "
%
s"'
%
(
exe
,
flags
,
user
,
pipes
.
quote
(
'echo
%
s;
%
s'
%
(
success_key
,
cmd
)
))
elif
method
==
'pfexec'
:
elif
method
==
'pfexec'
:
exe
=
exe
or
'pfexec'
exe
=
exe
or
'pfexec'
flags
=
flags
or
''
flags
=
flags
or
''
# No user as it uses it's own exec_attr to figure it out
# No user as it uses it's own exec_attr to figure it out
becomecmd
=
'
%
s
%
s "
%
s"'
%
(
exe
,
flags
,
'echo
%
s;
%
s'
%
(
success_key
,
cmd
))
becomecmd
=
'
%
s
%
s "
%
s"'
%
(
exe
,
flags
,
pipes
.
quote
(
'echo
%
s;
%
s'
%
(
success_key
,
cmd
)
))
if
becomecmd
is
None
:
if
becomecmd
is
None
:
raise
errors
.
AnsibleError
(
"Privilege escalation method not found:
%
s"
%
method
)
raise
errors
.
AnsibleError
(
"Privilege escalation method not found:
%
s"
%
method
)
...
...
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