summaryrefslogtreecommitdiffstats
path: root/usr.bin/telnet
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-07-06 05:14:28 +0000
committerbde <bde@FreeBSD.org>1997-07-06 05:14:28 +0000
commit3f0aace088bc6b054bf078c7be1970fd57453176 (patch)
treefb197e8ce150ef9d57444b959c5514685e108f47 /usr.bin/telnet
parent8e49bc41a2ccf2ebdd927af9395913f3da1156d1 (diff)
downloadFreeBSD-src-3f0aace088bc6b054bf078c7be1970fd57453176.zip
FreeBSD-src-3f0aace088bc6b054bf078c7be1970fd57453176.tar.gz
Import Lite2's src/usr.bin/telnet. The README is still on the vendor
branch and importing it gives some anachronisms. tn3270.c is still on the vendor branch and importing it just changes a memcpy to memmove.
Diffstat (limited to 'usr.bin/telnet')
-rw-r--r--usr.bin/telnet/README223
-rw-r--r--usr.bin/telnet/commands.c104
-rw-r--r--usr.bin/telnet/externs.h11
-rw-r--r--usr.bin/telnet/main.c16
-rw-r--r--usr.bin/telnet/ring.c6
-rw-r--r--usr.bin/telnet/sys_bsd.c79
-rw-r--r--usr.bin/telnet/telnet.110
-rw-r--r--usr.bin/telnet/telnet.c22
-rw-r--r--usr.bin/telnet/terminal.c5
-rw-r--r--usr.bin/telnet/tn3270.c4
-rw-r--r--usr.bin/telnet/utilities.c6
11 files changed, 368 insertions, 118 deletions
diff --git a/usr.bin/telnet/README b/usr.bin/telnet/README
index 086c88f..37b588f 100644
--- a/usr.bin/telnet/README
+++ b/usr.bin/telnet/README
@@ -1,25 +1,190 @@
-
This is a distribution of both client and server telnet. These programs
have been compiled on:
telnet telnetd
- BSD 4.3 Reno X X
- UNICOS 5.1 X X
- UNICOS 6.0 X X
- UNICOS 6.1 X X
- UNICOS 7.0 X X
- SunOs 3.5 X X (no linemode in server)
- SunOs 4.1 X X (no linemode in server)
- DYNIX V3.0.17.9 X X (no linemode in server)
- Ultrix 3.1 X X (no linemode in server)
- Ultrix 4.0 X X (no linemode in server)
+ 4.4 BSD-Lite x x
+ 4.3 BSD Reno X X
+ UNICOS 9.1 X X
+ UNICOS 9.0 X X
+ UNICOS 8.0 X X
+ BSDI 2.0 X X
+ Solaris 2.4 x x (no linemode in server)
+ SunOs 4.1.4 X X (no linemode in server)
+ Ultrix 4.3 X X (no linemode in server)
+ Ultrix 4.1 X X (no linemode in server)
In addition, previous versions have been compiled on the following
machines, but were not available for testing this version.
telnet telnetd
+ Next1.0 X X
+ UNICOS 8.3 X X
+ UNICOS 7.C X X
+ UNICOS 7.0 X X
SunOs 4.0.3c X X (no linemode in server)
- BSD 4.3 X X (no linemode in server)
+ 4.3 BSD X X (no linemode in server)
DYNIX V3.0.12 X X (no linemode in server)
+ Ultrix 3.1 X X (no linemode in server)
+ Ultrix 4.0 X X (no linemode in server)
+ SunOs 3.5 X X (no linemode in server)
+ SunOs 4.1.3 X X (no linemode in server)
+ Solaris 2.2 x x (no linemode in server)
+ Solaris 2.3 x x (no linemode in server)
+ BSDI 1.0 X X
+ BSDI 1.1 X X
+ DYNIX V3.0.17.9 X X (no linemode in server)
+ HP-UX 8.0 x x (no linemode in server)
+
+This code should work, but there are no guarantees.
+
+May 30, 1995
+
+This release represents what is on the 4.4BSD-Lite2 release, which
+should be the final BSD release. I will continue to support of
+telnet, The code (without encryption) is available via anonymous ftp
+from ftp.cray.com, in src/telnet/telnet.YY.MM.DD.NE.tar.Z, where
+YY.MM.DD is replaced with the year, month and day of the release.
+If you can't find it at one of these places, at some point in the
+near future information about the latest releases should be available
+from ftp.borman.com.
+
+In addition, the version with the encryption code is available via
+ftp from net-dist.mit.edu, in the directory /pub/telnet. There
+is a README file there that gives further information on how
+to get the distribution.
+
+Questions, comments, bug reports and bug fixes can be sent to
+one of these addresses:
+ dab@borman.com
+ dab@cray.com
+ dab@bsdi.com
+
+This release is mainly bug fixes and code cleanup.
+
+ Replace all calls to bcopy()/bzero() with calls to
+ memmove()/memset() and all calls to index()/rindex()
+ with calls to strchr()/strrchr().
+
+ Add some missing diagnostics for option tracing
+ to telnetd.
+
+ Add support for BSDI 2.0 and Solaris 2.4.
+
+ Add support for UNICOS 8.0
+
+ Get rid of expanded tabs and trailing white spaces.
+
+ From Paul Vixie:
+ Fix for telnet going into an endless spin
+ when the session dies abnormally.
+
+ From Jef Poskanzer:
+ Changes to allow telnet to compile
+ under SunOS 3.5.
+
+ From Philip Guenther:
+ makeutx() doesn't expand utmpx,
+ use pututxline() instead.
+
+ From Chris Torek:
+ Add a sleep(1) before execing login
+ to avoid race condition that can eat
+ up the login prompt.
+ Use terminal speed directly if it is
+ not an encoded value.
+
+ From Steve Parker:
+ Fix to realloc() call. Fix for execing
+ login on solaris with no user name.
+
+January 19, 1994
+
+This is a list of some of the changes since the last tar release
+of telnet/telnetd. There are probably other changes that aren't
+listed here, but this should hit a lot of the main ones.
+
+ General:
+ Changed #define for AUTHENTICATE to AUTHENTICATION
+ Changed #define for ENCRYPT to ENCRYPTION
+ Changed #define for DES_ENCRYPT to DES_ENCRYPTION
+
+ Added support for SPX authentication: -DSPX
+
+ Added support for Kerberos Version 5 authentication: -DKRB5
+
+ Added support for ANSI C function prototypes
+
+ Added support for the NEW-ENVIRON option (RFC-1572)
+ including support for USERVAR.
+
+ Made support for the old Environment Option (RFC-1408)
+ conditional on -DOLD_ENVIRON
+
+ Added #define ENV_HACK - support for RFC 1571
+
+ The encryption code is removed from the public distributions.
+ Domestic 4.4 BSD distributions contain the encryption code.
+
+ ENV_HACK: Code to deal with systems that only implement
+ the old ENVIRON option, and have reversed definitions
+ of ENV_VAR and ENV_VAL. Also fixes ENV processing in
+ client to handle things besides just the default set...
+
+ NO_BSD_SETJMP: UNICOS configuration for
+ UNICOS 6.1/6.0/5.1/5.0 systems.
+
+ STREAMSPTY: Use /dev/ptmx to get a clean pty. This
+ is for SVr4 derivatives (Like Solaris)
+
+ UTMPX: For systems that have /etc/utmpx. This is for
+ SVr4 derivatives (Like Solaris)
+
+ Definitions for BSDI 1.0
+
+ Definitions for 4.3 Reno and 4.4 BSD.
+
+ Definitions for UNICOS 8.0 and UNICOS 7.C
+
+ Definitions for Solaris 2.0
+
+ Definitions for HP-UX 8.0
+
+ Latest Copyright notices from Berkeley.
+
+ FLOW-CONTROL: support for RFC-XXXx
+
+
+ Client Specific:
+
+ Fix the "send" command to not send garbage...
+
+ Fix status message for "skiprc"
+
+ Make sure to send NAWS after telnet has been suspended
+ or an external command has been run, if the window size
+ has changed.
+
+ sysV88 support.
+
+ Server Specific:
+
+ Support flowcontrol option in non-linemode servers.
+
+ -k Server supports Kludge Linemode, but will default to
+ either single character mode or real Linemode support.
+ The user will have to explicitly ask to switch into
+ kludge linemode. ("stty extproc", or escape back to
+ to telnet and say "mode line".)
+
+ -u Specify the length of the hostname field in the utmp
+ file. Hostname longer than this length will be put
+ into the utmp file in dotted decimal notation, rather
+ than putting in a truncated hostname.
+
+ -U Registered hosts only. If a reverse hostname lookup
+ fails, the connection will be refused.
+
+ -f/-F
+ Allows forwarding of credentials for KRB5.
Februrary 22, 1991:
@@ -30,9 +195,9 @@ Februrary 22, 1991:
AUTHENTICATION option is fairly well defined, and
an option number has been assigned to it. The
ENCRYPTION option is still in a state of flux; an
- option number has NOT been assigned to it yet.
- The code is provided in this release for experimental
- and testing purposes.
+ option number has been assigned to, but it is still
+ subject to change. The code is provided in this release
+ for experimental and testing purposes.
The telnet "send" command can now be used to send
do/dont/will/wont commands, with any telnet option
@@ -50,13 +215,20 @@ Februrary 22, 1991:
A new telnet command, "auth" has been added (if
AUTHENTICATE is defined). It has four sub-commands,
- "status", "debug", "disable", "enable" and "help".
+ "status", "disable", "enable" and "help".
A new telnet command, "encrypt" has been added (if
ENCRYPT is defined). It has many sub-commands:
"enable", "type", "start", "stop", "input",
- "-input", "output", "-output", "status", "auto",
- "verbose", "debug", and "help".
+ "-input", "output", "-output", "status", and "help".
+
+ The LOGOUT option is now supported by both telnet
+ and telnetd, a new command, "logout", was added
+ to support this.
+
+ Several new toggle options were added:
+ "autoencrypt", "autodecrypt", "autologin", "authdebug",
+ "encdebug", "skiprc", "verbose_encrypt"
An "rlogin" interface has been added. If the program
is named "rlogin", or the "-r" flag is given, then
@@ -477,10 +649,6 @@ telnet.state:
with option negotiation loops. The algorithm that is
used is described in this file.
-tmac.doc:
- Macros for use in formatting the man pages on non-4.3Reno
- systems.
-
telnet:
This directory contains the client code. No kernel changes are
needed to use this code.
@@ -496,6 +664,13 @@ libtelnet:
arpa:
This directory has a new <arpa/telnet.h>
+libtelnet/Makefile.4.4:
+telnet/Makefile.4.4:
+telnetd/Makefile.4.4:
+ These are the makefiles that can be used on a 4.3Reno
+ system when this software is installed in /usr/src/lib/libtelnet,
+ /usr/src/libexec/telnetd, and /usr/src/usr.bin/telnet.
+
The following TELNET options are supported:
@@ -537,6 +712,8 @@ The following TELNET options are supported:
ECHO: As per RFC 857
+ LOGOUT: As per RFC 727
+
STATUS:
The server will send its current status upon
request. It does not ask for the clients status.
@@ -559,7 +736,7 @@ The following TELNET options are supported:
but the definitions for the specific authentication
schemes is still in a state of flux.
- ENCRYPT:
+ ENCRYPTION:
This option is currently being defined by the IETF
Telnet Working Group, and an RFC has not yet been
issued. The draft RFC is still in a state of flux,
diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c
index a7224d1..41ef5cd 100644
--- a/usr.bin/telnet/commands.c
+++ b/usr.bin/telnet/commands.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)commands.c 8.2 (Berkeley) 12/15/93";
+static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
#endif /* not lint */
#if defined(unix)
@@ -76,9 +76,9 @@ static char sccsid[] = "@(#)commands.c 8.2 (Berkeley) 12/15/93";
#include <netinet/ip.h>
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
-#endif MAXHOSTNAMELEN
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 64
+#endif MAXHOSTNAMELEN
#if defined(IPPROTO_IP) && defined(IP_TOS)
int tos = -1;
@@ -234,7 +234,7 @@ control(c)
* the "send" command.
*
*/
-
+
struct sendlist {
char *name; /* How user refers to it (case independent) */
char *help; /* Help information (0 ==> no help) */
@@ -1363,7 +1363,7 @@ suspend()
(void) kill(0, SIGTSTP);
/*
* If we didn't get the window size before the SUSPEND, but we
- * can get them now (???), then send the NAWS to make sure that
+ * can get them now (?), then send the NAWS to make sure that
* we are set up for the right window size.
*/
if (TerminalWindowSize(&newrows, &newcols) && connected &&
@@ -1403,12 +1403,12 @@ shell(argc, argv)
* Fire up the shell in the child.
*/
register char *shellp, *shellname;
- extern char *rindex();
+ extern char *strrchr();
shellp = getenv("SHELL");
if (shellp == NULL)
shellp = "/bin/sh";
- if ((shellname = rindex(shellp, '/')) == 0)
+ if ((shellname = strrchr(shellp, '/')) == 0)
shellname = shellp;
else
shellname++;
@@ -1544,14 +1544,14 @@ slccmd(argc, argv)
}
c = getslc(argv[1]);
if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('slc ?' for help).\n",
+ fprintf(stderr, "'%s': unknown argument ('slc ?' for help).\n",
argv[1]);
- return 0;
+ return 0;
}
if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\n",
+ fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\n",
argv[1]);
- return 0;
+ return 0;
}
(*c->handler)(c->arg);
slcstate();
@@ -1640,14 +1640,14 @@ env_cmd(argc, argv)
}
c = getenvcmd(argv[1]);
if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('environ ?' for help).\n",
+ fprintf(stderr, "'%s': unknown argument ('environ ?' for help).\n",
argv[1]);
- return 0;
+ return 0;
}
if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\n",
+ fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\n",
argv[1]);
- return 0;
+ return 0;
}
if (c->narg + 2 != argc) {
fprintf(stderr,
@@ -1690,10 +1690,10 @@ env_init()
extern char **environ;
register char **epp, *cp;
register struct env_lst *ep;
- extern char *index();
+ extern char *strchr();
for (epp = environ; *epp; epp++) {
- if (cp = index(*epp, '=')) {
+ if (cp = strchr(*epp, '=')) {
*cp = '\0';
ep = env_define((unsigned char *)*epp,
(unsigned char *)cp+1);
@@ -1708,9 +1708,9 @@ env_init()
*/
if ((ep = env_find("DISPLAY"))
&& ((*ep->value == ':')
- || (strncmp((char *)ep->value, "unix:", 5) == 0))) {
+ || (strncmp((char *)ep->value, "unix:", 5) == 0))) {
char hbuf[256+1];
- char *cp2 = index((char *)ep->value, ':');
+ char *cp2 = strchr((char *)ep->value, ':');
gethostname(hbuf, 256);
hbuf[256] = '\0';
@@ -1802,7 +1802,7 @@ env_send(var)
{
register struct env_lst *ep;
- if (my_state_is_wont(TELOPT_NEW_ENVIRON)
+ if (my_state_is_wont(TELOPT_NEW_ENVIRON)
#ifdef OLD_ENVIRON
&& my_state_is_wont(TELOPT_OLD_ENVIRON)
#endif
@@ -1915,8 +1915,8 @@ struct authlist {
};
extern int
- auth_enable P((int)),
- auth_disable P((int)),
+ auth_enable P((char *)),
+ auth_disable P((char *)),
auth_status P((void));
static int
auth_help P((void));
@@ -1955,17 +1955,23 @@ auth_cmd(argc, argv)
{
struct authlist *c;
+ if (argc < 2) {
+ fprintf(stderr,
+ "Need an argument to 'auth' command. 'auth ?' for help.\n");
+ return 0;
+ }
+
c = (struct authlist *)
genget(argv[1], (char **) AuthList, sizeof(struct authlist));
if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('auth ?' for help).\n",
+ fprintf(stderr, "'%s': unknown argument ('auth ?' for help).\n",
argv[1]);
- return 0;
+ return 0;
}
if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\n",
+ fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\n",
argv[1]);
- return 0;
+ return 0;
}
if (c->narg + 2 != argc) {
fprintf(stderr,
@@ -2011,7 +2017,7 @@ struct encryptlist EncryptList[] = {
EncryptEnable, 1, 1, 2 },
{ "disable", "Disable encryption. ('encrypt enable ?' for more)",
EncryptDisable, 0, 1, 2 },
- { "type", "Set encryptiong type. ('encrypt type ?' for more)",
+ { "type", "Set encryption type. ('encrypt type ?' for more)",
EncryptType, 0, 1, 1 },
{ "start", "Start encryption. ('encrypt start ?' for more)",
EncryptStart, 1, 0, 1 },
@@ -2055,17 +2061,23 @@ encrypt_cmd(argc, argv)
{
struct encryptlist *c;
+ if (argc < 2) {
+ fprintf(stderr,
+ "Need an argument to 'encrypt' command. 'encrypt ?' for help.\n");
+ return 0;
+ }
+
c = (struct encryptlist *)
genget(argv[1], (char **) EncryptList, sizeof(struct encryptlist));
if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('encrypt ?' for help).\n",
+ fprintf(stderr, "'%s': unknown argument ('encrypt ?' for help).\n",
argv[1]);
- return 0;
+ return 0;
}
if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('encrypt ?' for help).\n",
+ fprintf(stderr, "'%s': ambiguous argument ('encrypt ?' for help).\n",
argv[1]);
- return 0;
+ return 0;
}
argc -= 2;
if (argc < c->minarg || argc > c->maxarg) {
@@ -2228,7 +2240,7 @@ tn(argc, argv)
char *cmd, *hostp = 0, *portp = 0, *user = 0;
/* clear the socket address prior to use */
- bzero((char *)&sin, sizeof(sin));
+ memset((char *)&sin, 0, sizeof(sin));
if (connected) {
printf("?Already connected to %s\n", hostname);
@@ -2246,7 +2258,7 @@ tn(argc, argv)
cmd = *argv;
--argc; ++argv;
while (argc) {
- if (isprefix(*argv, "help") || isprefix(*argv, "?"))
+ if (strcmp(*argv, "help") == 0 || isprefix(*argv, "?"))
goto usage;
if (strcmp(*argv, "-l") == 0) {
--argc; ++argv;
@@ -2311,17 +2323,17 @@ tn(argc, argv)
if (host) {
sin.sin_family = host->h_addrtype;
#if defined(h_addr) /* In 4.3, this is a #define */
- memcpy((caddr_t)&sin.sin_addr,
+ memmove((caddr_t)&sin.sin_addr,
host->h_addr_list[0], host->h_length);
#else /* defined(h_addr) */
- memcpy((caddr_t)&sin.sin_addr, host->h_addr, host->h_length);
+ memmove((caddr_t)&sin.sin_addr, host->h_addr, host->h_length);
#endif /* defined(h_addr) */
strncpy(_hostname, host->h_name, sizeof(_hostname));
_hostname[sizeof(_hostname)-1] = '\0';
hostname = _hostname;
} else {
herror(hostp);
- setuid(getuid());
+ setuid(getuid());
return 0;
}
}
@@ -2341,7 +2353,7 @@ tn(argc, argv)
sin.sin_port = sp->s_port;
else {
printf("%s: bad port number\n", portp);
- setuid(getuid());
+ setuid(getuid());
return 0;
}
} else {
@@ -2355,7 +2367,7 @@ tn(argc, argv)
sp = getservbyname("telnet", "tcp");
if (sp == 0) {
fprintf(stderr, "telnet: tcp/telnet: unknown service\n");
- setuid(getuid());
+ setuid(getuid());
return 0;
}
sin.sin_port = sp->s_port;
@@ -2405,7 +2417,7 @@ tn(argc, argv)
errno = oerrno;
perror((char *)0);
host->h_addr_list++;
- memcpy((caddr_t)&sin.sin_addr,
+ memmove((caddr_t)&sin.sin_addr,
host->h_addr_list[0], host->h_length);
(void) NetClose(net);
continue;
@@ -2589,7 +2601,7 @@ command(top, tbuf, cnt)
goto getline;
*cp = '\0';
if (rlogin == _POSIX_VDISABLE)
- printf("%s\n", line);
+ printf("%s\n", line);
} else {
getline:
if (rlogin != _POSIX_VDISABLE)
@@ -2792,10 +2804,10 @@ cmdrc(m1, m2)
* *cpp: If *cpp was equal to NULL, it will be filled
* in with a pointer to our static area that has
* the option filled in. This will be 32bit aligned.
- *
+ *
* *lenp: This will be filled in with how long the option
* pointed to by *cpp is.
- *
+ *
*/
unsigned long
sourceroute(arg, cpp, lenp)
@@ -2889,16 +2901,16 @@ sourceroute(arg, cpp, lenp)
sin_addr.s_addr = tmp;
} else if (host = gethostbyname(cp)) {
#if defined(h_addr)
- memcpy((caddr_t)&sin_addr,
+ memmove((caddr_t)&sin_addr,
host->h_addr_list[0], host->h_length);
#else
- memcpy((caddr_t)&sin_addr, host->h_addr, host->h_length);
+ memmove((caddr_t)&sin_addr, host->h_addr, host->h_length);
#endif
} else {
*cpp = cp;
return(0);
}
- memcpy(lsrp, (char *)&sin_addr, 4);
+ memmove(lsrp, (char *)&sin_addr, 4);
lsrp += 4;
if (cp2)
cp = cp2;
diff --git a/usr.bin/telnet/externs.h b/usr.bin/telnet/externs.h
index b721992..83ba07b 100644
--- a/usr.bin/telnet/externs.h
+++ b/usr.bin/telnet/externs.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)externs.h 8.2 (Berkeley) 12/15/93
+ * @(#)externs.h 8.3 (Berkeley) 5/30/95
*/
#ifndef BSD
@@ -83,8 +83,9 @@ typedef unsigned char cc_t;
#ifndef NO_STRING_H
#include <string.h>
-#endif
+#else
#include <strings.h>
+#endif
#ifndef _POSIX_VDISABLE
# ifdef sun
@@ -118,12 +119,12 @@ extern int
flushout, /* flush output */
connected, /* Are we connected to the other side? */
globalmode, /* Mode tty should be in */
- In3270, /* Are we in 3270 mode? */
+ In3270, /* Are we in 3270 mode? */
telnetport, /* Are we connected to the telnet port? */
localflow, /* Flow control handled locally */
restartany, /* If flow control, restart output on any character */
localchars, /* we recognize interrupt/quit */
- donelclchars, /* the user has set "localchars" */
+ donelclchars, /* the user has set "localchars" */
showoptions,
net, /* Network file descriptor */
tin, /* Terminal input file descriptor */
@@ -144,7 +145,7 @@ extern int
#endif /* defined(TN3270) */
termdata, /* Print out terminal data flow */
#endif /* defined(unix) */
- debug; /* Debug level */
+ debug; /* Debug level */
extern cc_t escape; /* Escape to command mode */
extern cc_t rlogin; /* Rlogin mode escape character */
diff --git a/usr.bin/telnet/main.c b/usr.bin/telnet/main.c
index ce22840..6073dbf 100644
--- a/usr.bin/telnet/main.c
+++ b/usr.bin/telnet/main.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 12/15/93";
+static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
#include <sys/types.h>
@@ -49,8 +49,8 @@ static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 12/15/93";
/* These values need to be the same as defined in libtelnet/kerberos5.c */
/* Either define them in both places, or put in some common header file. */
-#define OPTS_FORWARD_CREDS 0x00000002
-#define OPTS_FORWARDABLE_CREDS 0x00000001
+#define OPTS_FORWARD_CREDS 0x00000002
+#define OPTS_FORWARDABLE_CREDS 0x00000001
#if 0
#define FORWARD
@@ -65,7 +65,7 @@ tninit()
init_terminal();
init_network();
-
+
init_telnet();
init_sys();
@@ -192,7 +192,7 @@ main(argc, argv)
case 'f':
#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
if (forward_flags & OPTS_FORWARD_CREDS) {
- fprintf(stderr,
+ fprintf(stderr,
"%s: Only one of -f and -F allowed.\n",
prompt);
usage();
@@ -200,14 +200,14 @@ main(argc, argv)
forward_flags |= OPTS_FORWARD_CREDS;
#else
fprintf(stderr,
- "%s: Warning: -f ignored, no Kerberos V5 support.\n",
+ "%s: Warning: -f ignored, no Kerberos V5 support.\n",
prompt);
#endif
break;
case 'F':
#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
if (forward_flags & OPTS_FORWARD_CREDS) {
- fprintf(stderr,
+ fprintf(stderr,
"%s: Only one of -f and -F allowed.\n",
prompt);
usage();
@@ -216,7 +216,7 @@ main(argc, argv)
forward_flags |= OPTS_FORWARDABLE_CREDS;
#else
fprintf(stderr,
- "%s: Warning: -F ignored, no Kerberos V5 support.\n",
+ "%s: Warning: -F ignored, no Kerberos V5 support.\n",
prompt);
#endif
break;
diff --git a/usr.bin/telnet/ring.c b/usr.bin/telnet/ring.c
index 1080d12..37dfda8 100644
--- a/usr.bin/telnet/ring.c
+++ b/usr.bin/telnet/ring.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 6/6/93";
+static char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
/*
@@ -295,7 +295,7 @@ ring_supply_data(ring, buffer, count)
while (count) {
i = MIN(count, ring_empty_consecutive(ring));
- memcpy(ring->supply, buffer, i);
+ memmove(ring->supply, buffer, i);
ring_supplied(ring, i);
count -= i;
buffer += i;
@@ -317,7 +317,7 @@ ring_consume_data(ring, buffer, count)
while (count) {
i = MIN(count, ring_full_consecutive(ring));
- memcpy(buffer, ring->consume, i);
+ memmove(buffer, ring->consume, i);
ring_consumed(ring, i);
count -= i;
buffer += i;
diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c
index 85414e2..281b8bd 100644
--- a/usr.bin/telnet/sys_bsd.c
+++ b/usr.bin/telnet/sys_bsd.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)sys_bsd.c 8.2 (Berkeley) 12/15/93";
+static char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95";
#endif /* not lint */
/*
@@ -223,7 +223,7 @@ TerminalSpecialChars(c)
/*
* Flush output to the terminal
*/
-
+
void
TerminalFlushOutput()
{
@@ -328,7 +328,7 @@ TerminalDefaultChars()
nttyb.sg_kill = ottyb.sg_kill;
nttyb.sg_erase = ottyb.sg_erase;
#else /* USE_TERMIO */
- memcpy(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc));
+ memmove(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc));
# ifndef VDISCARD
termFlushChar = CONTROL('O');
# endif
@@ -669,7 +669,11 @@ TerminalNewMode(f)
#endif
#ifdef SIGTSTP
(void) signal(SIGTSTP, SIG_DFL);
+# ifndef SOLARIS
(void) sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1)));
+# else SOLARIS
+ (void) sigrelse(SIGTSTP);
+# endif SOLARIS
#endif /* SIGTSTP */
#ifndef USE_TERMIO
ltc = oltc;
@@ -704,14 +708,51 @@ TerminalNewMode(f)
}
+/*
+ * Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD).
+ */
+#if B4800 != 4800
+#define DECODE_BAUD
+#endif
+
+#ifdef DECODE_BAUD
+#ifndef B7200
+#define B7200 B4800
+#endif
+
+#ifndef B14400
+#define B14400 B9600
+#endif
+
#ifndef B19200
-# define B19200 B9600
+# define B19200 B14400
+#endif
+
+#ifndef B28800
+#define B28800 B19200
#endif
#ifndef B38400
-# define B38400 B19200
+# define B38400 B28800
#endif
+#ifndef B57600
+#define B57600 B38400
+#endif
+
+#ifndef B76800
+#define B76800 B57600
+#endif
+
+#ifndef B115200
+#define B115200 B76800
+#endif
+
+#ifndef B230400
+#define B230400 B115200
+#endif
+
+
/*
* This code assumes that the values B0, B50, B75...
* are in ascending order. They do not have to be
@@ -721,20 +762,25 @@ struct termspeeds {
long speed;
long value;
} termspeeds[] = {
- { 0, B0 }, { 50, B50 }, { 75, B75 },
- { 110, B110 }, { 134, B134 }, { 150, B150 },
- { 200, B200 }, { 300, B300 }, { 600, B600 },
- { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 },
- { 4800, B4800 }, { 9600, B9600 }, { 19200, B19200 },
- { 38400, B38400 }, { -1, B38400 }
+ { 0, B0 }, { 50, B50 }, { 75, B75 },
+ { 110, B110 }, { 134, B134 }, { 150, B150 },
+ { 200, B200 }, { 300, B300 }, { 600, B600 },
+ { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 },
+ { 4800, B4800 }, { 7200, B7200 }, { 9600, B9600 },
+ { 14400, B14400 }, { 19200, B19200 }, { 28800, B28800 },
+ { 38400, B38400 }, { 57600, B57600 }, { 115200, B115200 },
+ { 230400, B230400 }, { -1, B230400 }
};
+#endif /* DECODE_BAUD */
void
TerminalSpeeds(ispeed, ospeed)
long *ispeed;
long *ospeed;
{
+#ifdef DECODE_BAUD
register struct termspeeds *tp;
+#endif /* DECODE_BAUD */
register long in, out;
out = cfgetospeed(&old_tc);
@@ -742,6 +788,7 @@ TerminalSpeeds(ispeed, ospeed)
if (in == 0)
in = out;
+#ifdef DECODE_BAUD
tp = termspeeds;
while ((tp->speed != -1) && (tp->value < in))
tp++;
@@ -751,6 +798,10 @@ TerminalSpeeds(ispeed, ospeed)
while ((tp->speed != -1) && (tp->value < out))
tp++;
*ospeed = tp->speed;
+#else /* DECODE_BAUD */
+ *ispeed = in;
+ *ospeed = out;
+#endif /* DECODE_BAUD */
}
int
@@ -946,7 +997,7 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll)
if (netout) {
FD_SET(net, &obits);
- }
+ }
if (ttyout) {
FD_SET(tout, &obits);
}
@@ -1085,7 +1136,7 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll)
int i;
i = recv(net, netiring.supply + c, canread - c, MSG_OOB);
if (i == c &&
- bcmp(netiring.supply, netiring.supply + c, i) == 0) {
+ memcmp(netiring.supply, netiring.supply + c, i) == 0) {
bogus_oob = 1;
first = 0;
} else if (i < 0) {
@@ -1134,6 +1185,8 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll)
if (FD_ISSET(tin, &ibits)) {
FD_CLR(tin, &ibits);
c = TerminalRead(ttyiring.supply, ring_empty_consecutive(&ttyiring));
+ if (c < 0 && errno == EIO)
+ c = 0;
if (c < 0 && errno == EWOULDBLOCK) {
c = 0;
} else {
diff --git a/usr.bin/telnet/telnet.1 b/usr.bin/telnet/telnet.1
index 27079d9..b996fea 100644
--- a/usr.bin/telnet/telnet.1
+++ b/usr.bin/telnet/telnet.1
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)telnet.1 8.5 (Berkeley) 3/1/94
+.\" @(#)telnet.1 8.6 (Berkeley) 6/1/94
.\"
-.Dd March 1, 1994
+.Dd June 1, 1994
.Dt TELNET 1
.Os BSD 4.2
.Sh NAME
@@ -139,6 +139,7 @@ there will be no escape character.
If Kerberos V5 authentication is being used, the
.Fl f
option allows the local credentials to be forwarded to the remote system.
+.ne 1i
.It Fl k Ar realm
If Kerberos authentication is being used, the
.Fl k
@@ -508,6 +509,7 @@ option.
This requires that the
.Dv LINEMODE
option be enabled.
+.ne 1i
.It Ic litecho Pq Ic \-litecho
Attempt to enable (disable) the
.Dv LIT_ECHO
@@ -641,6 +643,7 @@ command,
.Ic getstatus
will send the subnegotiation to request that the server send
its current option status.
+.ne 1i
.It Ic ip
Sends the
.Dv TELNET IP
@@ -966,6 +969,7 @@ The initial value for the suspend character is taken to be
the terminal's
.Ic suspend
character.
+.ne 1i
.It Ic tracefile
This is the file to which the output, caused by
.Ic netdata
@@ -1108,6 +1112,7 @@ stream does not start automatically. The autoencrypt
(autodecrypt) command states that encryption of the
output (input) stream should be enabled as soon as
possible.
+.sp
.Pp
Note: Because of export controls, the
.Dv TELNET ENCRYPT
@@ -1263,6 +1268,7 @@ protocol processing (having to do with
options).
The initial value for this toggle is
.Dv FALSE .
+.ne 1i
.It Ic prettydump
When the
.Ic netdata
diff --git a/usr.bin/telnet/telnet.c b/usr.bin/telnet/telnet.c
index 97f63e6..e792262 100644
--- a/usr.bin/telnet/telnet.c
+++ b/usr.bin/telnet/telnet.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)telnet.c 8.2 (Berkeley) 12/15/93";
+static char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95";
#endif /* not lint */
#include <sys/types.h>
@@ -57,7 +57,7 @@ static char sccsid[] = "@(#)telnet.c 8.2 (Berkeley) 12/15/93";
#include "general.h"
-#define strip(x) ((x)&0x7f)
+#define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x))
static unsigned char subbuffer[SUBBUFSIZE],
*subpointer, *subend; /* buffer for sub-options */
@@ -177,7 +177,7 @@ init_telnet()
ClearArray(options);
connected = In3270 = ISend = localflow = donebinarytoggle = 0;
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#if defined(AUTHENTICATION) || defined(ENCRYPTION)
auth_encrypt_connect(connected);
#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
restartany = -1;
@@ -623,7 +623,7 @@ mklist(buf, name)
register char c, *cp, **argvp, *cp2, **argv, **avt;
if (name) {
- if (strlen(name) > 40) {
+ if ((int)strlen(name) > 40) {
name = 0;
unknown[0] = name_unknown;
} else {
@@ -689,7 +689,7 @@ mklist(buf, name)
else if (islower(c))
*cp = toupper(c);
}
-
+
/*
* Check for an old V6 2 character name. If the second
* name points to the beginning of the buffer, and is
@@ -782,7 +782,7 @@ gettermname()
(setupterm(tname, 1, &err) == 0)) {
tnamep = mklist(termbuf, tname);
} else {
- if (tname && (strlen(tname) <= 40)) {
+ if (tname && ((int)strlen(tname) <= 40)) {
unknown[0] = tname;
upcase(tname);
} else
@@ -1810,7 +1810,7 @@ telrcv()
TTYADD('\n');
} else {
#ifdef ENCRYPTION
- if (decrypt_input)
+ if (decrypt_input)
(*decrypt_input)(-1);
#endif /* ENCRYPTION */
@@ -1834,7 +1834,7 @@ telrcv()
case TS_IAC:
process_iac:
switch (c) {
-
+
case WILL:
telrcv_state = TS_WILL;
continue;
@@ -2220,7 +2220,7 @@ Scheduler(block)
ring_full_consecutive(&ttyiring));
if (c) {
returnValue = 1;
- ring_consumed(&ttyiring, c);
+ ring_consumed(&ttyiring, c);
}
} else {
# endif /* defined(TN3270) */
@@ -2249,7 +2249,7 @@ telnet(user)
{
sys_telnet_init();
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#if defined(AUTHENTICATION) || defined(ENCRYPTION)
{
static char local_host[256] = { 0 };
@@ -2431,7 +2431,7 @@ netclear()
next = nextitem(next);
} while (wewant(next) && (nfrontp > next));
length = next-thisitem;
- memcpy(good, thisitem, length);
+ memmove(good, thisitem, length);
good += length;
thisitem = next;
} else {
diff --git a/usr.bin/telnet/terminal.c b/usr.bin/telnet/terminal.c
index b6d3b86..b5ceeda 100644
--- a/usr.bin/telnet/terminal.c
+++ b/usr.bin/telnet/terminal.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)terminal.c 8.1 (Berkeley) 6/6/93";
+static char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95";
#endif /* not lint */
#include <arpa/telnet.h>
@@ -140,7 +140,8 @@ ttyflush(drop)
n1 = n0 - n;
if (!drop)
n1 = TerminalWrite(ttyoring.bottom, n1);
- n += n1;
+ if (n1 > 0)
+ n += n1;
}
ring_consumed(&ttyoring, n);
}
diff --git a/usr.bin/telnet/tn3270.c b/usr.bin/telnet/tn3270.c
index 1f285cf..a75cd1e 100644
--- a/usr.bin/telnet/tn3270.c
+++ b/usr.bin/telnet/tn3270.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)tn3270.c 8.1 (Berkeley) 6/6/93";
+static char sccsid[] = "@(#)tn3270.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
#include <sys/types.h>
@@ -242,7 +242,7 @@ Push3270()
if (save) {
if (Ifrontp+save > Ibuf+sizeof Ibuf) {
if (Ibackp != Ibuf) {
- memcpy(Ibuf, Ibackp, Ifrontp-Ibackp);
+ memmove(Ibuf, Ibackp, Ifrontp-Ibackp);
Ifrontp -= (Ibackp-Ibuf);
Ibackp = Ibuf;
}
diff --git a/usr.bin/telnet/utilities.c b/usr.bin/telnet/utilities.c
index 70cf567..06d08a4 100644
--- a/usr.bin/telnet/utilities.c
+++ b/usr.bin/telnet/utilities.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)utilities.c 8.2 (Berkeley) 12/15/93";
+static char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
#define TELOPTS
@@ -593,7 +593,7 @@ printsub(direction, pointer, length)
break;
}
break;
-
+
case LM_SLC:
fprintf(NetTrace, "SLC");
for (i = 2; i < length - 2; i += 3) {
@@ -725,7 +725,7 @@ printsub(direction, pointer, length)
fprintf(NetTrace, "\n");
break;
-
+
default:
fprintf(NetTrace, " %d", pointer[i]);
break;
OpenPOWER on IntegriCloud