<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 10 (filtered)">
<title>Re: OpenSSH 3.6.1p1 on NCR MP-RAS v4.3, several weird terminal problems</title>

<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi Darren &#8211;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Cc: list &#8211;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>There's not much that I can tell you about
NCR MP-RAS, other than that it is a SysV r4.3 derivative, and the hardest UNIX
to port to that I've encountered since my Xenix 286 days.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Here is an excerpt from the setsid()
manual page:</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp; WARNING</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
If the calling process is the&nbsp; last&nbsp; member&nbsp; of&nbsp; a&nbsp;
pipeline</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
started&nbsp; by&nbsp; a&nbsp; job&nbsp; control&nbsp; shell,&nbsp; the shell
may make the</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
calling process a process group leader.&nbsp; The other processes</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
of&nbsp; the&nbsp; pipeline&nbsp; become&nbsp; members of that process group.
In</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
this case, the call to setsid will fail.&nbsp; For this reason, a</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
process&nbsp; that&nbsp; calls&nbsp; setsid&nbsp; and&nbsp; expects&nbsp;
to&nbsp; be part of a</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pipeline should always first fork; the&nbsp; parent&nbsp; should&nbsp; exit</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
and&nbsp; the child should call setsid, thereby insuring that the</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
process will work reliably when started by both job&nbsp; control</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
shells and non-job control shells.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I noticed in sshpty.c that the call to setsid()
follows a section which will call ioctl(fd, TIOCNOTTY, NULL) #ifdef TIOCNOTTY.
Looking in /usr/include/sys/*.h I find that termios.h and ttold.h #define
TIOCNOTTY.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>termios.h will only #define TIOCNOTTY if all
three of _<i><span style='font-style:italic'>SYS_TTOLD</span></i>_H,&nbsp; _<i><span
style='font-style:italic'>POSIX</span></i>_SOURCE,&nbsp; and&nbsp; _<i><span
style='font-style:italic'>XOPEN</span></i>_SOURCE &nbsp;are not defined.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>ttold.h will only #define TIOCNOTTY if _<i><span
style='font-style:italic'>SYS_TERMIOS</span></i>_H is not defined.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I do see termios.h included in the compile
on this platform. I do not see ttold.h included. Therefore, I assume that the
section in sshpty.c which would call ioctl() with TIOCNOTTY is NOT being executed.
I did a test by commenting out the #ifdef TIOCNOTTY to ensure that the ioctl()
call does happen, and took out the #define STREAMS_PUSH_ACQUIRES_CTTY. It did
not fix the problem, so calling or not calling the ioctl() with TIOCNOTTY
doesn't affect this problem. (Just casting about here).</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Regarding O_NOCTTY, the man page for open()
describes O_NOCTTY as:</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
O_NOCTTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If&nbsp; set&nbsp; and&nbsp; the&nbsp;
file&nbsp; is&nbsp; a&nbsp; terminal,&nbsp; the</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
terminal&nbsp; will not be allocated as the calling</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
process's controlling terminal.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>If you have any specific questions
regarding the platform, I'm happy to dig in manual pages, run tests, and report
back.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>-Jay</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b> Darren Tucker
[mailto:dtucker@zip.com.au] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, April 09, 2003
20:18<br>
<b><span style='font-weight:bold'>To:</span></b> Jay Libove<br>
<b><span style='font-weight:bold'>Cc:</span></b> openssh-unix-dev@mindrot.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: OpenSSH 3.6.1p1 on
NCR MP-RAS v4.3, several weird terminal problems</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p style='margin-left:.5in'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>Jay Libove wrote:</span></font> <br>
<font size=2><span style='font-size:10.0pt'>&gt; I tried the suggested config.h
modification of</span></font> <br>
<font size=2><span style='font-size:10.0pt'>&gt; </span></font><br>
<font size=2><span style='font-size:10.0pt'>&gt;&nbsp; #define
STREAMS_PUSH_ACQUIRES_CTTY 1</span></font> <br>
<font size=2><span style='font-size:10.0pt'>&gt; </span></font><br>
<font size=2><span style='font-size:10.0pt'>&gt;&nbsp; .. and it seems to have
fixed all of the problems that I reported below</span></font> <br>
<font size=2><span style='font-size:10.0pt'>&gt; (^C killing the session,
logging out not fully closing the connection,</span></font> <br>
<font size=2><span style='font-size:10.0pt'>&gt; lack of job control, and
command line pipes being broken).</span></font> </p>

<p style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><font
size=2><span style='font-size:10.0pt'>This means that MP-RAS somehow
re-acquires a controlling terminal after</span></font> <br>
<font size=2><span style='font-size:10.0pt'>forking and calling setsid() the
first time.&nbsp; In the Solaris case, a bug</span></font> <br>
<font size=2><span style='font-size:10.0pt'>in the pty driver caused it to
happen when pushing a STREAMS module</span></font> <br>
<font size=2><span style='font-size:10.0pt'>(hence the #define name).&nbsp;
Linux/glibc5 has the same symptoms but it</span></font> <br>
<font size=2><span style='font-size:10.0pt'>doesn't have STREAMS so it must be
acquiring it some other way (not</span></font> <br>
<font size=2><span style='font-size:10.0pt'>honouring O_NOCTTY maybe?)</span></font>
</p>

<p style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><font
size=2><span style='font-size:10.0pt'>What can you tell us about MP-RAS?&nbsp;
Is it a SysV derivative?</span></font> </p>

<p style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><font
size=2><span style='font-size:10.0pt'>Should we just change the define to
HAVE_BROKEN_O_NOCTTY.&nbsp; We could</span></font> <br>
<font size=2><span style='font-size:10.0pt'>have configure do a run-tine test
for it but it'd need a lot of the code</span></font> <br>
<font size=2><span style='font-size:10.0pt'>from pty_allocate().</span></font> </p>

<p style='margin-left:.5in'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>-- </span></font><br>
<font size=2><span style='font-size:10.0pt'>Darren Tucker (dtucker at
zip.com.au)</span></font> <br>
<font size=2><span style='font-size:10.0pt'>GPG key 8FF4FA69 / D9A3 86E9 7EEE
AF4B B2D4&nbsp; 37C9 C982 80C7 8FF4 FA69</span></font> <br>
<font size=2><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp; Good judgement
comes with experience. Unfortunately, the experience</span></font> <br>
<font size=2><span style='font-size:10.0pt'>usually comes from bad judgement.</span></font>
</p>

</div>

</body>

</html>