mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Only allocate a PTY when sudo is used
Postpone the paramiko.Channel.get_pty until we know sudo is used. If sudo is not used, then we do not need a PTY. In fact, the paramiko docs explicitly state that it's not desirable to allocate a PTY for a simple exec_command. Signed-off-by: martin f. krafft <madduck@madduck.net>
This commit is contained in:
parent
584fd7a261
commit
1cf43e9afe
1 changed files with 1 additions and 1 deletions
|
@ -110,7 +110,6 @@ class Connection(object):
|
||||||
if len(str(e)) > 0:
|
if len(str(e)) > 0:
|
||||||
msg += ": %s" % str(e)
|
msg += ": %s" % str(e)
|
||||||
raise errors.AnsibleConnectionFailed(msg)
|
raise errors.AnsibleConnectionFailed(msg)
|
||||||
chan.get_pty()
|
|
||||||
|
|
||||||
if not self.runner.sudo or not sudoable:
|
if not self.runner.sudo or not sudoable:
|
||||||
if executable:
|
if executable:
|
||||||
|
@ -120,6 +119,7 @@ class Connection(object):
|
||||||
vvv("EXEC %s" % quoted_command, host=self.host)
|
vvv("EXEC %s" % quoted_command, host=self.host)
|
||||||
chan.exec_command(quoted_command)
|
chan.exec_command(quoted_command)
|
||||||
else:
|
else:
|
||||||
|
chan.get_pty()
|
||||||
shcmd, prompt = utils.make_sudo_cmd(sudo_user, executable, cmd)
|
shcmd, prompt = utils.make_sudo_cmd(sudo_user, executable, cmd)
|
||||||
vvv("EXEC %s" % shcmd, host=self.host)
|
vvv("EXEC %s" % shcmd, host=self.host)
|
||||||
sudo_output = ''
|
sudo_output = ''
|
||||||
|
|
Loading…
Reference in a new issue