Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!mips!dimacs.rutgers.edu!aramis.rutgers.edu!athos.rutgers.edu!hedrick From: hedrick@athos.rutgers.edu (Charles Hedrick) Newsgroups: comp.protocols.tcp-ip Subject: Re: Porting BSD telnetd to a Sun Keywords: telnetd bsd 4.3 Sun SunOS Message-ID: Date: 28 May 91 21:54:41 GMT References: Organization: Rutgers Univ., New Brunswick, N.J. Lines: 33 To: jpc@avdms8.msfc.nasa.gov We use the 4.4 telnetd on our Suns. With either version, you'll want to add some code to the section that opens the controlling pty. Look for for (i = 0; i < 16; i++) { line[sizeof("/dev/ptyp") - 1] = "0123456789abcdef"[i]; p = open(line, O_RDWR); if (p > 0) goto gotpty; } Instead, you want something like the following. (This is taken from our 4.4 version of telnetd, so I haven't actually used it in the 4.3 one, but I think it should be OK.) Note that this code is SunOS-specific, and should work in 4.0.3c or later. (It depends upon an undocumented side-effect of TIOCGPGRP.) for (i = 0; i < 16; i++) { line[sizeof("/dev/ptyp") - 1] = "0123456789abcdef"[i]; p = open(line, O_RDWR); if (p > 0) { line[5] = 't'; chown(line, 0, 0); chmod(line, 0600); /* make sure the tty isn't in use */ if (ioctl(p, TIOCGPGRP, &dummy) == -1 && errno == EIO) goto gotpty; chmod(line, 0666); close(p); line[5] = 'p'; } }