From 9cb9e2b10cb965b24f0f41a520f4d17a0ebf14a1 Mon Sep 17 00:00:00 2001 From: "Gaige B. Paulsen" Date: Sun, 2 Oct 2022 19:58:45 +0000 Subject: [PATCH 1/3] fix: solaris fix --- docs/changelog.rst | 1 + mitogen/parent.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5d77910e8..ffc22bfaa 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,7 @@ To avail of fixes in an unreleased version, please download a ZIP file Unreleased ---------- +* :gh:issue:`950` Fix Solaris/Illumos/SmartOS compatibility with become * :gh:issue:`952` Fix Ansible `--ask-become-pass`, add test coverage * :gh:issue:`957` Fix Ansible exception when executing against 10s of hosts "ValueError: filedescriptor out of range in select()" diff --git a/mitogen/parent.py b/mitogen/parent.py index 4b96dcf4f..4ee6d3f9c 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -148,6 +148,9 @@ def _ioctl_cast(n): IS_LINUX = os.uname()[0] == 'Linux' +IS_SOLARIS = os.uname()[0] == 'SunOS' + + SIGNAL_BY_NUM = dict( (getattr(signal, name), name) for name in sorted(vars(signal), reverse=True) @@ -411,7 +414,7 @@ def _acquire_controlling_tty(): # On Linux, the controlling tty becomes the first tty opened by a # process lacking any prior tty. os.close(os.open(os.ttyname(2), os.O_RDWR)) - if hasattr(termios, 'TIOCSCTTY') and not mitogen.core.IS_WSL: + if hasattr(termios, 'TIOCSCTTY') and not mitogen.core.IS_WSL and not IS_SOLARIS: # #550: prehistoric WSL does not like TIOCSCTTY. # On BSD an explicit ioctl is required. For some inexplicable reason, # Python 2.6 on Travis also requires it. @@ -479,7 +482,10 @@ def openpty(): master_fp = os.fdopen(master_fd, 'r+b', 0) slave_fp = os.fdopen(slave_fd, 'r+b', 0) - disable_echo(master_fd) + try: + disable_echo(master_fd) + except: + pass disable_echo(slave_fd) mitogen.core.set_block(slave_fd) return master_fp, slave_fp From b9dfe8c574e8ca326ff28f79b3ae1e439b77e805 Mon Sep 17 00:00:00 2001 From: "Gaige B. Paulsen" Date: Thu, 5 Sep 2024 09:49:31 +0000 Subject: [PATCH 2/3] fix: disable_echo fails on solaris --- mitogen/parent.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 4ee6d3f9c..cbd04e9f1 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -482,10 +482,8 @@ def openpty(): master_fp = os.fdopen(master_fd, 'r+b', 0) slave_fp = os.fdopen(slave_fd, 'r+b', 0) - try: + if not IS_SOLARIS: disable_echo(master_fd) - except: - pass disable_echo(slave_fd) mitogen.core.set_block(slave_fd) return master_fp, slave_fp From 57a4b4d2af64e9da81431ad44a2124909f56d734 Mon Sep 17 00:00:00 2001 From: "Gaige B. Paulsen" Date: Sat, 14 Sep 2024 19:31:42 +0000 Subject: [PATCH 3/3] fix: adjust syntax to match --- mitogen/parent.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 6b6f641d1..2ed7e8baa 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -147,7 +147,6 @@ def _ioctl_cast(n): LINUX_TIOCSPTLCK = _ioctl_cast(1074025521) IS_LINUX = os.uname()[0] == 'Linux' - IS_SOLARIS = os.uname()[0] == 'SunOS' @@ -483,7 +482,7 @@ def openpty(): master_fp = os.fdopen(master_fd, 'r+b', 0) slave_fp = os.fdopen(slave_fd, 'r+b', 0) if not IS_SOLARIS: - disable_echo(master_fd) + disable_echo(master_fd) disable_echo(slave_fd) mitogen.core.set_block(slave_fd) return master_fp, slave_fp