Skip to content

Commit 2ba1b2b

Browse files
gaigemoreati
andauthored
Fix: termios.error: (22, 'Invalid argument') during become on Solaris/Illumos/SmartOS (#1089)
This fixes compatibility with Solaris/Illumos/SmartOS, addressing an issue that shows up most frequently with become. The issue was mostly due to differences in how the TTY driver is handled and the pty driver not supporting echo on both sides of the pipe (as designed, from a Solaris point of view). Fixes #950 Co-authored-by: Alex Willmer <[email protected]>
1 parent b8b1558 commit 2ba1b2b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ To avail of fixes in an unreleased version, please download a ZIP file
2121
Unreleased
2222
----------
2323

24+
* :gh:issue:`950` Fix Solaris/Illumos/SmartOS compatibility with become
2425
* :gh:issue:`1087` Fix :exc:`mitogen.core.StreamError` when Ansible template
2526
module is called with a ``dest:`` filename that has an extension
2627
* :gh:issue:`1110` Fix :exc:`mitogen.core.StreamError` when Ansible copy

mitogen/parent.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ def _ioctl_cast(n):
147147
LINUX_TIOCSPTLCK = _ioctl_cast(1074025521)
148148

149149
IS_LINUX = os.uname()[0] == 'Linux'
150+
IS_SOLARIS = os.uname()[0] == 'SunOS'
151+
150152

151153
SIGNAL_BY_NUM = dict(
152154
(getattr(signal, name), name)
@@ -411,7 +413,7 @@ def _acquire_controlling_tty():
411413
# On Linux, the controlling tty becomes the first tty opened by a
412414
# process lacking any prior tty.
413415
os.close(os.open(os.ttyname(2), os.O_RDWR))
414-
if hasattr(termios, 'TIOCSCTTY') and not mitogen.core.IS_WSL:
416+
if hasattr(termios, 'TIOCSCTTY') and not mitogen.core.IS_WSL and not IS_SOLARIS:
415417
# #550: prehistoric WSL does not like TIOCSCTTY.
416418
# On BSD an explicit ioctl is required. For some inexplicable reason,
417419
# Python 2.6 on Travis also requires it.
@@ -479,7 +481,8 @@ def openpty():
479481

480482
master_fp = os.fdopen(master_fd, 'r+b', 0)
481483
slave_fp = os.fdopen(slave_fd, 'r+b', 0)
482-
disable_echo(master_fd)
484+
if not IS_SOLARIS:
485+
disable_echo(master_fd)
483486
disable_echo(slave_fd)
484487
mitogen.core.set_block(slave_fd)
485488
return master_fp, slave_fp

0 commit comments

Comments
 (0)