From: David van Moolenbroek Date: Tue, 14 Feb 2017 18:51:12 +0000 (+0000) Subject: Retire MINIX in.telnetd(8) X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=a9ef5b90e63d0ccf89df652bb3ce3bb79d781300;p=minix.git Retire MINIX in.telnetd(8) Change-Id: Ib54998e7a81f924d19b8013ef567703996d24a03 --- diff --git a/distrib/sets/lists/minix-base/mi b/distrib/sets/lists/minix-base/mi index 6a8acd8ce..fb222e5bf 100644 --- a/distrib/sets/lists/minix-base/mi +++ b/distrib/sets/lists/minix-base/mi @@ -379,7 +379,7 @@ ./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 diff --git a/distrib/sets/lists/minix-debug/mi b/distrib/sets/lists/minix-debug/mi index b6a56e800..7cec8ea88 100644 --- a/distrib/sets/lists/minix-debug/mi +++ b/distrib/sets/lists/minix-debug/mi @@ -296,7 +296,7 @@ ./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 diff --git a/minix/commands/Makefile b/minix/commands/Makefile index 347ebeaf7..a07ea26f4 100644 --- a/minix/commands/Makefile +++ b/minix/commands/Makefile @@ -23,7 +23,7 @@ SUBDIR= at backup \ 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 \ diff --git a/minix/commands/telnetd/Makefile b/minix/commands/telnetd/Makefile deleted file mode 100644 index 55ce0dd2b..000000000 --- a/minix/commands/telnetd/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# Makefile for telnetd -# -# 01/30/96 Initial Release Michael Temari, -# - -PROG= in.telnetd -SRCS= main.c telnet.c term.c pty.c -MAN= - -.include diff --git a/minix/commands/telnetd/main.c b/minix/commands/telnetd/main.c deleted file mode 100644 index ccf39a0cb..000000000 --- a/minix/commands/telnetd/main.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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, - * Michael Temari, - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#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); -} diff --git a/minix/commands/telnetd/pty.c b/minix/commands/telnetd/pty.c deleted file mode 100644 index 0900a2cd0..000000000 --- a/minix/commands/telnetd/pty.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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, - */ -#include -#include -#include -#include -#include -#include -#include -#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); -} diff --git a/minix/commands/telnetd/telnet.c b/minix/commands/telnetd/telnet.c deleted file mode 100644 index 51dd67a71..000000000 --- a/minix/commands/telnetd/telnet.c +++ /dev/null @@ -1,337 +0,0 @@ -/* - * 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, 01/13/93 - * - */ -#include -#include -#include -#include -#include -#include -#include "telnetd.h" -#include "telnet.h" -#include -#include - - -#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); -} diff --git a/minix/commands/telnetd/telnet.h b/minix/commands/telnetd/telnet.h deleted file mode 100644 index 893aad825..000000000 --- a/minix/commands/telnetd/telnet.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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, - */ -#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 */ diff --git a/minix/commands/telnetd/telnetd.h b/minix/commands/telnetd/telnetd.h deleted file mode 100644 index b94c092a4..000000000 --- a/minix/commands/telnetd/telnetd.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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, - */ - -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); diff --git a/minix/commands/telnetd/term.c b/minix/commands/telnetd/term.c deleted file mode 100644 index 90638e53d..000000000 --- a/minix/commands/telnetd/term.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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, - * Michael Temari, - * - * 07/29/92 MT Telnet options hack which seems to work okay - * 01/12/93 MT Better telnet options processing instead of hack - */ -#include -#include -#if 0 -#include -#endif -#include -#include -#include -#include -#include -#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... */ -}