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

Initialise PTY from calling environment

If we need to acquire a PTY for sudo's use, then it should really
inherit the capabilities of the calling environment. This is what
OpenSSH does, and so it makes sense to copy this behaviour for the
paramiko connection type.

Closes: #2065
Signed-off-by: martin f. krafft <madduck@madduck.net>
This commit is contained in:
martin f. krafft 2013-02-15 10:23:34 +13:00
parent 1cf43e9afe
commit ab39909260

View file

@ -119,7 +119,12 @@ 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() # sudo usually requires a PTY (cf. requiretty option), therefore
# we give it one, and we try to initialise from the calling
# environment
chan.get_pty(term=os.getenv('TERM', 'vt100'),
width=os.getenv('COLUMNS', 0),
height=os.getenv('LINES', 0))
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 = ''