[comp.protocols.tcp-ip] Porting BSD telnetd to a Sun

jpc@avdms8.msfc.nasa.gov (J. Porter Clark) (05/28/91)

For a number of trivial reasons, I'm trying to compile the BSD 4.3
telnetd source on a Sun-3 running SunOS 4.1.  Is this possible?  Has
anybody done this successfully?  Can anybody give me some hints?

I already know of a few minor gotchas.  For example, BSD wants a
different version of /usr/include/arpa/telnet.h than what Sun
provides.
--
J. Porter Clark    jpc@avdms8.msfc.nasa.gov

hedrick@athos.rutgers.edu (Charles Hedrick) (05/29/91)

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';
	}
  }

deraadt@cpsc.ucalgary.ca (Theo de Raadt) (05/31/91)

In article <May.28.17.54.40.1991.9637@athos.rutgers.edu> hedrick@athos.rutgers.edu (Charles Hedrick) writes:
>  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.)

Note that Sun's in.telnetd does not even do this. in.rlogind on sun does
though...

Oh, and script does not either.

Of course, gmacs.. etc.. anything from the net that deals with pty's, do
not either.

I believe that the reason they do this is because when they went to
session groups they messed up vhangup(), or equivelant. Not surprising.
All terminals, not just pty's, are screwed up now.
 <tdr.
--

SunOS 4.0.3: /usr/include/vm/as.h, Line 44      | Theo de Raadt
SunOS 4.1.1: /usr/include/vm/as.h, Line 49      | deraadt@cpsc.ucalgary.ca
Is it a typo? Should the '_'  be an 's'?? :-)   | deraadt@cpsc.ucalgary.ca