1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

docker connection plugin: make privilege escalation code more similar to local.py (#56288)

* Make more similar to local.py

* Fix typo.
This commit is contained in:
Felix Fontein 2019-05-19 14:00:25 +02:00 committed by ansibot
parent 52a89b290f
commit 708bda06aa
2 changed files with 5 additions and 5 deletions

View file

@ -1,4 +1,4 @@
---
bugfixes:
- Fix privilege escalation support for the docker connection plugin when
credentials needs to be supplied (e.g. sudo with password).
credentials need to be supplied (e.g. sudo with password).

View file

@ -205,7 +205,9 @@ class Connection(ConnectionBase):
local_cmd = self._build_exec_cmd([self._play_context.executable, '-c', cmd])
display.vvv("EXEC %s" % (local_cmd,), host=self._play_context.remote_addr)
display.vvv(u"EXEC {0}".format(to_text(local_cmd)), host=self._play_context.remote_addr)
display.debug("opening command with Popen()")
local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
p = subprocess.Popen(
@ -214,12 +216,11 @@ class Connection(ConnectionBase):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
display.debug("done running command with Popen()")
if self.become and self.become.expect_prompt() and sudoable:
display.debug("handling privilege escalation")
fcntl.fcntl(p.stdout, fcntl.F_SETFL, fcntl.fcntl(p.stdout, fcntl.F_GETFL) | os.O_NONBLOCK)
fcntl.fcntl(p.stderr, fcntl.F_SETFL, fcntl.fcntl(p.stderr, fcntl.F_GETFL) | os.O_NONBLOCK)
selector = selectors.DefaultSelector()
selector.register(p.stdout, selectors.EVENT_READ)
selector.register(p.stderr, selectors.EVENT_READ)
@ -235,7 +236,6 @@ class Connection(ConnectionBase):
for key, event in events:
if key.fileobj == p.stdout:
chunk = p.stdout.read()
break
elif key.fileobj == p.stderr:
chunk = p.stderr.read()