./usr/bin/ifconfig minix-base obsolete
./usr/bin/ifdef minix-base
./usr/bin/in.rshd minix-base obsolete
-./usr/bin/in.telnetd minix-base
+./usr/bin/in.telnetd minix-base obsolete
./usr/bin/indent minix-base
./usr/bin/info minix-base
./usr/bin/infocmp minix-base
./usr/libdata/debug/usr/bin/id.debug minix-debug debug
./usr/libdata/debug/usr/bin/ifconfig.debug minix-debug debug,obsolete
./usr/libdata/debug/usr/bin/ifdef.debug minix-debug debug
-./usr/libdata/debug/usr/bin/in.telnetd.debug minix-debug debug
+./usr/libdata/debug/usr/bin/in.telnetd.debug minix-debug debug,obsolete
./usr/libdata/debug/usr/bin/indent.debug minix-debug debug
./usr/libdata/debug/usr/bin/info.debug minix-debug debug
./usr/libdata/debug/usr/bin/infocmp.debug minix-debug debug
rotate setup \
slip spell sprofalyze sprofdiff srccrc \
svrctl swifi synctree sysenv \
- telnetd term termcap tget \
+ term termcap tget \
truncate umount \
update version vol \
writeisofs fetch \
+++ /dev/null
-# Makefile for telnetd
-#
-# 01/30/96 Initial Release Michael Temari, <temari@ix.netcom.com>
-#
-
-PROG= in.telnetd
-SRCS= main.c telnet.c term.c pty.c
-MAN=
-
-.include <bsd.prog.mk>
+++ /dev/null
-/*
- * TNET A server program for MINIX which implements the TCP/IP
- * suite of networking protocols. It is based on the
- * TCP/IP code written by Phil Karn et al, as found in
- * his NET package for Packet Radio communications.
- *
- * This file contains an implementation of the "server"
- * for the TELNET protocol. This protocol can be used to
- * remote-login on other systems, just like a normal TTY
- * session.
- *
- * Usage: telnetd [-dv]
- *
- * Version: @(#)telnetd.c 1.00 07/26/92
- *
- * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- * Michael Temari, <temari@temari.ae.ge.com>
- */
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-#include <stdio.h>
-#include <ttyent.h>
-#include <utmp.h>
-#include <net/gen/in.h>
-#include <net/gen/tcp.h>
-#include <net/gen/tcp_io.h>
-#include <net/gen/socket.h>
-#include <netdb.h>
-#include <net/gen/inet.h>
-#include <arpa/inet.h>
-#include "telnetd.h"
-
-#if 0
-static char *Version = "@(#) telnetd 1.00 (07/26/92)";
-#endif
-
-int opt_d = 0; /* debugging output flag */
-
-void usage(void);
-int main(int argc, char *argv[]);
-
-void usage()
-{
- fprintf(stderr, "Usage: telnetd [-dv]\n");
-
- exit(-1);
-}
-
-int main(argc, argv)
-int argc;
-char *argv[];
-{
-char buff[128];
-register int c;
-int pty_fd;
-int tty_fd;
-pid_t pid;
-int lineno;
-char *tty_name;
-struct ttyent *ttyp;
-nwio_tcpconf_t tcpconf;
-struct hostent *hostent;
-char *hostname;
-
- opterr = 0;
- while ((c = getopt(argc, argv, "dv")) != EOF) switch(c) {
- case 'd':
- case 'v':
- opt_d = 1;
- break;
- default:
- usage();
- }
-
- /* No more arguments allowed. */
- if (optind != argc) usage();
-
- /* Obtain the name of the remote host. */
- if (ioctl(0, NWIOGTCPCONF, &tcpconf) < 0) {
- sprintf(buff, "Unable to obtain your IP address\r\n");
- (void) write(1, buff, strlen(buff));
- return(-1);
- }
- if ((hostent = gethostbyaddr((char *) &tcpconf.nwtc_remaddr,
- sizeof(tcpconf.nwtc_remaddr), AF_INET)) != NULL) {
- hostname = hostent->h_name;
- } else {
- hostname = inet_ntoa(*(struct in_addr *)&tcpconf.nwtc_remaddr);
- }
-
- /* Try allocating a PTY. */
- if (get_pty(&pty_fd, &tty_name) < 0) {
- sprintf(buff, "I am sorry, but there is no free PTY left!\r\n");
- (void) write(1, buff, strlen(buff));
- return(-1);
- }
-
- /* Find the tty in the tty table. */
- lineno = 0;
- for (;;) {
- if ((ttyp = getttyent()) == NULL) {
- sprintf(buff, "Can't find the tty entry in the tty table\r\n");
- (void) write(1, buff, strlen(buff));
- }
- if (strcmp(ttyp->ty_name, tty_name+5) == 0) break;
- lineno++;
- }
- endttyent();
-
- /* Initialize the connection to an 8 bit clean channel. */
- term_init();
-
- /* Fork off a child process and have it execute a getty(8). */
- if ((pid = fork()) == 0) {
- /* Set up a new session. */
- setsid();
- if ((tty_fd = open(tty_name, O_RDWR)) < 0) {
- sprintf(buff, "Can't open %s\r\n", tty_name);
- (void) write(1, buff, strlen(buff));
- return(-1);
- }
-
- close(pty_fd);
- dup2(tty_fd, 0);
- dup2(tty_fd, 1);
- dup2(tty_fd, 2);
- close(tty_fd);
- (void) execl("/usr/sbin/getty", "getty", (char *)NULL);
- (void) execl("/usr/bin/getty", "getty", (char *)NULL);
- (void) execl("/usr/bin/login", "login", (char *)NULL);
- (void) write(1, "EXEC failed!\r\n", 14);
- } else if (pid < 0) {
- sprintf(buff, "I am sorry, but the fork(2) call failed!\r\n");
- (void) write(1, buff, strlen(buff));
- (void) close(pty_fd);
- return(-1);
- }
-
- term_inout(pty_fd);
-
- (void) close(pty_fd);
-
- chown(tty_name, 0, 0);
- chmod(tty_name, 0666);
-
- return(0);
-}
+++ /dev/null
-/*
- * TNET A server program for MINIX which implements the TCP/IP
- * suite of networking protocols. It is based on the
- * TCP/IP code written by Phil Karn et al, as found in
- * his NET package for Packet Radio communications.
- *
- * Handle the allocation of a PTY.
- *
- * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- */
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include "telnetd.h"
-
-
-#define DEV_DIR "/dev"
-
-/*
- * Allocate a PTY, by trying to open one repeatedly,
- * until all PTY channels are done. If at that point
- * no PTY is found, go into panic mode :-(
- */
-int get_pty(pty_fdp, tty_namep)
-int *pty_fdp;
-char **tty_namep;
-{
- char buff[128], temp[128];
- register int i, j;
- int pty_fd;
- static char tty_name[128];
-
- for(i = 'p'; i < 'w'; i++) {
- j = 0;
- do {
- sprintf(buff, "%s/pty%c%c",
- DEV_DIR, i, (j < 10) ? j + '0' : j + 'a' - 10);
-
- if (opt_d == 1) {
- (void) write(2, "Testing: ", 9);
- (void) write(2, buff, strlen(buff));
- (void) write(2, "...: ", 5);
- }
-
- pty_fd = open(buff, O_RDWR);
- if (opt_d == 1) {
- if (pty_fd < 0) sprintf(temp, "error %d\r\n", errno);
- else sprintf(temp, "OK\r\n");
- (void) write(2, temp, strlen(temp));
- }
-
- if (pty_fd >= 0) break;
-
- j++;
- if (j == 16) break;
- } while(1);
-
- /* Did we find one? */
- if (j < 16) break;
- }
- if (pty_fd < 0) return(-1);
-
- if (opt_d == 1) {
- sprintf(temp, "File %s, desc %d\n", buff, pty_fd);
- (void) write(1, temp, strlen(temp));
- }
-
- sprintf(tty_name, "%s/tty%c%c", DEV_DIR,
- i, (j < 10) ? j + '0' : j + 'a' - 10);
-
- *pty_fdp = pty_fd;
- *tty_namep = tty_name;
- return(0);
-}
+++ /dev/null
-/*
- * TNET A server program for MINIX which implements the TCP/IP
- * suite of networking protocols. It is based on the
- * TCP/IP code written by Phil Karn et al, as found in
- * his NET package for Packet Radio communications.
- *
- * This module handles telnet option processing.
- *
- * Author: Michael Temari, <temari@temari.ae.ge.com> 01/13/93
- *
- */
-#include <sys/types.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <termios.h>
-#include "telnetd.h"
-#include "telnet.h"
-#include <stdio.h>
-#include <sys/ioctl.h>
-
-
-#define IN_DATA 0
-#define IN_CR 1
-#define IN_IAC 2
-#define IN_IAC2 3
-#define IN_SB 4
-
-static void dowill(int c);
-static void dowont(int c);
-static void dodo(int c);
-static void dodont(int c);
-static void respond(int ack, int option);
-static void respond_really(int ack, int option);
-
-#define LASTTELOPT TELOPT_SGA
-
-static int r_winch = 0;
-
-static int TelROpts[LASTTELOPT+1];
-static int TelLOpts[LASTTELOPT+1];
-
-static int telfdout;
-
-void tel_init()
-{
-int i;
-
- for(i = 0; i <= LASTTELOPT; i++) {
- TelROpts[i] = 0;
- TelLOpts[i] = 0;
- }
-}
-
-void telopt(fdout, what, option)
-int fdout;
-int what;
-int option;
-{
-char buf[3];
-int len;
-
- buf[0] = IAC;
- buf[1] = what;
- buf[2] = option;
- len = 0;
-
- switch(what) {
- case DO:
- if(option <= LASTTELOPT) {
- TelROpts[option] = 1;
- len = 3;
- } else if(option == TELOPT_WINCH && !r_winch) { r_winch = 1; len = 3; }
- break;
- case DONT:
- if(option <= LASTTELOPT) {
- TelROpts[option] = 1;
- len = 3;
- }
- break;
- case WILL:
- if(option <= LASTTELOPT) {
- TelLOpts[option] = 1;
- len = 3;
- }
- break;
- case WONT:
- if(option <= LASTTELOPT) {
- TelLOpts[option] = 1;
- len = 3;
- }
- break;
- }
- if(len > 0)
- (void) write(fdout, buf, len);
-}
-
-void set_winsize(int fd, unsigned int cols, unsigned int rows)
-{
- struct winsize w;
- memset(&w, 0, sizeof(w));
- w.ws_col = cols;
- w.ws_row = rows;
- ioctl(fd, TIOCSWINSZ, (char *) &w);
-}
-
-void tel_in(fdout, telout, buffer, len)
-int fdout;
-int telout;
-char *buffer;
-int len;
-{
-static int InState = IN_DATA;
-static int ThisOpt = 0;
-char *p;
-char *p2;
-int size;
-int c;
-
- telfdout = telout;
- p = p2 = buffer;
- size = 0;
-
- while(len > 0) {
- c = (unsigned char)*p++; len--;
- switch(InState) {
- case IN_CR:
- InState = IN_DATA;
- if(c == 0 || c == '\n')
- break;
- /* fall through */
- case IN_DATA:
- if(c == IAC) {
- InState = IN_IAC;
- break;
- }
- *p2++ = c; size++;
- if(c == '\r') InState = IN_CR;
- break;
- case IN_IAC:
- switch(c) {
- case IAC:
- *p2++ = c; size++;
- InState = IN_DATA;
- break;
- case WILL:
- case WONT:
- case DO:
- case DONT:
- InState = IN_IAC2;
- ThisOpt = c;
- break;
- case SB:
- InState = IN_SB;
- break;
- case EOR:
- case SE:
- case NOP:
- case BREAK:
- case IP:
- case AO:
- case AYT:
- case EC:
- case EL:
- case GA:
- break;
- default:
- break;
- }
- break;
- case IN_IAC2:
- if(size > 0) {
- write(fdout, buffer, size);
- p2 = buffer;
- size = 0;
- }
- InState = IN_DATA;
- switch(ThisOpt) {
- case WILL: dowill(c); break;
- case WONT: dowont(c); break;
- case DO: dodo(c); break;
- case DONT: dodont(c); break;
- }
- break;
- case IN_SB:
- {
- static int winchpos = -1;
- /* Subnegotiation. */
- if(winchpos >= 0) {
- static unsigned int winchbuf[5], iacs = 0;
- winchbuf[winchpos] = c;
- /* IAC is escaped - unescape it. */
- if(c == IAC) iacs++; else { iacs = 0; winchpos++; }
- if(iacs == 2) { winchpos++; iacs = 0; }
- if(winchpos >= 4) {
- /* End of WINCH data. */
- set_winsize(fdout,
- (winchbuf[0] << 8) | winchbuf[1],
- (winchbuf[2] << 8) | winchbuf[3]);
- winchpos = -1;
- }
- } else {
- static int lastiac = 0;
- switch(c) {
- case TELOPT_WINCH:
- /* Start listening. */
- winchpos = 0;
- break;
- case SE:
- if(lastiac) InState = IN_DATA;
- break;
- default:
- break;
- }
- if(c == IAC) lastiac = 1;
- else lastiac = 0;
-
-
- }
- break;
- }
- }
- }
-
- if(size > 0)
- write(fdout, buffer, size);
-}
-
-void tel_out(fdout, buf, size)
-int fdout;
-char *buf;
-int size;
-{
-char *p;
-int got_iac, len;
-
- p = buf;
- while(size > 0) {
- buf = p;
- got_iac = 0;
- if((p = (char *)memchr(buf, IAC, size)) != (char *)NULL) {
- got_iac = 1;
- p++;
- } else
- p = buf + size;
- len = p - buf;
- if(len > 0)
- (void) write(fdout, buf, len);
- if(got_iac)
- (void) write(fdout, p - 1, 1);
- size = size - len;
- }
-}
-
-static void dowill(c)
-int c;
-{
-int ack;
-
- switch(c) {
- case TELOPT_BINARY:
- case TELOPT_ECHO:
- case TELOPT_SGA:
- if(TelROpts[c] == 1)
- return;
- TelROpts[c] = 1;
- ack = DO;
- break;
- case TELOPT_WINCH:
- if(r_winch) return;
- r_winch = 1;
- ack = DO;
- respond_really(ack, c);
- return;
- default:
- ack = DONT;
- }
-
- respond(ack, c);
-}
-
-static void dowont(c)
-int c;
-{
- if(c <= LASTTELOPT) {
- if(TelROpts[c] == 0)
- return;
- TelROpts[c] = 0;
- }
- respond(DONT, c);
-}
-
-static void dodo(c)
-int c;
-{
-int ack;
-
- switch(c) {
- default:
- ack = WONT;
- }
- respond(ack, c);
-}
-
-static void dodont(c)
-int c;
-{
- if(c <= LASTTELOPT) {
- if(TelLOpts[c] == 0)
- return;
- TelLOpts[c] = 0;
- }
- respond(WONT, c);
-}
-
-static void respond(ack, option)
-int ack, option;
-{
-unsigned char c[3];
-
- c[0] = IAC;
- c[1] = ack;
- c[2] = option;
-/* write(telfdout, c, 3); */
-}
-
-static void respond_really(ack, option)
-int ack, option;
-{
-unsigned char c[3];
-
- c[0] = IAC;
- c[1] = ack;
- c[2] = option;
- write(telfdout, c, 3);
-}
+++ /dev/null
-/*
- * TNET A server program for MINIX which implements the TCP/IP
- * suite of networking protocols. It is based on the
- * TCP/IP code written by Phil Karn et al, as found in
- * his NET package for Packet Radio communications.
- *
- * Definitions for the TELNET protocol (see RFC XXX).
- *
- * Version: @(#)arpa/telnet.h 1.00 07/02/92
- *
- * Authors: Original taken from BSD 4.3/TAHOE.
- * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- */
-#ifndef _ARPA_TELNET_H
-#define _ARPA_TELNET_H
-
-#define IAC 255 /* interpret as command: */
-#define DONT 254 /* you are not to use option */
-#define DO 253 /* please, you use option */
-#define WONT 252 /* I won't use option */
-#define WILL 251 /* I will use option */
-#define SB 250 /* interpret as subnegotiation */
-#define GA 249 /* you may reverse the line */
-#define EL 248 /* erase the current line */
-#define EC 247 /* erase the current character */
-#define AYT 246 /* are you there */
-#define AO 245 /* abort output--but let prog finish */
-#define IP 244 /* interrupt process--permanently */
-#define BREAK 243 /* break */
-#define DM 242 /* data mark--for connect. cleaning */
-#define NOP 241 /* nop */
-#define SE 240 /* end sub negotiation */
-#define EOR 239 /* end of record (transparent mode) */
-
-#define SYNCH 242 /* for telfunc calls */
-
-/* Telnet options. */
-#define TELOPT_BINARY 0 /* 8-bit data path */
-#define TELOPT_ECHO 1 /* echo */
-#define TELOPT_RCP 2 /* prepare to reconnect */
-#define TELOPT_SGA 3 /* suppress go ahead */
-#define TELOPT_NAMS 4 /* approximate message size */
-#define TELOPT_STATUS 5 /* give status */
-#define TELOPT_TM 6 /* timing mark */
-#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
-#define TELOPT_NAOL 8 /* negotiate about output line width */
-#define TELOPT_NAOP 9 /* negotiate about output page size */
-#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
-#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
-#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
-#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
-#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
-#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
-#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
-#define TELOPT_XASCII 17 /* extended ascic character set */
-#define TELOPT_LOGOUT 18 /* force logout */
-#define TELOPT_BM 19 /* byte macro */
-#define TELOPT_DET 20 /* data entry terminal */
-#define TELOPT_SUPDUP 21 /* supdup protocol */
-#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
-#define TELOPT_SNDLOC 23 /* send location */
-#define TELOPT_TTYPE 24 /* terminal type */
-#define TELOPT_EOR 25 /* end or record */
-#define TELOPT_WINCH 31 /* window size */
-#define TELOPT_EXOPL 255 /* extended-options-list */
-
-/* Sub-option qualifiers. */
-#define TELQUAL_IS 0 /* option is... */
-#define TELQUAL_SEND 1 /* send option */
-
-#endif /* _ARPA_TELNET_H */
+++ /dev/null
-/*
- * TNET A server program for MINIX which implements the TCP/IP
- * suite of networking protocols. It is based on the
- * TCP/IP code written by Phil Karn et al, as found in
- * his NET package for Packet Radio communications.
- *
- * Definitions for the TELNET server.
- *
- * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- */
-
-extern int opt_d; /* debugging flag */
-
-int get_pty(int *, char **);
-void term_init(void);
-void term_inout(int pty_fd);
-void tel_init(void);
-void telopt(int fdout, int what, int option);
-void tel_in(int fdout, int telout, char *buffer, int len);
-void tel_out(int fdout, char *buf, int size);
+++ /dev/null
-/*
- * TNET A server program for MINIX which implements the TCP/IP
- * suite of networking protocols. It is based on the
- * TCP/IP code written by Phil Karn et al, as found in
- * his NET package for Packet Radio communications.
- *
- * Handle the TERMINAL module.
- *
- * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- * Michael Temari, <temari@temari.ae.ge.com>
- *
- * 07/29/92 MT Telnet options hack which seems to work okay
- * 01/12/93 MT Better telnet options processing instead of hack
- */
-#include <sys/types.h>
-#include <errno.h>
-#if 0
-#include <fcntl.h>
-#endif
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <signal.h>
-#include "telnet.h"
-#include "telnetd.h"
-
-void sig_done(int sig);
-
-static char buff[4096];
-
-void term_init()
-{
- tel_init();
-
- telopt(1, WILL, TELOPT_SGA);
- telopt(1, DO, TELOPT_SGA);
- telopt(1, WILL, TELOPT_BINARY);
- telopt(1, DO, TELOPT_BINARY);
- telopt(1, WILL, TELOPT_ECHO);
- telopt(1, DO, TELOPT_WINCH);
-}
-
-static int io_done = 0;
-
-void term_inout(pty_fd)
-int pty_fd;
-{
-register int i;
-pid_t pid;
-struct sigaction sa;
-
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = sig_done;
- sigaction(SIGALRM, &sa, (struct sigaction *) NULL);
-
- if ((pid = fork()) == -1) {
- sprintf(buff, "telnetd: fork() failed: %s\r\n", strerror(errno));
- (void) write(1, buff, strlen(buff));
- }
-
- if (pid != 0) {
- /* network -> login process */
- while (!io_done && (i = read(0, buff, sizeof(buff))) > 0) {
- tel_in(pty_fd, 1, buff, i);
- }
- /* EOF, kill opposite number and exit. */
- (void) kill(pid, SIGKILL);
- } else {
- /* login process -> network */
- while ((i = read(pty_fd, buff, sizeof(buff))) > 0) {
- tel_out(1, buff, i);
- }
- /* EOF, alert opposite number and exit. */
- (void) kill(getppid(), SIGALRM);
- }
- /* EOF. */
-}
-
-void sig_done(sig)
-int sig;
-{
- io_done = 1;
- alarm(1); /* there is always a chance... */
-}