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
40f60353
Commit
40f60353
authored
Apr 27, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Unify normal and sudo remote command execution. Breaks stderr/stdout handling
This reverts commit
44486223
.
parent
e1611403
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
lib/ansible/connection.py
+14
-12
No files found.
lib/ansible/connection.py
View file @
40f60353
...
...
@@ -132,15 +132,9 @@ class ParamikoConnection(object):
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudoable
=
False
):
# pylint: disable-msg=W0613
''' run a command on the remote host '''
bufsize
=
4096
# Could make this a Runner param if needed
timeout_secs
=
self
.
runner
.
timeout
# Reusing runner's TCP connect timeout as command progress timeout
chan
=
self
.
ssh
.
get_transport
()
.
open_session
()
chan
.
settimeout
(
timeout_secs
)
chan
.
get_pty
()
# Many sudo setups require a terminal; use in both cases for consistency
if
not
self
.
runner
.
sudo
or
not
sudoable
:
quoted_command
=
'"$SHELL" -c '
+
pipes
.
quote
(
cmd
)
chan
.
exec_command
(
quoted_command
)
stdin
,
stdout
,
stderr
=
self
.
ssh
.
exec_command
(
cmd
)
return
(
stdin
,
stdout
,
stderr
)
else
:
# Rather than detect if sudo wants a password this time, -k makes
# sudo always ask for a password if one is required. The "--"
...
...
@@ -149,17 +143,25 @@ class ParamikoConnection(object):
# directly doesn't work, so we shellquote it with pipes.quote()
# and pass the quoted string to the user's shell.
sudocmd
=
'sudo -k -- "$SHELL" -c '
+
pipes
.
quote
(
cmd
)
bufsize
=
4096
# Could make this a Runner param if needed
timeout_secs
=
self
.
runner
.
timeout
# Reusing runner's TCP connect timeout as command progress timeout
chan
=
self
.
ssh
.
get_transport
()
.
open_session
()
chan
.
settimeout
(
timeout_secs
)
chan
.
get_pty
()
# Many sudo setups require a terminal
#print "exec_command: " + sudocmd
chan
.
exec_command
(
sudocmd
)
if
self
.
runner
.
sudo_pass
:
while
not
chan
.
recv_ready
():
time
.
sleep
(
0.25
)
sudo_output
=
chan
.
recv
(
bufsize
)
# Pull prompt, catch errors, eat sudo output
#print "exec_command: " + sudo_output
#print "exec_command: sending password"
chan
.
sendall
(
self
.
runner
.
sudo_pass
+
'
\n
'
)
stdin
=
chan
.
makefile
(
'wb'
,
bufsize
)
stdout
=
chan
.
makefile
(
'rb'
,
bufsize
)
stderr
=
chan
.
makefile_stderr
(
'rb'
,
bufsize
)
return
stdin
,
stdout
,
stderr
stdin
=
chan
.
makefile
(
'wb'
,
bufsize
)
stdout
=
chan
.
makefile
(
'rb'
,
bufsize
)
stderr
=
chan
.
makefile_stderr
(
'rb'
,
bufsize
)
return
stdin
,
stdout
,
stderr
def
put_file
(
self
,
in_path
,
out_path
):
''' transfer a file from local to remote '''
...
...
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