4.4BSD-Lite2 distribution

This commit is contained in:
Miles Bader
1997-03-01 16:22:12 +00:00
parent eee191e266
commit bde72eeb4e
46 changed files with 1184 additions and 754 deletions

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)cmds.c 8.5 (Berkeley) 4/6/94";
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#endif /* not lint */
/*
@@ -2009,6 +2009,17 @@ LOOP:
return (new);
}
void
setpassive(argc, argv)
int argc;
char *argv[];
{
passivemode = !passivemode;
printf("Passive mode %s.\n", onoff(passivemode));
code = passivemode;
}
void
setsunique(argc, argv)
int argc;

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)cmdtab.c 8.3 (Berkeley) 4/2/94";
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#endif /* not lint */
#include <stdio.h>
@@ -94,6 +94,7 @@ char rmtstatushelp[]="show status of remote machine";
char runiquehelp[] = "toggle store unique for local files";
char resethelp[] = "clear queued command replies";
char sendhelp[] = "send one file";
char passivehelp[] = "enter passive transfer mode";
char sitehelp[] = "send site specific command to remote server\n\t\tTry \"rhelp site\" or \"site help\" for more information";
char shellhelp[] = "escape to the shell";
char sizecmdhelp[] = "show size of remote file";
@@ -150,6 +151,7 @@ struct cmd cmdtab[] = {
{ "nlist", nlisthelp, 1, 1, 1, ls },
{ "ntrans", ntranshelp, 0, 0, 1, setntrans },
{ "open", connecthelp, 0, 0, 1, setpeer },
{ "passive", passivehelp, 0, 0, 0, setpassive },
{ "prompt", prompthelp, 0, 0, 0, setprompt },
{ "proxy", proxyhelp, 0, 0, 1, doproxy },
{ "sendport", porthelp, 0, 0, 0, setport },

View File

@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)extern.h 8.2 (Berkeley) 4/3/94
* @(#)extern.h 8.3 (Berkeley) 10/9/94
*/
struct timeval;
@@ -120,6 +120,7 @@ void setglob __P((int, char **));
void sethash __P((int, char **));
void setnmap __P((int, char **));
void setntrans __P((int, char **));
void setpassive __P((int, char **));
void setpeer __P((int, char **));
void setport __P((int, char **));
void setprompt __P((int, char **));

View File

@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)ftp.1 8.2 (Berkeley) 12/30/93
.\" @(#)ftp.1 8.3 (Berkeley) 10/9/94
.\"
.Dd December 30, 1993
.Dd October 9, 1994
.Dt FTP 1
.Os BSD 4.2
.Sh NAME
@@ -360,7 +360,7 @@ If no local file is specified, or if
is
.Sq Fl ,
the output is sent to the terminal.
.It Ic macdefNs Ar macro-name
.It Ic macdef Ar macro-name
Define a macro.
Subsequent lines are stored as the macro
.Ar macro-name ;
@@ -601,6 +601,27 @@ will also attempt to automatically log the user in to
the
.Tn FTP
server (see below).
.It Ic passive
Toggle passive mode. If passive mode is turned on
(default is off), the ftp client will
send a
.Dv PASV
command for all data connections instead of the usual
.Dv PORT
command. The
.Dv PASV
command requests that the remote server open a port for the data connection
and return the address of that port. The remote server listens on that
port and the client connects to it. When using the more traditional
.Dv PORT
command, the client listens on a port and sends that address to the remote
server, who connects back to it. Passive mode is useful when using
.Nm ftp
through a gateway router or host that controls the directionality of
traffic.
(Note that though ftp servers are required to support the
.Dv PASV
command by RFC 1123, some do not.)
.It Ic prompt
Toggle interactive prompting.
Interactive prompting

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)ftp.c 8.4 (Berkeley) 4/6/94";
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#endif /* not lint */
#include <sys/param.h>
@@ -646,10 +646,10 @@ sendrequest(cmd, local, remote, printnames)
}
break;
}
(void) gettimeofday(&stop, (struct timezone *)0);
if (closefunc != NULL)
(*closefunc)(fin);
(void) fclose(dout);
(void) gettimeofday(&stop, (struct timezone *)0);
(void) getreply(0);
(void) signal(SIGINT, oldintr);
if (oldintp)
@@ -658,7 +658,6 @@ sendrequest(cmd, local, remote, printnames)
ptransfer("sent", bytes, &start, &stop);
return;
abort:
(void) gettimeofday(&stop, (struct timezone *)0);
(void) signal(SIGINT, oldintr);
if (oldintp)
(void) signal(SIGPIPE, oldintp);
@@ -676,6 +675,7 @@ abort:
code = -1;
if (closefunc != NULL && fin != NULL)
(*closefunc)(fin);
(void) gettimeofday(&stop, (struct timezone *)0);
if (bytes > 0)
ptransfer("sent", bytes, &start, &stop);
}
@@ -955,8 +955,8 @@ break2:
(void) signal(SIGINT, oldintr);
if (oldintp)
(void) signal(SIGPIPE, oldintp);
(void) gettimeofday(&stop, (struct timezone *)0);
(void) fclose(din);
(void) gettimeofday(&stop, (struct timezone *)0);
(void) getreply(0);
if (bytes > 0 && is_retr)
ptransfer("received", bytes, &start, &stop);
@@ -965,7 +965,6 @@ abort:
/* abort using RFC959 recommended IP,SYNC sequence */
(void) gettimeofday(&stop, (struct timezone *)0);
if (oldintp)
(void) signal(SIGPIPE, oldintr);
(void) signal(SIGINT, SIG_IGN);
@@ -985,6 +984,7 @@ abort:
(*closefunc)(fout);
if (din)
(void) fclose(din);
(void) gettimeofday(&stop, (struct timezone *)0);
if (bytes > 0)
ptransfer("received", bytes, &start, &stop);
(void) signal(SIGINT, oldintr);
@@ -1000,6 +1000,62 @@ initconn()
char *p, *a;
int result, len, tmpno = 0;
int on = 1;
int a0, a1, a2, a3, p0, p1;
if (passivemode) {
data = socket(AF_INET, SOCK_STREAM, 0);
if (data < 0) {
perror("ftp: socket");
return(1);
}
if ((options & SO_DEBUG) &&
setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
sizeof (on)) < 0)
perror("ftp: setsockopt (ignored)");
if (command("PASV") != COMPLETE) {
printf("Passive mode refused.\n");
goto bad;
}
/*
* What we've got at this point is a string of comma
* separated one-byte unsigned integer values.
* The first four are the an IP address. The fifth is
* the MSB of the port number, the sixth is the LSB.
* From that we'll prepare a sockaddr_in.
*/
if (sscanf(pasv,"%d,%d,%d,%d,%d,%d",
&a0, &a1, &a2, &a3, &p0, &p1) != 6) {
printf("Passive mode address scan failure. "
"Shouldn't happen!\n");
goto bad;
}
bzero(&data_addr, sizeof(data_addr));
data_addr.sin_family = AF_INET;
a = (char *)&data_addr.sin_addr.s_addr;
a[0] = a0 & 0xff;
a[1] = a1 & 0xff;
a[2] = a2 & 0xff;
a[3] = a3 & 0xff;
p = (char *)&data_addr.sin_port;
p[0] = p0 & 0xff;
p[1] = p1 & 0xff;
if (connect(data, (struct sockaddr *)&data_addr,
sizeof(data_addr)) < 0) {
perror("ftp: connect");
goto bad;
}
#ifdef IP_TOS
on = IPTOS_THROUGHPUT;
if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on,
sizeof(int)) < 0)
perror("ftp: setsockopt TOS (ignored)");
#endif
return(0);
}
noport:
data_addr = myctladdr;
@@ -1070,6 +1126,9 @@ dataconn(lmode)
struct sockaddr_in from;
int s, fromlen = sizeof (from), tos;
if (passivemode)
return (fdopen(data, lmode));
s = accept(data, (struct sockaddr *) &from, &fromlen);
if (s < 0) {
warn("accept");
@@ -1093,15 +1152,16 @@ ptransfer(direction, bytes, t0, t1)
struct timeval *t0, *t1;
{
struct timeval td;
float s, bs;
float s;
long bs;
if (verbose) {
tvsub(&td, t1, t0);
s = td.tv_sec + (td.tv_usec / 1000000.);
#define nz(x) ((x) == 0 ? 1 : (x))
bs = bytes / nz(s);
printf("%ld bytes %s in %.2g seconds (%.2g Kbytes/s)\n",
bytes, direction, s, bs / 1024.);
printf("%ld bytes %s in %.3g seconds (%ld bytes/s)\n",
bytes, direction, s, bs);
}
}

View File

@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)ftp_var.h 8.3 (Berkeley) 4/2/94
* @(#)ftp_var.h 8.4 (Berkeley) 10/9/94
*/
/*
@@ -66,6 +66,7 @@ int mapflag; /* use mapin mapout templates on file names */
int code; /* return/reply code for ftp command */
int crflag; /* if 1, strip car. rets. on ascii gets */
char pasv[64]; /* passive port for proxy data connection */
int passivemode; /* passive mode enabled */
char *altarg; /* argv[1] with no shell-like preprocessing */
char ntin[17]; /* input translation table */
char ntout[17]; /* output translation table */

View File

@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 4/3/94";
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#endif /* not lint */
/*
@@ -78,7 +78,7 @@ main(argc, argv)
autologin = 1;
while ((ch = getopt(argc, argv, "dgintv")) != EOF) {
switch (*cp) {
switch (ch) {
case 'd':
options |= SO_DEBUG;
debug++;
@@ -118,6 +118,7 @@ main(argc, argv)
verbose++;
cpend = 0; /* no pending replies */
proxy = 0; /* proxy not active */
passivemode = 0; /* passive mode not active */
crflag = 1; /* strip c.r. on ascii gets */
sendport = -1; /* not using ports */
/*

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94";
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
#endif /* not lint */
#include <sys/types.h>
@@ -144,7 +144,7 @@ next:
}
break;
case PASSWD:
if (strcmp(*aname, "anonymous") &&
if ((*aname == NULL || strcmp(*aname, "anonymous")) &&
fstat(fileno(cfile), &stb) >= 0 &&
(stb.st_mode & 077) != 0) {
warnx("Error: .netrc file is readable by others.");

View File

@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)ftpd.8 8.2 (Berkeley) 4/19/94
.\" @(#)ftpd.8 8.3 (Berkeley) 6/1/94
.\"
.Dd April 19, 1994
.Dd June 1, 1994
.Dt FTPD 8
.Os BSD 4.2
.Sh NAME
@@ -228,6 +228,7 @@ subtree be constructed with care, following these rules:
Make the home directory owned by
.Dq root
and unwritable by anyone.
.ne 1i
.It Pa ~ftp/bin
Make this directory owned by
.Dq root

View File

@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95";
#endif /* not lint */
/*
@@ -483,7 +483,7 @@ checkuser(name)
*p = '\0';
if (line[0] == '#')
continue;
if (strcmp(p, name) == 0) {
if (strcmp(line, name) == 0) {
found = 1;
break;
}

View File

@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)inetd.8 8.3 (Berkeley) 4/13/94
.\" @(#)inetd.8 8.4 (Berkeley) 6/1/94
.\"
.Dd April 13, 1994
.Dd June 1, 1994
.Dt INETD 8
.Os BSD 4.4
.Sh NAME
@@ -301,6 +301,7 @@ causes
.Nm inetd
to list TCPMUX services in
.Pa inetd.conf .
.ne 1i
.Sh "EXAMPLES"
.Pp
Here are several example service entries for the various types of services:

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)auth.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
/*
@@ -222,6 +222,9 @@ auth_init(name, server)
Name,
ap->type, ap->way);
}
else if (auth_debug_mode)
printf(">>>%s: Init failed: auth type %d %d\r\n",
Name, ap->type, ap->way);
++ap;
}
}
@@ -246,7 +249,7 @@ getauthmask(type, maskp)
{
register int x;
if (strcasecmp(type, AUTHTYPE_NAME(0))) {
if (!strcasecmp(type, AUTHTYPE_NAME(0))) {
*maskp = -1;
return(1);
}
@@ -262,14 +265,14 @@ getauthmask(type, maskp)
int
auth_enable(type)
int type;
char *type;
{
return(auth_onoff(type, 1));
}
int
auth_disable(type)
int type;
char *type;
{
return(auth_onoff(type, 0));
}
@@ -279,15 +282,20 @@ auth_onoff(type, on)
char *type;
int on;
{
int mask = -1;
int i, mask = -1;
Authenticator *ap;
if (!strcasecmp(type, "?") || !strcasecmp(type, "help")) {
printf("auth %s 'type'\n", on ? "enable" : "disable");
printf("auth %s 'type'\n", on ? "enable" : "disable");
printf("Where 'type' is one of:\n");
printf("\t%s\n", AUTHTYPE_NAME(0));
for (ap = authenticators; ap->type; ap++)
mask = 0;
for (ap = authenticators; ap->type; ap++) {
if ((mask & (i = typemask(ap->type))) != 0)
continue;
mask |= i;
printf("\t%s\n", AUTHTYPE_NAME(ap->type));
}
return(0);
}
@@ -295,7 +303,6 @@ auth_onoff(type, on)
printf("%s: invalid authentication type\n", type);
return(0);
}
mask = getauthmask(type, &mask);
if (on)
i_wont_support &= ~mask;
else
@@ -319,16 +326,22 @@ auth_togdebug(on)
auth_status()
{
Authenticator *ap;
int i, mask;
if (i_wont_support == -1)
printf("Authentication disabled\n");
else
printf("Authentication enabled\n");
for (ap = authenticators; ap->type; ap++)
mask = 0;
for (ap = authenticators; ap->type; ap++) {
if ((mask & (i = typemask(ap->type))) != 0)
continue;
mask |= i;
printf("%s: %s\n", AUTHTYPE_NAME(ap->type),
(i_wont_support & typemask(ap->type)) ?
"disabled" : "enabled");
}
return(1);
}
@@ -406,7 +419,7 @@ auth_send(data, cnt)
auth_send_cnt = cnt > sizeof(_auth_send_data)
? sizeof(_auth_send_data)
: cnt;
bcopy((void *)data, (void *)_auth_send_data, auth_send_cnt);
memmove((void *)_auth_send_data, (void *)data, auth_send_cnt);
auth_send_data = _auth_send_data;
} else {
/*
@@ -457,7 +470,7 @@ auth_send(data, cnt)
* We requested strong authentication, however no mechanisms worked.
* Therefore, exit on client end.
*/
printf("Unable to securely authenticate user ... exit\n");
printf("Unable to securely authenticate user ... exit\n");
exit(0);
#endif /* KANNAN */
}
@@ -532,7 +545,7 @@ auth_name(data, cnt)
Name, cnt, sizeof(savename)-1);
return;
}
bcopy((void *)data, (void *)savename, cnt);
memmove((void *)savename, (void *)data, cnt);
savename[cnt] = '\0'; /* Null terminate */
if (auth_debug_mode)
printf(">>>%s: Got NAME [%s]\r\n", Name, savename);

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)enc_des.c 8.2 (Berkeley) 12/15/93";
static char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
#ifdef ENCRYPTION
@@ -143,7 +143,7 @@ ofb64_init(server)
fb64_init(fbp)
register struct fb *fbp;
{
bzero((void *)fbp, sizeof(*fbp));
memset((void *)fbp, 0, sizeof(*fbp));
fbp->state[0] = fbp->state[1] = FAILED;
fbp->fb_feed[0] = IAC;
fbp->fb_feed[1] = SB;
@@ -374,7 +374,7 @@ fb64_reply(data, cnt, fbp)
break;
case FB64_IV_BAD:
bzero(fbp->temp_feed, sizeof(Block));
memset(fbp->temp_feed, 0, sizeof(Block));
fb64_stream_iv(fbp->temp_feed, &fbp->streams[DIR_ENCRYPT-1]);
state = FAILED;
break;
@@ -422,7 +422,7 @@ fb64_session(key, server, fbp)
key ? key->type : -1, SK_DES);
return;
}
bcopy((void *)key->data, (void *)fbp->krbdes_key, sizeof(Block));
memmove((void *)fbp->krbdes_key, (void *)key->data, sizeof(Block));
fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT-1]);
fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]);
@@ -549,8 +549,8 @@ fb64_stream_iv(seed, stp)
register struct stinfo *stp;
{
bcopy((void *)seed, (void *)stp->str_iv, sizeof(Block));
bcopy((void *)seed, (void *)stp->str_output, sizeof(Block));
memmove((void *)stp->str_iv, (void *)seed, sizeof(Block));
memmove((void *)stp->str_output, (void *)seed, sizeof(Block));
des_key_sched(stp->str_ikey, stp->str_sched);
@@ -562,10 +562,10 @@ fb64_stream_key(key, stp)
Block key;
register struct stinfo *stp;
{
bcopy((void *)key, (void *)stp->str_ikey, sizeof(Block));
memmove((void *)stp->str_ikey, (void *)key, sizeof(Block));
des_key_sched(key, stp->str_sched);
bcopy((void *)stp->str_iv, (void *)stp->str_output, sizeof(Block));
memmove((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block));
stp->str_index = sizeof(Block);
}
@@ -580,7 +580,7 @@ fb64_stream_key(key, stp)
* INPUT --(--------->(+)+---> DATA
* | |
* +-------------+
*
*
*
* Given:
* iV: Initial vector, 64 bits (8 bytes) long.
@@ -605,7 +605,7 @@ cfb64_encrypt(s, c)
if (index == sizeof(Block)) {
Block b;
des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1);
bcopy((void *)b, (void *)stp->str_feed, sizeof(Block));
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
index = 0;
}
@@ -639,9 +639,9 @@ cfb64_decrypt(data)
if (index == sizeof(Block)) {
Block b;
des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1);
bcopy((void *)b, (void *)stp->str_feed, sizeof(Block));
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
stp->str_index = 1; /* Next time will be 1 */
index = 0; /* But now use 0 */
index = 0; /* But now use 0 */
}
/* On decryption we store (data) which is cypher. */
@@ -681,7 +681,7 @@ ofb64_encrypt(s, c)
if (index == sizeof(Block)) {
Block b;
des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1);
bcopy((void *)b, (void *)stp->str_feed, sizeof(Block));
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
index = 0;
}
*s++ ^= stp->str_feed[index];
@@ -712,9 +712,9 @@ ofb64_decrypt(data)
if (index == sizeof(Block)) {
Block b;
des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1);
bcopy((void *)b, (void *)stp->str_feed, sizeof(Block));
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
stp->str_index = 1; /* Next time will be 1 */
index = 0; /* But now use 0 */
index = 0; /* But now use 0 */
}
return(data ^ stp->str_feed[index]);

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)encrypt.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
/*
@@ -106,7 +106,7 @@ static long remote_supports_decrypt = 0;
static Encryptions encryptions[] = {
#ifdef DES_ENCRYPTION
{ "DES_CFB64", ENCTYPE_DES_CFB64,
cfb64_encrypt,
cfb64_encrypt,
cfb64_decrypt,
cfb64_init,
cfb64_start,
@@ -116,7 +116,7 @@ static Encryptions encryptions[] = {
cfb64_keyid,
cfb64_printsub },
{ "DES_OFB64", ENCTYPE_DES_OFB64,
ofb64_encrypt,
ofb64_encrypt,
ofb64_decrypt,
ofb64_init,
ofb64_start,
@@ -708,7 +708,7 @@ encrypt_request_end()
* Called when ENCRYPT REQUEST-START is received. If we receive
* this before a type is picked, then that indicates that the
* other side wants us to start encrypting data as soon as we
* can.
* can.
*/
void
encrypt_request_start(data, cnt)
@@ -763,12 +763,13 @@ encrypt_keyid(kp, keyid, len)
if (ep->keyid)
(void)(*ep->keyid)(dir, kp->keyid, &kp->keylen);
} else if ((len != kp->keylen) || (bcmp(keyid, kp->keyid, len) != 0)) {
} else if ((len != kp->keylen) ||
(memcmp(keyid, kp->keyid, len) != 0)) {
/*
* Length or contents are different
*/
kp->keylen = len;
bcopy(keyid, kp->keyid, len);
memmove(kp->keyid, keyid, len);
if (ep->keyid)
(void)(*ep->keyid)(dir, kp->keyid, &kp->keylen);
} else {
@@ -795,7 +796,7 @@ encrypt_send_keyid(dir, keyid, keylen, saveit)
? ENCRYPT_ENC_KEYID : ENCRYPT_DEC_KEYID;
if (saveit) {
struct key_info *kp = &ki[(dir == DIR_ENCRYPT) ? 0 : 1];
bcopy(keyid, kp->keyid, keylen);
memmove(kp->keyid, keyid, keylen);
kp->keylen = keylen;
}
@@ -851,7 +852,7 @@ encrypt_start_output(type)
i = (*ep->start)(DIR_ENCRYPT, Server);
if (encrypt_debug_mode) {
printf(">>>%s: Encrypt start: %s (%d) %s\r\n",
Name,
Name,
(i < 0) ? "failed" :
"initial negotiation in progress",
i, ENCTYPE_NAME(type));

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)genget.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
@@ -49,22 +49,22 @@ static char sccsid[] = "@(#)genget.c 8.1 (Berkeley) 6/4/93";
isprefix(s1, s2)
register char *s1, *s2;
{
register int n = 0;
char *os1;
register int n = 0;
char *os1;
register char c1, c2;
if (*s1 == '\0')
return(-1);
os1 = s1;
if (*s1 == '\0')
return(-1);
os1 = s1;
c1 = *s1;
c2 = *s2;
while (LOWER(c1) == LOWER(c2)) {
while (LOWER(c1) == LOWER(c2)) {
if (c1 == '\0')
break;
c1 = *++s1;
c2 = *++s2;
}
return(*s1 ? 0 : (*s2 ? (s1 - os1) : (os1 - s1)));
c1 = *++s1;
c2 = *++s2;
}
return(*s1 ? 0 : (*s2 ? (s1 - os1) : (os1 - s1)));
}
static char *ambiguous; /* special return value for command routines */

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)kerberos.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
/*
@@ -59,7 +59,7 @@ static char sccsid[] = "@(#)kerberos.c 8.1 (Berkeley) 6/4/93";
#include <sys/types.h>
#include <arpa/telnet.h>
#include <stdio.h>
#include <des.h> /* BSD wont include this in krb.h, so we do it here */
#include <des.h> /* BSD wont include this in krb.h, so we do it here */
#include <krb.h>
#ifdef __STDC__
#include <stdlib.h>
@@ -113,32 +113,32 @@ Data(ap, type, d, c)
void *d;
int c;
{
unsigned char *p = str_data + 4;
unsigned char *p = str_data + 4;
unsigned char *cd = (unsigned char *)d;
if (c == -1)
c = strlen((char *)cd);
if (auth_debug_mode) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
if (auth_debug_mode) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
*p++ = ap->type;
*p++ = ap->way;
*p++ = type;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
if (str_data[3] == TELQUAL_IS)
printsub('>', &str_data[2], p - (&str_data[2]));
return(net_write(str_data, p - str_data));
return(net_write(str_data, p - str_data));
}
int
@@ -177,7 +177,7 @@ kerberos4_send(ap)
CREDENTIALS cred;
int r;
printf("[ Trying KERBEROS4 ... ]\n");
printf("[ Trying KERBEROS4 ... ]\n");
if (!UserNameRequested) {
if (auth_debug_mode) {
printf("Kerberos V4: no user name supplied\r\n");
@@ -185,7 +185,7 @@ kerberos4_send(ap)
return(0);
}
bzero(instance, sizeof(instance));
memset(instance, 0, sizeof(instance));
if (realm = krb_get_phost(RemoteHostName))
strncpy(instance, realm, sizeof(instance));
@@ -227,9 +227,10 @@ kerberos4_send(ap)
register int i;
des_key_sched(cred.session, sched);
des_set_random_generator_seed(cred.session);
des_new_random_key(challenge);
des_ecb_encrypt(challenge, session_key, sched, 1);
des_init_random_number_generator(cred.session);
des_new_random_key(session_key);
des_ecb_encrypt(session_key, session_key, sched, 0);
des_ecb_encrypt(session_key, challenge, sched, 0);
/*
* Increment the challenge by 1, and encrypt it for
* later comparison.
@@ -244,7 +245,7 @@ kerberos4_send(ap)
des_ecb_encrypt(challenge, challenge, sched, 1);
}
#endif /* ENCRYPTION */
if (auth_debug_mode) {
printf("CK: %d:", kerberos4_cksum(auth.dat, auth.length));
printd(auth.dat, auth.length);
@@ -279,7 +280,7 @@ kerberos4_is(ap, data, cnt)
printf("No local realm\r\n");
return;
}
bcopy((void *)data, (void *)auth.dat, auth.length = cnt);
memmove((void *)auth.dat, (void *)data, auth.length = cnt);
if (auth_debug_mode) {
printf("Got %d bytes of authentication data\r\n", cnt);
printf("CK: %d:", kerberos4_cksum(auth.dat, auth.length));
@@ -296,7 +297,7 @@ kerberos4_is(ap, data, cnt)
return;
}
#ifdef ENCRYPTION
bcopy((void *)adat.session, (void *)session_key, sizeof(Block));
memmove((void *)session_key, (void *)adat.session, sizeof(Block));
#endif /* ENCRYPTION */
krb_kntoln(&adat, name);
@@ -322,8 +323,13 @@ kerberos4_is(ap, data, cnt)
break;
}
/*
* Initialize the random number generator since it's
* used later on by the encryption routine.
*/
des_init_random_number_generator(session_key);
des_key_sched(session_key, sched);
bcopy((void *)data, (void *)datablock, sizeof(Block));
memmove((void *)datablock, (void *)data, sizeof(Block));
/*
* Take the received encrypted challenge, and encrypt
* it again to get a unique session_key for the
@@ -339,7 +345,7 @@ kerberos4_is(ap, data, cnt)
* increment by one, re-encrypt it and send it back.
*/
des_ecb_encrypt(datablock, challenge, sched, 0);
for (r = 7; r >= 0; r++) {
for (r = 7; r >= 0; r--) {
register int t;
t = (unsigned int)challenge[r] + 1;
challenge[r] = t; /* ignore overflow */

View File

@@ -46,7 +46,7 @@ char rcsid_kerberos5_c[] = "$Id$";
*/
#ifndef lint
static char sccsid[] = "@(#)kerberos5.c 8.2 (Berkeley) 12/15/93";
static char sccsid[] = "@(#)kerberos5.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
/*
@@ -84,7 +84,7 @@ static char sccsid[] = "@(#)kerberos5.c 8.2 (Berkeley) 12/15/93";
/* kerberos 5 include files (ext-proto.h) will get an appropriate stdlib.h
and string.h/strings.h */
#include "encrypt.h"
#include "auth.h"
#include "misc.h"
@@ -96,8 +96,8 @@ int forward_flags = 0; /* Flags get set in telnet/main.c on -f and -F */
/* These values need to be the same as those defined in telnet/main.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
void kerberos5_forward();
@@ -139,32 +139,32 @@ Data(ap, type, d, c)
Voidptr d;
int c;
{
unsigned char *p = str_data + 4;
unsigned char *p = str_data + 4;
unsigned char *cd = (unsigned char *)d;
if (c == -1)
c = strlen((char *)cd);
if (auth_debug_mode) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
if (auth_debug_mode) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
*p++ = ap->type;
*p++ = ap->way;
*p++ = type;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
if (str_data[3] == TELQUAL_IS)
printsub('>', &str_data[2], p - &str_data[2]);
return(net_write(str_data, p - str_data));
return(net_write(str_data, p - str_data));
}
int
@@ -176,7 +176,7 @@ kerberos5_init(ap, server)
str_data[3] = TELQUAL_REPLY;
else
str_data[3] = TELQUAL_IS;
krb5_init_ets();
krb5_init_ets();
return(1);
}
@@ -203,14 +203,14 @@ kerberos5_send(ap)
ksum.checksum_type = CKSUMTYPE_CRC32;
ksum.contents = sum;
ksum.length = sizeof(sum);
bzero((Voidptr )sum, sizeof(sum));
if (!UserNameRequested) {
if (auth_debug_mode) {
printf("Kerberos V5: no user name supplied\r\n");
}
return(0);
}
memset((Voidptr )sum, 0, sizeof(sum));
if (!UserNameRequested) {
if (auth_debug_mode) {
printf("Kerberos V5: no user name supplied\r\n");
}
return(0);
}
if (r = krb5_cc_default(&ccache)) {
if (auth_debug_mode) {
@@ -254,9 +254,9 @@ kerberos5_send(ap)
krb5_free_host_realm(realms);
return(0);
}
bzero((char *)&creds, sizeof(creds));
memset((char *)&creds, 0, sizeof(creds));
creds.server = server;
if (r = krb5_cc_get_principal(ccache, &creds.client)) {
@@ -284,7 +284,7 @@ kerberos5_send(ap)
ap_opts = AP_OPTS_MUTUAL_REQUIRED;
else
ap_opts = 0;
r = krb5_mk_req_extended(ap_opts, &ksum, krb5_kdc_default_options, 0,
#ifdef ENCRYPTION
&newkey,
@@ -305,12 +305,12 @@ kerberos5_send(ap)
if (newkey->keytype != KEYTYPE_DES) {
if (creds.keyblock.keytype == KEYTYPE_DES)
/* use the session key in credentials instead */
memcpy((char *)session_key,
memmove((char *)session_key,
(char *)creds.keyblock.contents, sizeof(Block));
else
/* XXX ? */;
} else {
memcpy((char *)session_key, (char *)newkey->contents,
memmove((char *)session_key, (char *)newkey->contents,
sizeof(Block));
}
krb5_free_keyblock(newkey);
@@ -324,11 +324,11 @@ kerberos5_send(ap)
return(0);
}
if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) {
if (auth_debug_mode)
printf("Not enough room for user name\r\n");
return(0);
}
if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) {
if (auth_debug_mode)
printf("Not enough room for user name\r\n");
return(0);
}
if (!Data(ap, KRB_AUTH, auth.data, auth.length)) {
if (auth_debug_mode)
printf("Not enough room for authentication data\r\n");
@@ -403,7 +403,7 @@ kerberos5_is(ap, data, cnt)
if (authdat)
krb5_free_tkt_authent(authdat);
r = krb5_build_principal_ext(&server,
r = krb5_build_principal_ext(&server,
strlen(realm), realm,
4, "host",
p2 - name, name,
@@ -441,7 +441,7 @@ kerberos5_is(ap, data, cnt)
goto errout;
}
Data(ap, KRB_RESPONSE, outbuf.data, outbuf.length);
}
}
if (krb5_unparse_name(authdat->ticket->enc_part2 ->client,
&name))
name = 0;
@@ -450,20 +450,22 @@ kerberos5_is(ap, data, cnt)
printf("Kerberos5 identifies him as ``%s''\r\n",
name ? name : "");
}
auth_finished(ap, AUTH_USER);
auth_finished(ap, AUTH_USER);
free(name);
if (authdat->authenticator->subkey &&
authdat->authenticator->subkey->keytype == KEYTYPE_DES) {
bcopy((Voidptr )authdat->authenticator->subkey->contents,
(Voidptr )session_key, sizeof(Block));
memmove((Voidptr )session_key,
(Voidptr )authdat->authenticator->subkey->contents,
sizeof(Block));
} else if (authdat->ticket->enc_part2->session->keytype ==
KEYTYPE_DES) {
bcopy((Voidptr )authdat->ticket->enc_part2->session->contents,
(Voidptr )session_key, sizeof(Block));
memmove((Voidptr )session_key,
(Voidptr )authdat->ticket->enc_part2->session->contents,
sizeof(Block));
} else
break;
#ifdef ENCRYPTION
skey.type = SK_DES;
skey.length = 8;
@@ -475,17 +477,17 @@ kerberos5_is(ap, data, cnt)
case KRB_FORWARD:
inbuf.data = (char *)data;
inbuf.length = cnt;
if (r = rd_and_store_for_creds(&inbuf, authdat->ticket,
if (r = rd_and_store_for_creds(&inbuf, authdat->ticket,
UserNameRequested)) {
char errbuf[128];
(void) strcpy(errbuf, "Read forwarded creds failed: ");
(void) strcat(errbuf, error_message(r));
Data(ap, KRB_FORWARD_REJECT, errbuf, -1);
if (auth_debug_mode)
printf("Could not read forwarded credentials\r\n");
}
else
else
Data(ap, KRB_FORWARD_ACCEPT, 0, 0);
if (auth_debug_mode)
printf("Forwarded credentials obtained\r\n");
@@ -505,7 +507,7 @@ kerberos5_reply(ap, data, cnt)
unsigned char *data;
int cnt;
{
Session_Key skey;
Session_Key skey;
static int mutual_complete = 0;
if (cnt-- < 1)
@@ -649,15 +651,15 @@ kerberos5_printsub(data, cnt, buf, buflen)
goto common2;
#ifdef FORWARD
case KRB_FORWARD: /* Forwarded credentials follow */
case KRB_FORWARD: /* Forwarded credentials follow */
strncpy((char *)buf, " FORWARD", buflen);
goto common2;
case KRB_FORWARD_ACCEPT: /* Forwarded credentials accepted */
case KRB_FORWARD_ACCEPT: /* Forwarded credentials accepted */
strncpy((char *)buf, " FORWARD_ACCEPT", buflen);
goto common2;
case KRB_FORWARD_REJECT: /* Forwarded credentials rejected */
case KRB_FORWARD_REJECT: /* Forwarded credentials rejected */
/* (reason might follow) */
strncpy((char *)buf, " FORWARD_REJECT", buflen);
goto common2;
@@ -678,7 +680,7 @@ kerberos5_printsub(data, cnt, buf, buflen)
}
#ifdef FORWARD
void
void
kerberos5_forward(ap)
Authenticator *ap;
{
@@ -690,16 +692,16 @@ kerberos5_forward(ap)
krb5_ccache ccache;
int i;
if (!(local_creds = (krb5_creds *)
if (!(local_creds = (krb5_creds *)
calloc(1, sizeof(*local_creds)))) {
if (auth_debug_mode)
if (auth_debug_mode)
printf("Kerberos V5: could not allocate memory for credentials\r\n");
return;
}
if (r = krb5_sname_to_principal(RemoteHostName, "host", 1,
&local_creds->server)) {
if (auth_debug_mode)
if (auth_debug_mode)
printf("Kerberos V5: could not build server name - %s\r\n",
error_message(r));
krb5_free_creds(local_creds);
@@ -707,7 +709,7 @@ kerberos5_forward(ap)
}
if (r = krb5_cc_default(&ccache)) {
if (auth_debug_mode)
if (auth_debug_mode)
printf("Kerberos V5: could not get default ccache - %s\r\n",
error_message(r));
krb5_free_creds(local_creds);
@@ -715,7 +717,7 @@ kerberos5_forward(ap)
}
if (r = krb5_cc_get_principal(ccache, &local_creds->client)) {
if (auth_debug_mode)
if (auth_debug_mode)
printf("Kerberos V5: could not get default principal - %s\r\n",
error_message(r));
krb5_free_creds(local_creds);
@@ -724,7 +726,7 @@ kerberos5_forward(ap)
/* Get ticket from credentials cache */
if (r = krb5_get_credentials(KRB5_GC_CACHED, ccache, local_creds)) {
if (auth_debug_mode)
if (auth_debug_mode)
printf("Kerberos V5: could not obtain credentials - %s\r\n",
error_message(r));
krb5_free_creds(local_creds);
@@ -738,13 +740,13 @@ kerberos5_forward(ap)
&local_creds->keyblock,
forward_flags & OPTS_FORWARDABLE_CREDS,
&forw_creds)) {
if (auth_debug_mode)
if (auth_debug_mode)
printf("Kerberos V5: error getting forwarded creds - %s\r\n",
error_message(r));
krb5_free_creds(local_creds);
return;
}
/* Send forwarded credentials */
if (!Data(ap, KRB_FORWARD, forw_creds.data, forw_creds.length)) {
if (auth_debug_mode)

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)krb4encpwd.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)krb4encpwd.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
@@ -125,32 +125,32 @@ Data(ap, type, d, c)
void *d;
int c;
{
unsigned char *p = str_data + 4;
unsigned char *p = str_data + 4;
unsigned char *cd = (unsigned char *)d;
if (c == -1)
c = strlen((char *)cd);
if (0) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
if (0) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
*p++ = ap->type;
*p++ = ap->way;
*p++ = type;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
if (str_data[3] == TELQUAL_IS)
printsub('>', &str_data[2], p - (&str_data[2]));
return(net_write(str_data, p - str_data));
return(net_write(str_data, p - str_data));
}
int
@@ -158,7 +158,7 @@ krb4encpwd_init(ap, server)
Authenticator *ap;
int server;
{
char hostname[80], *cp, *realm;
char hostname[80], *cp, *realm;
C_Block skey;
if (server) {
@@ -167,7 +167,7 @@ krb4encpwd_init(ap, server)
str_data[3] = TELQUAL_IS;
gethostname(hostname, sizeof(hostname));
realm = krb_realmofhost(hostname);
cp = index(hostname, '.');
cp = strchr(hostname, '.');
if (*cp != NULL) *cp = NULL;
if (read_service_key(KRB_SERVICE_NAME, hostname, realm, 0,
KEYFILE, (char *)skey)) {
@@ -214,10 +214,10 @@ krb4encpwd_is(ap, data, cnt)
return;
switch (*data++) {
case KRB4_ENCPWD_AUTH:
bcopy((void *)data, (void *)auth.dat, auth.length = cnt);
memmove((void *)auth.dat, (void *)data, auth.length = cnt);
gethostname(lhostname, sizeof(lhostname));
if ((cp = index(lhostname, '.')) != 0) *cp = '\0';
if ((cp = strchr(lhostname, '.')) != 0) *cp = '\0';
if (r = krb_rd_encpwd_req(&auth, KRB_SERVICE_NAME, lhostname, 0, &adat, NULL, challenge, r_user, r_passwd)) {
Data(ap, KRB4_ENCPWD_REJECT, (void *)"Auth failed", -1);
@@ -234,7 +234,7 @@ krb4encpwd_is(ap, data, cnt)
return;
}
bcopy((void *)adat.session, (void *)session_key, sizeof(Block));
memmove((void *)session_key, (void *)adat.session, sizeof(Block));
Data(ap, KRB4_ENCPWD_ACCEPT, (void *)0, 0);
auth_finished(ap, AUTH_USER);
break;
@@ -244,7 +244,7 @@ krb4encpwd_is(ap, data, cnt)
* Take the received random challenge text and save
* for future authentication.
*/
bcopy((void *)data, (void *)challenge, sizeof(Block));
memmove((void *)challenge, (void *)data, sizeof(Block));
break;
@@ -255,7 +255,7 @@ krb4encpwd_is(ap, data, cnt)
/*
* If we are doing mutual authentication, get set up to send
* the challange, and verify it when the response comes back.
* the challenge, and verify it when the response comes back.
*/
if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
@@ -266,7 +266,7 @@ krb4encpwd_is(ap, data, cnt)
Data(ap, KRB4_ENCPWD_CHALLENGE, (void *)challenge, strlen(challenge));
}
break;
default:
Data(ap, KRB4_ENCPWD_REJECT, 0, 0);
break;
@@ -285,8 +285,8 @@ krb4encpwd_reply(ap, data, cnt)
Block enckey;
CREDENTIALS cred;
int r;
char randchal[REALM_SZ], instance[ANAME_SZ], *cp;
char hostname[80], *realm;
char randchal[REALM_SZ], instance[ANAME_SZ], *cp;
char hostname[80], *realm;
if (cnt-- < 1)
return;
@@ -310,13 +310,13 @@ krb4encpwd_reply(ap, data, cnt)
gethostname(hostname, sizeof(hostname));
realm = krb_realmofhost(hostname);
bcopy((void *)data, (void *)challenge, cnt);
bzero(user_passwd, sizeof(user_passwd));
memmove((void *)challenge, (void *)data, cnt);
memset(user_passwd, 0, sizeof(user_passwd));
local_des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0);
UserPassword = user_passwd;
Challenge = challenge;
strcpy(instance, RemoteHostName);
if ((cp = index(instance, '.')) != 0) *cp = '\0';
if ((cp = strchr(instance, '.')) != 0) *cp = '\0';
if (r = krb_mk_encpwd_req(&krb_token, KRB_SERVICE_NAME, instance, realm, Challenge, UserNameRequested, user_passwd)) {
krb_token.length = 0;

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)read_password.c 8.2 (Berkeley) 12/15/93";
static char sccsid[] = "@(#)read_password.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
/*
@@ -76,7 +76,7 @@ local_des_read_pw_string(s,max,prompt,verify)
{
int ok = 0;
char *ptr;
jmp_buf old_env;
struct sgttyb tty_state;
char key_string[BUFSIZ];
@@ -86,12 +86,12 @@ local_des_read_pw_string(s,max,prompt,verify)
}
/* XXX assume jmp_buf is typedef'ed to an array */
bcopy((char *)old_env, (char *)env, sizeof(env));
memmove((char *)env, (char *)old_env, sizeof(env));
if (setjmp(env))
goto lose;
/* save terminal state*/
if (ioctl(0,TIOCGETP,(char *)&tty_state) == -1)
if (ioctl(0,TIOCGETP,(char *)&tty_state) == -1)
return -1;
/*
push_signals();
@@ -105,7 +105,7 @@ local_des_read_pw_string(s,max,prompt,verify)
(void) fflush(stdout);
while (!fgets(s, max, stdin));
if ((ptr = index(s, '\n')))
if ((ptr = strchr(s, '\n')))
*ptr = '\0';
if (verify) {
printf("\nVerifying, please re-enter %s",prompt);
@@ -114,7 +114,7 @@ local_des_read_pw_string(s,max,prompt,verify)
clearerr(stdin);
continue;
}
if ((ptr = index(key_string, '\n')))
if ((ptr = strchr(key_string, '\n')))
*ptr = '\0';
if (strcmp(s,key_string)) {
printf("\n\07\07Mismatch - try again\n");
@@ -127,7 +127,7 @@ local_des_read_pw_string(s,max,prompt,verify)
lose:
if (!ok)
bzero(s, max);
memset(s, 0, max);
printf("\n");
/* turn echo back on */
tty_state.sg_flags |= ECHO;
@@ -136,9 +136,9 @@ lose:
/*
pop_signals();
*/
bcopy((char *)env, (char *)old_env, sizeof(env));
memmove((char *)old_env, (char *)env, sizeof(env));
if (verify)
bzero(key_string, sizeof (key_string));
memset(key_string, 0, sizeof (key_string));
s[max-1] = 0; /* force termination */
return !ok; /* return nonzero if not okay */
}

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)rsaencpwd.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)rsaencpwd.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
@@ -120,32 +120,32 @@ Data(ap, type, d, c)
void *d;
int c;
{
unsigned char *p = str_data + 4;
unsigned char *p = str_data + 4;
unsigned char *cd = (unsigned char *)d;
if (c == -1)
c = strlen((char *)cd);
if (0) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
if (0) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
*p++ = ap->type;
*p++ = ap->way;
if (type != NULL) *p++ = type;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
if (str_data[3] == TELQUAL_IS)
printsub('>', &str_data[2], p - (&str_data[2]));
return(net_write(str_data, p - str_data));
return(net_write(str_data, p - str_data));
}
int
@@ -158,9 +158,9 @@ rsaencpwd_init(ap, server)
if (server) {
str_data[3] = TELQUAL_REPLY;
bzero(key_file, sizeof(key_file));
memset(key_file, 0, sizeof(key_file));
gethostname(lhostname, sizeof(lhostname));
if ((cp = index(lhostname, '.')) != 0) *cp = '\0';
if ((cp = strchr(lhostname, '.')) != 0) *cp = '\0';
strcpy(key_file, "/etc/.");
strcat(key_file, lhostname);
strcat(key_file, "_privkey");
@@ -210,7 +210,7 @@ rsaencpwd_is(ap, data, cnt)
cnt--;
switch (*data++) {
case RSA_ENCPWD_AUTH:
bcopy((void *)data, (void *)auth.dat, auth.length = cnt);
memmove((void *)auth.dat, (void *)data, auth.length = cnt);
if ((fp=fopen(key_file, "r"))==NULL) {
Data(ap, RSA_ENCPWD_REJECT, (void *)"Auth failed", -1);
@@ -252,7 +252,7 @@ rsaencpwd_is(ap, data, cnt)
/*
* If we are doing mutual authentication, get set up to send
* the challange, and verify it when the response comes back.
* the challenge, and verify it when the response comes back.
*/
if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_ONE_WAY) {
register int i;
@@ -294,17 +294,17 @@ rsaencpwd_is(ap, data, cnt)
ptr +=NumEncodeLengthOctets(chalkey_len);
*ptr++ = 0x04; /* OCTET STRING */
*ptr++ = challenge_len;
bcopy(challenge, ptr, challenge_len);
memmove(ptr, challenge, challenge_len);
ptr += challenge_len;
*ptr++ = 0x04; /* OCTET STRING */
EncodeLength(ptr, i);
ptr += NumEncodeLengthOctets(i);
bcopy(key, ptr, i);
memmove(ptr, key, i);
chalkey_len = 1+NumEncodeLengthOctets(chalkey_len)+chalkey_len;
Data(ap, RSA_ENCPWD_CHALLENGEKEY, (void *)chalkey, chalkey_len);
}
break;
default:
Data(ap, RSA_ENCPWD_REJECT, 0, 0);
break;
@@ -322,8 +322,8 @@ rsaencpwd_reply(ap, data, cnt)
KTEXT_ST token;
Block enckey;
int r, pubkey_len;
char randchal[CHAL_SZ], *cp;
char chalkey[160], pubkey[128], *ptr;
char randchal[CHAL_SZ], *cp;
char chalkey[160], pubkey[128], *ptr;
if (cnt-- < 1)
return;
@@ -345,25 +345,25 @@ rsaencpwd_reply(ap, data, cnt)
* Verify that the response to the challenge is correct.
*/
bcopy((void *)data, (void *)chalkey, cnt);
memmove((void *)chalkey, (void *)data, cnt);
ptr = (char *) &chalkey[0];
ptr += DecodeHeaderLength(chalkey);
if (*ptr != 0x04) {
return;
}
return;
}
*ptr++;
challenge_len = DecodeValueLength(ptr);
ptr += NumEncodeLengthOctets(challenge_len);
bcopy(ptr, challenge, challenge_len);
memmove(challenge, ptr, challenge_len);
ptr += challenge_len;
if (*ptr != 0x04) {
return;
}
*ptr++;
return;
}
*ptr++;
pubkey_len = DecodeValueLength(ptr);
ptr += NumEncodeLengthOctets(pubkey_len);
bcopy(ptr, pubkey, pubkey_len);
bzero(user_passwd, sizeof(user_passwd));
memmove(pubkey, ptr, pubkey_len);
memset(user_passwd, 0, sizeof(user_passwd));
local_des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0);
UserPassword = user_passwd;
Challenge = challenge;

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)spx.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)spx.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
#ifdef SPX
@@ -107,23 +107,23 @@ static Block challenge = { 0 };
/*******************************************************************/
gss_OID_set actual_mechs;
gss_OID actual_mech_type, output_name_type;
int major_status, status, msg_ctx = 0, new_status;
int req_flags = 0, ret_flags, lifetime_rec;
gss_cred_id_t gss_cred_handle;
gss_ctx_id_t actual_ctxhandle, context_handle;
gss_buffer_desc output_token, input_token, input_name_buffer;
gss_buffer_desc status_string;
gss_name_t desired_targname, src_name;
gss_channel_bindings input_chan_bindings;
char lhostname[GSS_C_MAX_PRINTABLE_NAME];
char targ_printable[GSS_C_MAX_PRINTABLE_NAME];
int to_addr=0, from_addr=0;
char *address;
gss_buffer_desc fullname_buffer;
gss_OID fullname_type;
gss_cred_id_t gss_delegated_cred_handle;
gss_OID_set actual_mechs;
gss_OID actual_mech_type, output_name_type;
int major_status, status, msg_ctx = 0, new_status;
int req_flags = 0, ret_flags, lifetime_rec;
gss_cred_id_t gss_cred_handle;
gss_ctx_id_t actual_ctxhandle, context_handle;
gss_buffer_desc output_token, input_token, input_name_buffer;
gss_buffer_desc status_string;
gss_name_t desired_targname, src_name;
gss_channel_bindings input_chan_bindings;
char lhostname[GSS_C_MAX_PRINTABLE_NAME];
char targ_printable[GSS_C_MAX_PRINTABLE_NAME];
int to_addr=0, from_addr=0;
char *address;
gss_buffer_desc fullname_buffer;
gss_OID fullname_type;
gss_cred_id_t gss_delegated_cred_handle;
/*******************************************************************/
@@ -136,32 +136,32 @@ Data(ap, type, d, c)
void *d;
int c;
{
unsigned char *p = str_data + 4;
unsigned char *p = str_data + 4;
unsigned char *cd = (unsigned char *)d;
if (c == -1)
c = strlen((char *)cd);
if (0) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
if (0) {
printf("%s:%d: [%d] (%d)",
str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
str_data[3],
type, c);
printd(d, c);
printf("\r\n");
}
*p++ = ap->type;
*p++ = ap->way;
*p++ = type;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
while (c-- > 0) {
if ((*p++ = *cd++) == IAC)
*p++ = IAC;
}
*p++ = IAC;
*p++ = SE;
if (str_data[3] == TELQUAL_IS)
printsub('>', &str_data[2], p - (&str_data[2]));
return(net_write(str_data, p - str_data));
return(net_write(str_data, p - str_data));
}
int
@@ -169,7 +169,7 @@ spx_init(ap, server)
Authenticator *ap;
int server;
{
gss_cred_id_t tmp_cred_handle;
gss_cred_id_t tmp_cred_handle;
if (server) {
str_data[3] = TELQUAL_REPLY;
@@ -179,17 +179,17 @@ spx_init(ap, server)
input_name_buffer.length = strlen(targ_printable);
input_name_buffer.value = targ_printable;
major_status = gss_import_name(&status,
&input_name_buffer,
GSS_C_NULL_OID,
&desired_targname);
&input_name_buffer,
GSS_C_NULL_OID,
&desired_targname);
major_status = gss_acquire_cred(&status,
desired_targname,
0,
GSS_C_NULL_OID_SET,
GSS_C_ACCEPT,
&tmp_cred_handle,
&actual_mechs,
&lifetime_rec);
desired_targname,
0,
GSS_C_NULL_OID_SET,
GSS_C_ACCEPT,
&tmp_cred_handle,
&actual_mechs,
&lifetime_rec);
if (major_status != GSS_S_COMPLETE) return(0);
} else {
str_data[3] = TELQUAL_IS;
@@ -204,9 +204,9 @@ spx_send(ap)
Block enckey;
int r;
gss_OID actual_mech_type, output_name_type;
int msg_ctx = 0, new_status, status;
int req_flags = 0, ret_flags, lifetime_rec, major_status;
gss_OID actual_mech_type, output_name_type;
int msg_ctx = 0, new_status, status;
int req_flags = 0, ret_flags, lifetime_rec, major_status;
gss_buffer_desc output_token, input_token, input_name_buffer;
gss_buffer_desc output_name_buffer, status_string;
gss_name_t desired_targname;
@@ -228,9 +228,9 @@ spx_send(ap)
}
major_status = gss_import_name(&status,
&input_name_buffer,
GSS_C_NULL_OID,
&desired_targname);
&input_name_buffer,
GSS_C_NULL_OID,
&desired_targname);
major_status = gss_display_name(&status,
@@ -263,35 +263,35 @@ spx_send(ap)
address[3] = (to_addr & 0xff);
input_chan_bindings->application_data.length = 0;
req_flags = 0;
if (deleg_flag) req_flags = req_flags | 1;
if (mutual_flag) req_flags = req_flags | 2;
if (replay_flag) req_flags = req_flags | 4;
if (seq_flag) req_flags = req_flags | 8;
req_flags = 0;
if (deleg_flag) req_flags = req_flags | 1;
if (mutual_flag) req_flags = req_flags | 2;
if (replay_flag) req_flags = req_flags | 4;
if (seq_flag) req_flags = req_flags | 8;
major_status = gss_init_sec_context(&status, /* minor status */
major_status = gss_init_sec_context(&status, /* minor status */
GSS_C_NO_CREDENTIAL, /* cred handle */
&actual_ctxhandle, /* ctx handle */
desired_targname, /* target name */
GSS_C_NULL_OID, /* mech type */
req_flags, /* req flags */
0, /* time req */
input_chan_bindings, /* chan binding */
GSS_C_NO_BUFFER, /* input token */
&actual_mech_type, /* actual mech */
&output_token, /* output token */
&ret_flags, /* ret flags */
&lifetime_rec); /* time rec */
&actual_ctxhandle, /* ctx handle */
desired_targname, /* target name */
GSS_C_NULL_OID, /* mech type */
req_flags, /* req flags */
0, /* time req */
input_chan_bindings, /* chan binding */
GSS_C_NO_BUFFER, /* input token */
&actual_mech_type, /* actual mech */
&output_token, /* output token */
&ret_flags, /* ret flags */
&lifetime_rec); /* time rec */
if ((major_status != GSS_S_COMPLETE) &&
(major_status != GSS_S_CONTINUE_NEEDED)) {
gss_display_status(&new_status,
status,
GSS_C_MECH_CODE,
GSS_C_NULL_OID,
&msg_ctx,
&status_string);
printf("%s\n", status_string.value);
gss_display_status(&new_status,
status,
GSS_C_MECH_CODE,
GSS_C_NULL_OID,
&msg_ctx,
&status_string);
printf("%s\n", status_string.value);
return(0);
}
@@ -320,7 +320,7 @@ spx_is(ap, data, cnt)
return;
switch (*data++) {
case SPX_AUTH:
input_token.length = cnt;
input_token.length = cnt;
input_token.value = (char *) data;
gethostname(lhostname, sizeof(lhostname));
@@ -332,18 +332,18 @@ spx_is(ap, data, cnt)
input_name_buffer.value = targ_printable;
major_status = gss_import_name(&status,
&input_name_buffer,
GSS_C_NULL_OID,
&desired_targname);
&input_name_buffer,
GSS_C_NULL_OID,
&desired_targname);
major_status = gss_acquire_cred(&status,
desired_targname,
0,
GSS_C_NULL_OID_SET,
GSS_C_ACCEPT,
&gss_cred_handle,
&actual_mechs,
&lifetime_rec);
desired_targname,
0,
GSS_C_NULL_OID_SET,
GSS_C_ACCEPT,
&gss_cred_handle,
&actual_mechs,
&lifetime_rec);
major_status = gss_release_name(&status, desired_targname);
@@ -369,33 +369,33 @@ spx_is(ap, data, cnt)
input_chan_bindings->application_data.length = 0;
major_status = gss_accept_sec_context(&status,
&context_handle,
gss_cred_handle,
&input_token,
input_chan_bindings,
&src_name,
&actual_mech_type,
&output_token,
&ret_flags,
&lifetime_rec,
&gss_delegated_cred_handle);
&context_handle,
gss_cred_handle,
&input_token,
input_chan_bindings,
&src_name,
&actual_mech_type,
&output_token,
&ret_flags,
&lifetime_rec,
&gss_delegated_cred_handle);
if (major_status != GSS_S_COMPLETE) {
major_status = gss_display_name(&status,
src_name,
&fullname_buffer,
&fullname_type);
src_name,
&fullname_buffer,
&fullname_type);
Data(ap, SPX_REJECT, (void *)"auth failed", -1);
auth_finished(ap, AUTH_REJECT);
return;
}
major_status = gss_display_name(&status,
src_name,
&fullname_buffer,
&fullname_type);
src_name,
&fullname_buffer,
&fullname_type);
Data(ap, SPX_ACCEPT, (void *)output_token.value, output_token.length);
@@ -438,26 +438,26 @@ spx_reply(ap, data, cnt)
input_token.length = cnt;
major_status = gss_init_sec_context(&status, /* minor stat */
GSS_C_NO_CREDENTIAL, /* cred handle */
&actual_ctxhandle, /* ctx handle */
desired_targname, /* target name */
GSS_C_NULL_OID, /* mech type */
req_flags, /* req flags */
0, /* time req */
input_chan_bindings, /* chan binding */
&input_token, /* input token */
&actual_mech_type, /* actual mech */
&output_token, /* output token */
&ret_flags, /* ret flags */
&lifetime_rec); /* time rec */
GSS_C_NO_CREDENTIAL, /* cred handle */
&actual_ctxhandle, /* ctx handle */
desired_targname, /* target name */
GSS_C_NULL_OID, /* mech type */
req_flags, /* req flags */
0, /* time req */
input_chan_bindings, /* chan binding */
&input_token, /* input token */
&actual_mech_type, /* actual mech */
&output_token, /* output token */
&ret_flags, /* ret flags */
&lifetime_rec); /* time rec */
if (major_status != GSS_S_COMPLETE) {
gss_display_status(&new_status,
status,
GSS_C_MECH_CODE,
GSS_C_NULL_OID,
&msg_ctx,
&status_string);
status,
GSS_C_MECH_CODE,
GSS_C_NULL_OID,
&msg_ctx,
&status_string);
printf("[ SPX mutual response fails ... '%s' ]\r\n",
status_string.value);
auth_send_retry();
@@ -481,25 +481,25 @@ spx_status(ap, name, level)
gss_buffer_desc fullname_buffer, acl_file_buffer;
gss_OID fullname_type;
char acl_file[160], fullname[160];
int major_status, status = 0;
char acl_file[160], fullname[160];
int major_status, status = 0;
struct passwd *pwd;
/*
* hard code fullname to
* "SPX:/C=US/O=Digital/OU=LKG/OU=Sphinx/OU=Users/CN=Kannan Alagappan"
* and acl_file to "~kannan/.sphinx"
*/
/*
* hard code fullname to
* "SPX:/C=US/O=Digital/OU=LKG/OU=Sphinx/OU=Users/CN=Kannan Alagappan"
* and acl_file to "~kannan/.sphinx"
*/
pwd = getpwnam(UserNameRequested);
if (pwd == NULL) {
return(AUTH_USER); /* not authenticated */
}
return(AUTH_USER); /* not authenticated */
}
strcpy(acl_file, pwd->pw_dir);
strcat(acl_file, "/.sphinx");
acl_file_buffer.value = acl_file;
acl_file_buffer.length = strlen(acl_file);
acl_file_buffer.value = acl_file;
acl_file_buffer.length = strlen(acl_file);
major_status = gss_display_name(&status,
src_name,
@@ -509,15 +509,15 @@ spx_status(ap, name, level)
if (level < AUTH_USER)
return(level);
major_status = gss__check_acl(&status, &fullname_buffer,
&acl_file_buffer);
major_status = gss__check_acl(&status, &fullname_buffer,
&acl_file_buffer);
if (major_status == GSS_S_COMPLETE) {
if (major_status == GSS_S_COMPLETE) {
strcpy(name, UserNameRequested);
return(AUTH_VALID);
} else {
return(AUTH_USER);
}
} else {
return(AUTH_USER);
}
}

View File

@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)rexecd.8 8.2 (Berkeley) 12/11/93
.\" @(#)rexecd.8 8.3 (Berkeley) 6/1/94
.\"
.Dd December 11, 1993
.Dd June 1, 1994
.Dt REXECD 8
.Os BSD 4.2
.Sh NAME
@@ -117,6 +117,7 @@ list (as configured into the system).
No password file entry for the user name existed.
.It Sy Password incorrect.
The wrong password was supplied.
.ne 1i
.It Sy \&No remote directory.
The
.Xr chdir

View File

@@ -29,21 +29,26 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)rlogin.1 8.1 (Berkeley) 6/6/93
.\" @(#)rlogin.1 8.2 (Berkeley) 4/29/95
.\"
.Dd June 6, 1993
.Dd April 29, 1995
.Dt RLOGIN 1
.Os BSD 4.2
.Sh NAME
.Nm rlogin
.Nd remote login
.Sh SYNOPSIS
.Ar rlogin
.Nm rlogin
.Op Fl 8EKLdx
.Op Fl e Ar char
.Op Fl k Ar realm
.Op Fl l Ar username
.Ar host
.Nm rlogin
.Op Fl 8EKLdx
.Op Fl e Ar char
.Op Fl k Ar realm
.Ar username@host
.Sh DESCRIPTION
.Nm Rlogin
starts a terminal session on a remote host

View File

@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)rlogin.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)rlogin.c 8.4 (Berkeley) 4/29/95";
#endif /* not lint */
/*
@@ -49,6 +49,7 @@ static char sccsid[] = "@(#)rlogin.c 8.1 (Berkeley) 6/6/93";
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -59,7 +60,7 @@ static char sccsid[] = "@(#)rlogin.c 8.1 (Berkeley) 6/6/93";
#include <netdb.h>
#include <pwd.h>
#include <setjmp.h>
#include <sgtty.h>
#include <termios.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -98,11 +99,6 @@ int eight, litout, rem;
int noescape;
u_char escapechar = '~';
char *speeds[] = {
"0", "50", "75", "110", "134", "150", "200", "300", "600", "1200",
"1800", "2400", "4800", "9600", "19200", "38400"
};
#ifdef OLDSUN
struct winsize {
unsigned short ws_row, ws_col;
@@ -115,7 +111,7 @@ struct winsize winsize;
void catch_child __P((int));
void copytochild __P((int));
__dead void doit __P((long));
__dead void doit __P((sigset_t *));
__dead void done __P((int));
void echo __P((char));
u_int getescape __P((char *));
@@ -123,9 +119,10 @@ void lostpeer __P((int));
void mode __P((int));
void msg __P((char *));
void oob __P((int));
int reader __P((int));
int reader __P((sigset_t *));
void sendwindow __P((void));
void setsignal __P((int));
int speed __P((int));
void sigwinch __P((int));
void stop __P((char));
__dead void usage __P((void));
@@ -144,25 +141,24 @@ main(argc, argv)
int argc;
char *argv[];
{
extern char *optarg;
extern int optind;
struct passwd *pw;
struct servent *sp;
struct sgttyb ttyb;
long omask;
int argoff, ch, dflag, one, uid;
sigset_t smask;
uid_t uid;
int argoff, ch, dflag, one;
char *host, *p, *user, term[1024];
struct sigaction sa;
argoff = dflag = 0;
one = 1;
host = user = NULL;
if (p = rindex(argv[0], '/'))
if (p = strrchr(argv[0], '/'))
++p;
else
p = argv[0];
if (strcmp(p, "rlogin"))
if (strcmp(p, "rlogin") != 0)
host = p;
/* handle "rlogin host flags" */
@@ -231,9 +227,17 @@ main(argc, argv)
if (*argv)
usage();
if (!(pw = getpwuid(uid = getuid()))) {
(void)fprintf(stderr, "rlogin: unknown user id.\n");
exit(1);
if (!(pw = getpwuid(uid = getuid())))
errx(1, "unknown user id.");
/* Accept user1@host format, though "-l user2" overrides user1 */
p = strchr(host, '@');
if (p) {
*p = '\0';
if (!user && p > host)
user = host;
host = p + 1;
if (*host == '\0')
usage();
}
if (!user)
user = pw->pw_name;
@@ -251,30 +255,34 @@ main(argc, argv)
#endif
if (sp == NULL)
sp = getservbyname("login", "tcp");
if (sp == NULL) {
(void)fprintf(stderr, "rlogin: login/tcp: unknown service.\n");
exit(1);
}
if (sp == NULL)
errx(1, "login/tcp: unknown service.");
(void)strcpy(term, (p = getenv("TERM")) ? p : "network");
if (ioctl(0, TIOCGETP, &ttyb) == 0) {
(void)strcat(term, "/");
(void)strcat(term, speeds[(int)ttyb.sg_ospeed]);
}
(void)snprintf(term, sizeof(term), "%s/%d",
((p = getenv("TERM")) ? p : "network"),
speed(0));
(void)get_window_size(0, &winsize);
(void)signal(SIGPIPE, lostpeer);
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sa.sa_handler = lostpeer;
(void)sigaction(SIGPIPE, &sa, (struct sigaction *) 0);
/* will use SIGUSR1 for window size hack, so hold it off */
omask = sigblock(sigmask(SIGURG) | sigmask(SIGUSR1));
sigemptyset(&smask);
sigaddset(&smask, SIGURG);
sigaddset(&smask, SIGUSR1);
(void)sigprocmask(SIG_SETMASK, &smask, &smask);
/*
* We set SIGURG and SIGUSR1 below so that an
* incoming signal will be held pending rather than being
* discarded. Note that these routines will be ready to get
* a signal by the time that they are unblocked below.
*/
(void)signal(SIGURG, copytochild);
(void)signal(SIGUSR1, writeroob);
sa.sa_handler = copytochild;
(void)sigaction(SIGURG, &sa, (struct sigaction *) 0);
sa.sa_handler = writeroob;
(void)sigaction(SIGUSR1, &sa, (struct sigaction *) 0);
#ifdef KERBEROS
try_connect:
@@ -283,11 +291,8 @@ try_connect:
/* Fully qualify hostname (needed for krb_realmofhost). */
hp = gethostbyname(host);
if (hp != NULL && !(host = strdup(hp->h_name))) {
(void)fprintf(stderr, "rlogin: %s\n",
strerror(ENOMEM));
exit(1);
}
if (hp != NULL && !(host = strdup(hp->h_name)))
errx(1, "%s", strerror(ENOMEM));
rem = KSUCCESS;
errno = 0;
@@ -305,11 +310,8 @@ try_connect:
if (rem < 0) {
use_kerberos = 0;
sp = getservbyname("login", "tcp");
if (sp == NULL) {
(void)fprintf(stderr,
"rlogin: unknown service login/tcp.\n");
exit(1);
}
if (sp == NULL)
errx(1, "unknown service login/tcp.");
if (errno == ECONNREFUSED)
warning("remote host doesn't support Kerberos");
if (errno == ENOENT)
@@ -318,11 +320,8 @@ try_connect:
}
} else {
#ifdef CRYPT
if (doencrypt) {
(void)fprintf(stderr,
"rlogin: the -x flag requires Kerberos authentication.\n");
exit(1);
}
if (doencrypt)
errx(1, "the -x flag requires Kerberos authentication.");
#endif /* CRYPT */
rem = rcmd(&host, sp->s_port, pw->pw_name, user, term, 0);
}
@@ -335,52 +334,77 @@ try_connect:
if (dflag &&
setsockopt(rem, SOL_SOCKET, SO_DEBUG, &one, sizeof(one)) < 0)
(void)fprintf(stderr, "rlogin: setsockopt: %s.\n",
strerror(errno));
warn("setsockopt DEBUG (ignored)");
one = IPTOS_LOWDELAY;
if (setsockopt(rem, IPPROTO_IP, IP_TOS, (char *)&one, sizeof(int)) < 0)
perror("rlogin: setsockopt TOS (ignored)");
warn("setsockopt TOS (ignored)");
(void)setuid(uid);
doit(omask);
doit(&smask);
/*NOTREACHED*/
}
int child, defflags, deflflags, tabflag;
char deferase, defkill;
struct tchars deftc;
struct ltchars defltc;
struct tchars notc = { -1, -1, -1, -1, -1, -1 };
struct ltchars noltc = { -1, -1, -1, -1, -1, -1 };
#if BSD >= 198810
int
speed(fd)
int fd;
{
struct termios tt;
(void)tcgetattr(fd, &tt);
return ((int) cfgetispeed(&tt));
}
#else
int speeds[] = { /* for older systems, B0 .. EXTB */
0, 50, 75, 110,
134, 150, 200, 300,
600, 1200, 1800, 2400,
4800, 9600, 19200, 38400
};
int
speed(fd)
int fd;
{
struct termios tt;
(void)tcgetattr(fd, &tt);
return (speeds[(int)cfgetispeed(&tt)]);
}
#endif
pid_t child;
struct termios deftt;
struct termios nott;
void
doit(omask)
long omask;
doit(smask)
sigset_t *smask;
{
struct sgttyb sb;
int i;
struct sigaction sa;
(void)ioctl(0, TIOCGETP, (char *)&sb);
defflags = sb.sg_flags;
tabflag = defflags & TBDELAY;
defflags &= ECHO | CRMOD;
deferase = sb.sg_erase;
defkill = sb.sg_kill;
(void)ioctl(0, TIOCLGET, &deflflags);
(void)ioctl(0, TIOCGETC, &deftc);
notc.t_startc = deftc.t_startc;
notc.t_stopc = deftc.t_stopc;
(void)ioctl(0, TIOCGLTC, &defltc);
(void)signal(SIGINT, SIG_IGN);
for (i = 0; i < NCCS; i++)
nott.c_cc[i] = _POSIX_VDISABLE;
tcgetattr(0, &deftt);
nott.c_cc[VSTART] = deftt.c_cc[VSTART];
nott.c_cc[VSTOP] = deftt.c_cc[VSTOP];
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sa.sa_handler = SIG_IGN;
(void)sigaction(SIGINT, &sa, (struct sigaction *) 0);
setsignal(SIGHUP);
setsignal(SIGQUIT);
child = fork();
if (child == -1) {
(void)fprintf(stderr, "rlogin: fork: %s.\n", strerror(errno));
warn("fork");
done(1);
}
if (child == 0) {
mode(1);
if (reader(omask) == 0) {
if (reader(smask) == 0) {
msg("connection closed.");
exit(0);
}
@@ -396,8 +420,9 @@ doit(omask)
* signals to the child. We can now unblock SIGURG and SIGUSR1
* that were set above.
*/
(void)sigsetmask(omask);
(void)signal(SIGCHLD, catch_child);
(void)sigprocmask(SIG_SETMASK, smask, (sigset_t *) 0);
sa.sa_handler = catch_child;
(void)sigaction(SIGCHLD, &sa, (struct sigaction *) 0);
writer();
msg("closed connection.");
done(0);
@@ -408,25 +433,41 @@ void
setsignal(sig)
int sig;
{
int omask = sigblock(sigmask(sig));
struct sigaction sa;
sigset_t sigs;
if (signal(sig, exit) == SIG_IGN)
(void)signal(sig, SIG_IGN);
(void)sigsetmask(omask);
sigemptyset(&sigs);
sigaddset(&sigs, sig);
sigprocmask(SIG_BLOCK, &sigs, &sigs);
sigemptyset(&sa.sa_mask);
sa.sa_handler = exit;
sa.sa_flags = SA_RESTART;
(void)sigaction(sig, &sa, &sa);
if (sa.sa_handler == SIG_IGN)
(void)sigaction(sig, &sa, (struct sigaction *) 0);
(void)sigprocmask(SIG_SETMASK, &sigs, (sigset_t *) 0);
}
__dead void
done(status)
int status;
{
int w, wstatus;
pid_t w;
int wstatus;
struct sigaction sa;
mode(0);
if (child > 0) {
/* make sure catch_child does not snap it up */
(void)signal(SIGCHLD, SIG_DFL);
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_DFL;
sa.sa_flags = 0;
(void)sigaction(SIGCHLD, &sa, (struct sigaction *) 0);
if (kill(child, SIGKILL) >= 0)
while ((w = wait(&wstatus)) > 0 && w != child);
while ((w = wait(&wstatus)) > 0 && w != child)
continue;
}
exit(status);
}
@@ -441,9 +482,14 @@ void
writeroob(signo)
int signo;
{
struct sigaction sa;
if (dosigwinch == 0) {
sendwindow();
(void)signal(SIGWINCH, sigwinch);
sigemptyset(&sa.sa_mask);
sa.sa_handler = sigwinch;
sa.sa_flags = SA_RESTART;
(void)sigaction(SIGWINCH, &sa, (struct sigaction *) 0);
}
dosigwinch = 1;
}
@@ -452,16 +498,16 @@ void
catch_child(signo)
int signo;
{
union wait status;
int pid;
int status;
pid_t pid;
for (;;) {
pid = wait3((int *)&status, WNOHANG|WUNTRACED, NULL);
pid = waitpid(-1, &status, WNOHANG|WUNTRACED);
if (pid == 0)
return;
/* if the child (reader) dies, just quit */
if (pid < 0 || (pid == child && !WIFSTOPPED(status)))
done((int)(status.w_termsig | status.w_retcode));
done(WEXITSTATUS(status) | WTERMSIG(status));
}
/* NOTREACHED */
}
@@ -502,11 +548,11 @@ writer()
}
} else if (local) {
local = 0;
if (c == '.' || c == deftc.t_eofc) {
if (c == '.' || c == deftt.c_cc[VEOF]) {
echo(c);
break;
}
if (c == defltc.t_suspc || c == defltc.t_dsuspc) {
if (c == deftt.c_cc[VSUSP] || c == deftt.c_cc[VDSUSP]) {
bol = 1;
echo(c);
stop(c);
@@ -538,8 +584,8 @@ writer()
msg("line gone");
break;
}
bol = c == defkill || c == deftc.t_eofc ||
c == deftc.t_intrc || c == defltc.t_suspc ||
bol = c == deftt.c_cc[VKILL] || c == deftt.c_cc[VEOF] ||
c == deftt.c_cc[VINTR] || c == deftt.c_cc[VSUSP] ||
c == '\r' || c == '\n';
}
}
@@ -579,10 +625,16 @@ stop(cmdc)
char cmdc;
#endif
{
struct sigaction sa;
mode(0);
(void)signal(SIGCHLD, SIG_IGN);
(void)kill(cmdc == defltc.t_suspc ? 0 : getpid(), SIGTSTP);
(void)signal(SIGCHLD, catch_child);
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_IGN;
sa.sa_flags = SA_RESTART;
(void)sigaction(SIGCHLD, &sa, (struct sigaction *) 0);
(void)kill(cmdc == deftt.c_cc[VSUSP] ? 0 : getpid(), SIGTSTP);
sa.sa_handler = catch_child;
(void)sigaction(SIGCHLD, &sa, (struct sigaction *) 0);
mode(1);
sigwinch(0); /* check for size changes */
}
@@ -594,7 +646,7 @@ sigwinch(signo)
struct winsize ws;
if (dosigwinch && get_window_size(0, &ws) == 0 &&
bcmp(&ws, &winsize, sizeof(ws))) {
memcmp(&ws, &winsize, sizeof(ws))) {
winsize = ws;
sendwindow();
}
@@ -636,14 +688,15 @@ sendwindow()
#define WRITING 2
jmp_buf rcvtop;
int ppid, rcvcnt, rcvstate;
pid_t ppid;
int rcvcnt, rcvstate;
char rcvbuf[8 * 1024];
void
oob(signo)
int signo;
{
struct sgttyb sb;
struct termios tt;
int atmark, n, out, rcvd;
char waste[BUFSIZ], mark;
@@ -678,29 +731,24 @@ oob(signo)
(void)kill(ppid, SIGUSR1);
}
if (!eight && (mark & TIOCPKT_NOSTOP)) {
(void)ioctl(0, TIOCGETP, (char *)&sb);
sb.sg_flags &= ~CBREAK;
sb.sg_flags |= RAW;
(void)ioctl(0, TIOCSETN, (char *)&sb);
notc.t_stopc = -1;
notc.t_startc = -1;
(void)ioctl(0, TIOCSETC, (char *)&notc);
tcgetattr(0, &tt);
tt.c_iflag &= ~(IXON | IXOFF);
tt.c_cc[VSTOP] = _POSIX_VDISABLE;
tt.c_cc[VSTART] = _POSIX_VDISABLE;
tcsetattr(0, TCSANOW, &tt);
}
if (!eight && (mark & TIOCPKT_DOSTOP)) {
(void)ioctl(0, TIOCGETP, (char *)&sb);
sb.sg_flags &= ~RAW;
sb.sg_flags |= CBREAK;
(void)ioctl(0, TIOCSETN, (char *)&sb);
notc.t_stopc = deftc.t_stopc;
notc.t_startc = deftc.t_startc;
(void)ioctl(0, TIOCSETC, (char *)&notc);
tcgetattr(0, &tt);
tt.c_iflag |= (IXON|IXOFF);
tt.c_cc[VSTOP] = deftt.c_cc[VSTOP];
tt.c_cc[VSTART] = deftt.c_cc[VSTART];
tcsetattr(0, TCSANOW, &tt);
}
if (mark & TIOCPKT_FLUSHWRITE) {
(void)ioctl(1, TIOCFLUSH, (char *)&out);
for (;;) {
if (ioctl(rem, SIOCATMARK, &atmark) < 0) {
(void)fprintf(stderr, "rlogin: ioctl: %s.\n",
strerror(errno));
warn("ioctl SIOCATMARK (ignored)");
break;
}
if (atmark)
@@ -732,23 +780,29 @@ oob(signo)
/* reader: read from remote: line -> 1 */
int
reader(omask)
int omask;
reader(smask)
sigset_t *smask;
{
int pid, n, remaining;
pid_t pid;
int n, remaining;
char *bufp;
struct sigaction sa;
#if BSD >= 43 || defined(SUNOS4)
pid = getpid(); /* modern systems use positives for pid */
#else
pid = -getpid(); /* old broken systems use negatives */
#endif
(void)signal(SIGTTOU, SIG_IGN);
(void)signal(SIGURG, oob);
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sa.sa_handler = SIG_IGN;
(void)sigaction(SIGTTOU, &sa, (struct sigaction *) 0);
sa.sa_handler = oob;
(void)sigaction(SIGURG, &sa, (struct sigaction *) 0);
ppid = getppid();
(void)fcntl(rem, F_SETOWN, pid);
(void)setjmp(rcvtop);
(void)sigsetmask(omask);
(void)sigprocmask(SIG_SETMASK, smask, (sigset_t *) 0);
bufp = rcvbuf;
for (;;) {
while ((remaining = rcvcnt - (bufp - rcvbuf)) > 0) {
@@ -778,8 +832,7 @@ reader(omask)
if (rcvcnt < 0) {
if (errno == EINTR)
continue;
(void)fprintf(stderr, "rlogin: read: %s.\n",
strerror(errno));
warn("read");
return (-1);
}
}
@@ -789,49 +842,44 @@ void
mode(f)
int f;
{
struct ltchars *ltc;
struct sgttyb sb;
struct tchars *tc;
int lflags;
struct termios tt;
(void)ioctl(0, TIOCGETP, (char *)&sb);
(void)ioctl(0, TIOCLGET, (char *)&lflags);
switch(f) {
switch (f) {
case 0:
sb.sg_flags &= ~(CBREAK|RAW|TBDELAY);
sb.sg_flags |= defflags|tabflag;
tc = &deftc;
ltc = &defltc;
sb.sg_kill = defkill;
sb.sg_erase = deferase;
lflags = deflflags;
tcsetattr(0, TCSADRAIN, &deftt);
break;
case 1:
sb.sg_flags |= (eight ? RAW : CBREAK);
sb.sg_flags &= ~defflags;
/* preserve tab delays, but turn off XTABS */
if ((sb.sg_flags & TBDELAY) == XTABS)
sb.sg_flags &= ~TBDELAY;
tc = &notc;
ltc = &noltc;
sb.sg_kill = sb.sg_erase = -1;
if (litout)
lflags |= LLITOUT;
tt = deftt;
tt.c_oflag &= ~(OPOST);
tt.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
tt.c_iflag &= ~(ICRNL);
tt.c_cc[VMIN] = 1;
tt.c_cc[VTIME] = 0;
if (eight) {
tt.c_iflag &= ~(IXON | IXOFF | ISTRIP);
tt.c_cc[VSTOP] = _POSIX_VDISABLE;
tt.c_cc[VSTART] = _POSIX_VDISABLE;
}
/*if (litout)
lflags |= LLITOUT;*/
tcsetattr(0, TCSADRAIN, &tt);
break;
default:
return;
}
(void)ioctl(0, TIOCSLTC, (char *)ltc);
(void)ioctl(0, TIOCSETC, (char *)tc);
(void)ioctl(0, TIOCSETN, (char *)&sb);
(void)ioctl(0, TIOCLSET, (char *)&lflags);
}
void
lostpeer(signo)
int signo;
{
(void)signal(SIGPIPE, SIG_IGN);
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sa.sa_handler = SIG_IGN;
(void)sigaction(SIGPIPE, &sa, (struct sigaction *) 0);
msg("\007connection closed.");
done(1);
}
@@ -841,6 +889,7 @@ void
copytochild(signo)
int signo;
{
(void)kill(child, SIGURG);
}
@@ -848,6 +897,7 @@ void
msg(str)
char *str;
{
(void)fprintf(stderr, "rlogin: %s\r\n", str);
}
@@ -880,7 +930,7 @@ __dead void
usage()
{
(void)fprintf(stderr,
"usage: rlogin [ -%s]%s[-e char] [ -l username ] host\n",
"usage: rlogin [ -%s]%s[-e char] [ -l username ] [username@]host\n",
#ifdef KERBEROS
#ifdef CRYPT
"8EKLx", " [-k realm] ");

View File

@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)rlogind.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)rlogind.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*
@@ -302,11 +302,11 @@ doit(f, fromp)
hostname);
#endif
execl(_PATH_LOGIN, "login", "-p",
"-h", hostname, "-f", lusername, (char *)NULL);
execle(_PATH_LOGIN, "login", "-p",
"-h", hostname, "-f", "--", lusername, NULL, env);
} else
execl(_PATH_LOGIN, "login", "-p",
"-h", hostname, lusername, (char *)NULL);
execle(_PATH_LOGIN, "login", "-p",
"-h", hostname, "--", lusername, NULL, env);
fatal(STDERR_FILENO, _PATH_LOGIN, 1);
/*NOTREACHED*/
}
@@ -348,7 +348,7 @@ control(pty, cp, n)
if (n < 4+sizeof (w) || cp[2] != 's' || cp[3] != 's')
return (0);
oobdata[0] &= ~TIOCPKT_WINDOW; /* we know he heard */
bcopy(cp+4, (char *)&w, sizeof(w));
memmove(&w, cp+4, sizeof(w));
w.ws_row = ntohs(w.ws_row);
w.ws_col = ntohs(w.ws_col);
w.ws_xpixel = ntohs(w.ws_xpixel);
@@ -596,8 +596,6 @@ getstr(buf, cnt, errmsg)
} while (c != 0);
}
extern char **environ;
void
setup_term(fd)
int fd;
@@ -636,7 +634,6 @@ setup_term(fd)
env[0] = term;
env[1] = 0;
environ = env;
}
#ifdef KERBEROS

View File

@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)rsh.1 8.1 (Berkeley) 6/6/93
.\" @(#)rsh.1 8.2 (Berkeley) 4/29/95
.\"
.Dd June 6, 1993
.Dd April 29, 1995
.Dt RSH 1
.Os BSD 4.2
.Sh NAME
@@ -43,6 +43,10 @@
.Op Fl k Ar realm
.Op Fl l Ar username
.Ar host
.Nm rsh
.Op Fl Kdnx
.Op Fl k Ar realm
.Ar username@host
.Op command
.Sh DESCRIPTION
.Nm Rsh
@@ -86,7 +90,9 @@ instead of the remote host's realm as determined by
By default, the remote username is the same as the local username.
The
.Fl l
option allows the remote name to be specified.
option or the
.Pa username@host
format allow the remote name to be specified.
Kerberos authentication is used, and authorization is determined
as in
.Xr rlogin 1 .

View File

@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)rsh.c 8.3 (Berkeley) 4/6/94";
static char sccsid[] = "@(#)rsh.c 8.4 (Berkeley) 4/29/95";
#endif /* not lint */
/*
@@ -189,6 +189,16 @@ main(argc, argv)
if (!(pw = getpwuid(uid = getuid())))
errx(1, "unknown user id");
/* Accept user1@host format, though "-l user2" overrides user1 */
p = strchr(host, '@');
if (p) {
*p = '\0';
if (!user && p > host)
user = host;
host = p + 1;
if (*host == '\0')
usage();
}
if (!user)
user = pw->pw_name;
@@ -466,7 +476,7 @@ usage()
{
(void)fprintf(stderr,
"usage: rsh [-nd%s]%s[-l login] host [command]\n",
"usage: rsh [-nd%s]%s[-l login] [login@]host [command]\n",
#ifdef KERBEROS
#ifdef CRYPT
"x", " [-k realm] ");

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)announce.c 8.2 (Berkeley) 1/7/94";
static char sccsid[] = "@(#)announce.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/types.h>
@@ -48,6 +48,7 @@ static char sccsid[] = "@(#)announce.c 8.2 (Berkeley) 1/7/94";
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <vis.h>
#include <paths.h>
extern char hostname[];
@@ -77,7 +78,7 @@ announce(request, remote_machine)
#define max(a,b) ( (a) > (b) ? (a) : (b) )
#define N_LINES 5
#define N_CHARS 120
#define N_CHARS 256
/*
* Build a block of characters containing the message.
@@ -99,7 +100,7 @@ print_mesg(tty, tf, request, remote_machine)
char line_buf[N_LINES][N_CHARS];
int sizes[N_LINES];
char big_buf[N_LINES*N_CHARS];
char *bptr, *lptr, *ttymsg();
char *bptr, *lptr, *vis_user;
int i, j, max_size;
i = 0;
@@ -115,13 +116,15 @@ print_mesg(tty, tf, request, remote_machine)
sizes[i] = strlen(line_buf[i]);
max_size = max(max_size, sizes[i]);
i++;
vis_user = (char *) malloc(strlen(request->l_name) * 4 + 1);
strvis(vis_user, request->l_name, VIS_CSTYLE);
(void)sprintf(line_buf[i], "talk: connection requested by %s@%s",
request->l_name, remote_machine);
vis_user, remote_machine);
sizes[i] = strlen(line_buf[i]);
max_size = max(max_size, sizes[i]);
i++;
(void)sprintf(line_buf[i], "talk: respond with: talk %s@%s",
request->l_name, remote_machine);
vis_user, remote_machine);
sizes[i] = strlen(line_buf[i]);
max_size = max(max_size, sizes[i]);
i++;

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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

View File

@@ -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 {

View File

@@ -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);
}

View File

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

View File

@@ -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;

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)authenc.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
@@ -45,7 +45,7 @@ net_write(str, len)
int len;
{
if (nfrontp + len < netobuf + BUFSIZ) {
bcopy((void *)str, (void *)nfrontp, len);
memmove((void *)nfrontp, (void *)str, len);
nfrontp += len;
return(len);
}

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)slc.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)slc.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -109,10 +109,10 @@ get_slc_defaults()
init_termbuf();
for (i = 1; i <= NSLC; i++) {
slctab[i].defset.flag =
slctab[i].defset.flag =
spcset(i, &slctab[i].defset.val, &slctab[i].sptr);
slctab[i].current.flag = SLC_NOSUPPORT;
slctab[i].current.val = 0;
slctab[i].current.flag = SLC_NOSUPPORT;
slctab[i].current.val = 0;
}
} /* end of get_slc_defaults */
@@ -286,7 +286,7 @@ change_slc(func, flag, val)
register cc_t val;
{
register int hislevel, mylevel;
hislevel = flag & SLC_LEVELBITS;
mylevel = slctab[func].defset.flag & SLC_LEVELBITS;
/*
@@ -345,7 +345,7 @@ change_slc(func, flag, val)
* request as he asks.
*
* If our level is DEFAULT, then just ack whatever was
* sent.
* sent.
*
* If he can't change and we can't change,
* then degenerate to NOSUPPORT.
@@ -372,7 +372,6 @@ change_slc(func, flag, val)
slctab[func].defset.val;
val = slctab[func].current.val;
}
}
add_slc(func, flag, val);
}
@@ -423,7 +422,6 @@ check_slc()
slctab[i].current.val);
}
}
} /* check_slc */
/*
@@ -465,7 +463,7 @@ do_opt_slc(ptr, len)
def_slcbuf = (unsigned char *)malloc((unsigned)len);
if (def_slcbuf == (unsigned char *)0)
return; /* too bad */
bcopy(ptr, def_slcbuf, len);
memmove(def_slcbuf, ptr, len);
}
}

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)state.c 8.2 (Berkeley) 12/15/93";
static char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -366,7 +366,7 @@ gotiac: switch (c) {
char xbuf2[BUFSIZ];
register char *cp;
int n = pfrontp - opfrontp, oc;
bcopy(opfrontp, xptyobuf, n);
memmove(xptyobuf, opfrontp, n);
pfrontp = opfrontp;
pfrontp += term_input(xptyobuf, pfrontp, n, BUFSIZ+NETSLOP,
xbuf2, &oc, BUFSIZ);
@@ -388,7 +388,7 @@ gotiac: switch (c) {
* All state defaults are negative, and resp defaults to 0.
*
* When initiating a request to change state to new_state:
*
*
* if ((want_resp == 0 && new_state == my_state) || want_state == new_state) {
* do nothing;
* } else {
@@ -716,7 +716,6 @@ wontoption(option)
*/
if (lmodetype != REAL_LINEMODE)
break;
lmodetype = KLUDGE_LINEMODE;
# endif /* KLUDGELINEMODE */
clientstat(TELOPT_LINEMODE, WONT, 0);
break;
@@ -1520,8 +1519,8 @@ doclientstat()
clientstat(TELOPT_LINEMODE, WILL, 0);
}
#define ADD(c) *ncp++ = c;
#define ADD_DATA(c) { *ncp++ = c; if (c == SE) *ncp++ = c; }
#define ADD(c) *ncp++ = c
#define ADD_DATA(c) { *ncp++ = c; if (c == SE || c == IAC) *ncp++ = c; }
void
send_status()
{
@@ -1550,14 +1549,10 @@ send_status()
if (my_want_state_is_will(i)) {
ADD(WILL);
ADD_DATA(i);
if (i == IAC)
ADD(IAC);
}
if (his_want_state_is_will(i)) {
ADD(DO);
ADD_DATA(i);
if (i == IAC)
ADD(IAC);
}
}
@@ -1572,15 +1567,14 @@ send_status()
ADD(SE);
if (restartany >= 0) {
ADD(SB)
ADD(SB);
ADD(TELOPT_LFLOW);
if (restartany) {
ADD(LFLOW_RESTART_ANY);
} else {
ADD(LFLOW_RESTART_XON);
}
ADD(SE)
ADD(SB);
ADD(SE);
}
}
@@ -1593,8 +1587,6 @@ send_status()
ADD(TELOPT_LINEMODE);
ADD(LM_MODE);
ADD_DATA(editmode);
if (editmode == IAC)
ADD(IAC);
ADD(SE);
ADD(SB);

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)sys_term.c 8.2 (Berkeley) 12/15/93";
static char sccsid[] = "@(#)sys_term.c 8.4 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -69,21 +69,16 @@ char wtmpf[] = "/etc/wtmp";
# ifdef CRAY
#include <tmpdir.h>
#include <sys/wait.h>
# if defined(_SC_CRAY_SECURE_SYS) && !defined(SCM_SECURITY)
/*
* UNICOS 6.0/6.1 do not have SCM_SECURITY defined, so we can
* use it to tell us to turn off all the socket security code,
* since that is only used in UNICOS 7.0 and later.
*/
# undef _SC_CRAY_SECURE_SYS
# if (UNICOS_LVL == '7.0') || (UNICOS_LVL == '7.1')
# define UNICOS7x
# endif
# if defined(_SC_CRAY_SECURE_SYS)
# ifdef UNICOS7x
#include <sys/sysv.h>
#include <sys/secstat.h>
extern int secflag;
extern struct sysv sysv;
# endif /* _SC_CRAY_SECURE_SYS */
# endif /* UNICOS7x */
# endif /* CRAY */
#endif /* NEWINIT */
@@ -215,7 +210,7 @@ copy_termbuf(cp, len)
{
if (len > sizeof(termbuf))
len = sizeof(termbuf);
bcopy(cp, (char *)&termbuf, len);
memmove((char *)&termbuf, cp, len);
termbuf2 = termbuf;
}
#endif /* defined(LINEMODE) && defined(TIOCPKT_IOCTL) */
@@ -227,17 +222,19 @@ set_termbuf()
* Only make the necessary changes.
*/
#ifndef USE_TERMIO
if (bcmp((char *)&termbuf.sg, (char *)&termbuf2.sg, sizeof(termbuf.sg)))
if (memcmp((char *)&termbuf.sg, (char *)&termbuf2.sg,
sizeof(termbuf.sg)))
(void) ioctl(pty, TIOCSETN, (char *)&termbuf.sg);
if (bcmp((char *)&termbuf.tc, (char *)&termbuf2.tc, sizeof(termbuf.tc)))
if (memcmp((char *)&termbuf.tc, (char *)&termbuf2.tc,
sizeof(termbuf.tc)))
(void) ioctl(pty, TIOCSETC, (char *)&termbuf.tc);
if (bcmp((char *)&termbuf.ltc, (char *)&termbuf2.ltc,
if (memcmp((char *)&termbuf.ltc, (char *)&termbuf2.ltc,
sizeof(termbuf.ltc)))
(void) ioctl(pty, TIOCSLTC, (char *)&termbuf.ltc);
if (termbuf.lflags != termbuf2.lflags)
(void) ioctl(pty, TIOCLSET, (char *)&termbuf.lflags);
#else /* USE_TERMIO */
if (bcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
if (memcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
# ifdef STREAMSPTY
(void) tcsetattr(ttyfd, TCSANOW, &termbuf);
# else
@@ -942,6 +939,15 @@ tty_iscrnl()
#endif
}
/*
* Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD).
*/
#if B4800 != 4800
#define DECODE_BAUD
#endif
#ifdef DECODE_BAUD
/*
* A table of available terminal speeds
*/
@@ -949,34 +955,72 @@ struct termspeeds {
int speed;
int 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, B9600 },
{ 38400, B9600 }, { -1, B9600 }
{ 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 },
#ifdef B7200
{ 7200, B7200 },
#endif
{ 9600, B9600 },
#ifdef B14400
{ 14400, B14400 },
#endif
#ifdef B19200
{ 19200, B19200 },
#endif
#ifdef B28800
{ 28800, B28800 },
#endif
#ifdef B38400
{ 38400, B38400 },
#endif
#ifdef B57600
{ 57600, B57600 },
#endif
#ifdef B115200
{ 115200, B115200 },
#endif
#ifdef B230400
{ 230400, B230400 },
#endif
{ -1, 0 }
};
#endif /* DECODE_BUAD */
void
tty_tspeed(val)
int val;
{
#ifdef DECODE_BAUD
register struct termspeeds *tp;
for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
;
if (tp->speed == -1) /* back up to last valid value */
--tp;
cfsetospeed(&termbuf, tp->value);
#else /* DECODE_BUAD */
cfsetospeed(&termbuf, val);
#endif /* DECODE_BUAD */
}
void
tty_rspeed(val)
int val;
{
#ifdef DECODE_BAUD
register struct termspeeds *tp;
for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
;
if (tp->speed == -1) /* back up to last valid value */
--tp;
cfsetispeed(&termbuf, tp->value);
#else /* DECODE_BAUD */
cfsetispeed(&termbuf, val);
#endif /* DECODE_BAUD */
}
#if defined(CRAY2) && defined(UNICOS5)
@@ -1076,7 +1120,7 @@ getptyslave()
#ifdef USE_TERMIO
ttyfd = t;
#endif
if (ioctl(t, I_PUSH, "ptem") < 0)
if (ioctl(t, I_PUSH, "ptem") < 0)
fatal(net, "I_PUSH ptem");
if (ioctl(t, I_PUSH, "ldterm") < 0)
fatal(net, "I_PUSH ldterm");
@@ -1092,7 +1136,7 @@ getptyslave()
init_termbuf();
# ifdef TIOCGWINSZ
if (def_row || def_col) {
bzero((char *)&ws, sizeof(ws));
memset((char *)&ws, 0, sizeof(ws));
ws.ws_col = def_col;
ws.ws_row = def_row;
(void)ioctl(t, TIOCSWINSZ, (char *)&ws);
@@ -1172,9 +1216,9 @@ cleanopen(line)
char *line;
{
register int t;
#if defined(_SC_CRAY_SECURE_SYS)
#ifdef UNICOS7x
struct secstat secbuf;
#endif /* _SC_CRAY_SECURE_SYS */
#endif /* UNICOS7x */
#ifndef STREAMSPTY
/*
@@ -1188,7 +1232,7 @@ cleanopen(line)
# if !defined(CRAY) && (BSD > 43)
(void) revoke(line);
# endif
#if defined(_SC_CRAY_SECURE_SYS)
#ifdef UNICOS7x
if (secflag) {
if (secstat(line, &secbuf) < 0)
return(-1);
@@ -1197,18 +1241,18 @@ cleanopen(line)
if (setucmp(secbuf.st_compart) < 0)
return(-1);
}
#endif /* _SC_CRAY_SECURE_SYS */
#endif /* UNICOS7x */
t = open(line, O_RDWR|O_NOCTTY);
#if defined(_SC_CRAY_SECURE_SYS)
#ifdef UNICOS7x
if (secflag) {
if (setulvl(sysv.sy_minlvl) < 0)
return(-1);
if (setucmp(0) < 0)
return(-1);
}
#endif /* _SC_CRAY_SECURE_SYS */
#endif /* UNICOS7x */
if (t < 0)
return(-1);
@@ -1231,9 +1275,8 @@ cleanopen(line)
(void) signal(SIGHUP, SIG_IGN);
(void) ioctl(t, TCVHUP, (char *)0);
(void) signal(SIGHUP, SIG_DFL);
setpgrp();
#if defined(_SC_CRAY_SECURE_SYS)
#ifdef UNICOS7x
if (secflag) {
if (secstat(line, &secbuf) < 0)
return(-1);
@@ -1242,18 +1285,18 @@ cleanopen(line)
if (setucmp(secbuf.st_compart) < 0)
return(-1);
}
#endif /* _SC_CRAY_SECURE_SYS */
#endif /* UNICOS7x */
i = open(line, O_RDWR);
#if defined(_SC_CRAY_SECURE_SYS)
#ifdef UNICOS7x
if (secflag) {
if (setulvl(sysv.sy_minlvl) < 0)
return(-1);
if (setucmp(0) < 0)
return(-1);
}
#endif /* _SC_CRAY_SECURE_SYS */
#endif /* UNICOS7x */
if (i < 0)
return(-1);
@@ -1302,7 +1345,11 @@ login_tty(t)
* setsid() call above may have set our pgrp, so clear
* it out before opening the tty...
*/
# ifndef SOLARIS
(void) setpgrp(0, 0);
# else
(void) setpgrp();
# endif
close(open(line, O_RDWR));
# endif
if (t != 0)
@@ -1513,7 +1560,7 @@ start_login(host, autologin, name)
* Create utmp entry for child
*/
bzero(&utmpx, sizeof(utmpx));
memset(&utmpx, 0, sizeof(utmpx));
SCPYN(utmpx.ut_user, ".telnet");
SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1);
utmpx.ut_pid = pid;
@@ -1523,8 +1570,8 @@ start_login(host, autologin, name)
utmpx.ut_id[3] = SC_WILDC;
utmpx.ut_type = LOGIN_PROCESS;
(void) time(&utmpx.ut_tv.tv_sec);
if (makeutx(&utmpx) == NULL)
fatal(net, "makeutx failed");
if (pututxline(&utmpx) == NULL)
fatal(net, "pututxline failed");
#endif
/*
@@ -1568,6 +1615,19 @@ start_login(host, autologin, name)
#if !defined(NO_LOGIN_P)
argv = addarg(argv, "-p");
#endif
#ifdef LINEMODE
/*
* Set the environment variable "LINEMODE" to either
* "real" or "kludge" if we are operating in either
* real or kludge linemode.
*/
if (lmodetype == REAL_LINEMODE)
setenv("LINEMODE", "real", 1);
# ifdef KLUDGELINEMODE
else if (lmodetype == KLUDGE_LINEMODE || lmodetype == KLUDGE_OK)
setenv("LINEMODE", "kludge", 1);
# endif
#endif
#ifdef BFTPDAEMON
/*
* Are we working as the bftp daemon? If so, then ask login
@@ -1576,7 +1636,7 @@ start_login(host, autologin, name)
if (bftpd) {
argv = addarg(argv, "-e");
argv = addarg(argv, BFTPPATH);
} else
} else
#endif
#if defined (SecurID)
/*
@@ -1688,11 +1748,27 @@ start_login(host, autologin, name)
*/
unsetenv("USER");
}
#ifdef SOLARIS
else {
char **p;
argv = addarg(argv, ""); /* no login name */
for (p = environ; *p; p++) {
argv = addarg(argv, *p);
}
}
#endif /* SOLARIS */
#if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
if (pty > 2)
close(pty);
#endif
closelog();
/*
* This sleep(1) is in here so that telnetd can
* finish up with the tty. There's a race condition
* the login banner message gets lost...
*/
sleep(1);
execv(_PATH_LOGIN, argv);
syslog(LOG_ERR, "%s: %m\n", _PATH_LOGIN);
@@ -1722,7 +1798,7 @@ addarg(argv, val)
if (cpp == &argv[(int)argv[-1]]) {
--argv;
*argv = (char *)((int)(*argv) + 10);
argv = (char **)realloc(argv, (int)(*argv) + 2);
argv = (char **)realloc(argv, sizeof(*argv)*((int)(*argv) + 2));
if (argv == NULL)
return(NULL);
argv++;
@@ -1775,6 +1851,8 @@ cleanup(sig)
# ifdef CRAY
static int incleanup = 0;
register int t;
int child_status; /* status of child process as returned by waitpid */
int flags = WNOHANG|WUNTRACED;
/*
* 1: Pick up the zombie, if we are being called
@@ -1785,9 +1863,17 @@ cleanup(sig)
* 5: Close down the network and pty connections.
* 6: Finish up the TMPDIR cleanup, if needed.
*/
if (sig == SIGCHLD)
while (waitpid(-1, 0, WNOHANG) > 0)
if (sig == SIGCHLD) {
while (waitpid(-1, &child_status, flags) > 0)
; /* VOID */
/* Check if the child process was stopped
* rather than exited. We want cleanup only if
* the child has died.
*/
if (WIFSTOPPED(child_status)) {
return;
}
}
t = sigblock(sigmask(SIGCHLD));
if (incleanup) {
sigsetmask(t);
@@ -1795,6 +1881,7 @@ cleanup(sig)
}
incleanup = 1;
sigsetmask(t);
#ifdef UNICOS7x
if (secflag) {
/*
* We need to set ourselves back to a null
@@ -1804,6 +1891,7 @@ cleanup(sig)
setulvl(sysv.sy_minlvl);
setucmp((long)0);
}
#endif /* UNICOS7x */
t = cleantmp(&wtmp);
setutent(); /* just to make sure */
@@ -1903,6 +1991,28 @@ sigjob(sig)
}
}
/*
* jid_getutid:
* called by jobend() before calling cleantmp()
* to find the correct $TMPDIR to cleanup.
*/
struct utmp *
jid_getutid(jid)
int jid;
{
struct utmp *cur = NULL;
setutent(); /* just to make sure */
while (cur = getutent()) {
if ( (cur->ut_type != NULL) && (jid == cur->ut_jid) ) {
return(cur);
}
}
return(0);
}
/*
* Clean up the TMPDIR that login created.
* The first time this is called we pick up the info
@@ -1959,9 +2069,27 @@ jobend(jid, path, user)
register char *user;
{
static int saved_jid = 0;
static int pty_saved_jid = 0;
static char saved_path[sizeof(wtmp.ut_tpath)+1];
static char saved_user[sizeof(wtmp.ut_user)+1];
/*
* this little piece of code comes into play
* only when ptyreconnect is used to reconnect
* to an previous session.
*
* this is the only time when the
* "saved_jid != jid" code is executed.
*/
if ( saved_jid && saved_jid != jid ) {
if (!path) { /* called from signal handler */
pty_saved_jid = jid;
} else {
pty_saved_jid = saved_jid;
}
}
if (path) {
strncpy(saved_path, path, sizeof(wtmp.ut_tpath));
strncpy(saved_user, user, sizeof(wtmp.ut_user));
@@ -1972,6 +2100,24 @@ jobend(jid, path, user)
saved_jid = jid;
return(0);
}
/* if the jid has changed, get the correct entry from the utmp file */
if ( saved_jid != jid ) {
struct utmp *utp = NULL;
struct utmp *jid_getutid();
utp = jid_getutid(pty_saved_jid);
if (utp == 0) {
syslog(LOG_ERR, "Can't get /etc/utmp entry to clean TMPDIR");
return(-1);
}
cleantmpdir(jid, utp->ut_tpath, utp->ut_user);
return(1);
}
cleantmpdir(jid, saved_path, saved_user);
return(1);
}
@@ -2061,7 +2207,7 @@ rmut()
if (statbf.st_size && utmp) {
nutmp = read(f, (char *)utmp, (int)statbf.st_size);
nutmp /= sizeof(struct utmp);
for (u = utmp ; u < &utmp[nutmp] ; u++) {
if (SCMPN(u->ut_line, line+5) ||
u->ut_name[0]==0)

View File

@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)telnetd.8 8.3 (Berkeley) 3/1/94
.\" @(#)telnetd.8 8.4 (Berkeley) 6/1/94
.\"
.Dd March 1, 1994
.Dd June 1, 1994
.Dt TELNETD 8
.Os BSD 4.2
.Sh NAME
@@ -308,6 +308,7 @@ indicates that only dotted decimal addresses
should be put into the
.Pa utmp
file.
.ne 1i
.It Fl U
This option causes
.Nm telnetd
@@ -424,6 +425,7 @@ Whenever a
command is received, it is always responded
to with a
.Dv WILL TIMING-MARK
.ne 1i
.It "WILL LOGOUT"
When a
.Dv DO LOGOUT

View File

@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)telnetd.c 8.2 (Berkeley) 12/15/93";
static char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -451,7 +451,7 @@ main(argc, argv)
int szi = sizeof(int);
#endif /* SO_SEC_MULTI */
bzero((char *)&dv, sizeof(dv));
memset((char *)&dv, 0, sizeof(dv));
if (getsysv(&sysv, sizeof(struct sysv)) != 0) {
perror("getsysv");
@@ -637,34 +637,40 @@ getterminaltype(name)
static unsigned char sb[] =
{ IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC, SE };
bcopy(sb, nfrontp, sizeof sb);
memmove(nfrontp, sb, sizeof sb);
nfrontp += sizeof sb;
DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
}
if (his_state_is_will(TELOPT_XDISPLOC)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_XDISPLOC, TELQUAL_SEND, IAC, SE };
bcopy(sb, nfrontp, sizeof sb);
memmove(nfrontp, sb, sizeof sb);
nfrontp += sizeof sb;
DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
}
if (his_state_is_will(TELOPT_NEW_ENVIRON)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_NEW_ENVIRON, TELQUAL_SEND, IAC, SE };
bcopy(sb, nfrontp, sizeof sb);
memmove(nfrontp, sb, sizeof sb);
nfrontp += sizeof sb;
DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
}
else if (his_state_is_will(TELOPT_OLD_ENVIRON)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_OLD_ENVIRON, TELQUAL_SEND, IAC, SE };
bcopy(sb, nfrontp, sizeof sb);
memmove(nfrontp, sb, sizeof sb);
nfrontp += sizeof sb;
DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
}
if (his_state_is_will(TELOPT_TTYPE)) {
bcopy(ttytype_sbbuf, nfrontp, sizeof ttytype_sbbuf);
memmove(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf);
nfrontp += sizeof ttytype_sbbuf;
DIAG(TD_OPTIONS, printsub('>', ttytype_sbbuf + 2,
sizeof ttytype_sbbuf - 2););
}
if (his_state_is_will(TELOPT_TSPEED)) {
while (sequenceIs(tspeedsubopt, baseline))
@@ -737,8 +743,10 @@ _gettermname()
if (his_state_is_wont(TELOPT_TTYPE))
return;
settimer(baseline);
bcopy(ttytype_sbbuf, nfrontp, sizeof ttytype_sbbuf);
memmove(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf);
nfrontp += sizeof ttytype_sbbuf;
DIAG(TD_OPTIONS, printsub('>', ttytype_sbbuf + 2,
sizeof ttytype_sbbuf - 2););
while (sequenceIs(ttypesubopt, baseline))
ttloop();
}
@@ -816,7 +824,7 @@ doit(who)
#if defined(_SC_CRAY_SECURE_SYS)
/*
* set ttyp line security label
* set ttyp line security label
*/
if (secflag) {
char slave_dev[16];
@@ -836,9 +844,10 @@ doit(who)
if (hp == NULL && registerd_host_only) {
fatal(net, "Couldn't resolve your address into a host name.\r\n\
Please contact your net administrator");
Please contact your net administrator");
} else if (hp &&
(strlen(hp->h_name) <= ((utmp_len < 0) ? -utmp_len : utmp_len))) {
(strlen(hp->h_name) <= (unsigned int)((utmp_len < 0) ? -utmp_len
: utmp_len))) {
host = hp->h_name;
} else {
host = inet_ntoa(who->sin_addr);
@@ -927,6 +936,7 @@ telnet(f, p, host)
char *HN;
char *IM;
void netflush();
int nfd;
/*
* Initialize the slc mapping table.
@@ -1156,6 +1166,7 @@ telnet(f, p, host)
startslave(host);
#endif
nfd = ((f > p) ? f : p) + 1;
for (;;) {
fd_set ibits, obits, xbits;
register int c;
@@ -1187,7 +1198,7 @@ telnet(f, p, host)
if (!SYNCHing) {
FD_SET(f, &xbits);
}
if ((c = select(16, &ibits, &obits, &xbits,
if ((c = select(nfd, &ibits, &obits, &xbits,
(struct timeval *)0)) < 1) {
if (c == -1) {
if (errno == EINTR) {
@@ -1326,6 +1337,9 @@ telnet(f, p, host)
*nfrontp++ = IAC;
*nfrontp++ = DM;
neturg = nfrontp-1; /* off by one XXX */
DIAG(TD_OPTIONS,
printoption("td: send IAC", DM));
#endif
}
if (his_state_is_will(TELOPT_LFLOW) &&
@@ -1342,6 +1356,9 @@ telnet(f, p, host)
: LFLOW_OFF,
IAC, SE);
nfrontp += 6;
DIAG(TD_OPTIONS, printsub('>',
(unsigned char *)nfrontp-4,
4););
}
}
pcc--;
@@ -1400,7 +1417,7 @@ telnet(f, p, host)
}
cleanup(0);
} /* end of telnet */
#ifndef TCSIG
# ifdef TIOCSIG
# define TCSIG TIOCSIG
@@ -1476,7 +1493,7 @@ int readstream(p, ibuf, bufsize)
tp = (struct termio *) (ibuf+1 + sizeof(struct iocblk));
vstop = tp->c_cc[VSTOP];
vstart = tp->c_cc[VSTART];
ixon = tp->c_iflag & IXON;
ixon = tp->c_iflag & IXON;
break;
default:
errno = EAGAIN;
@@ -1507,6 +1524,14 @@ interrupt()
{
ptyflush(); /* half-hearted */
#if defined(STREAMSPTY) && defined(TIOCSIGNAL)
/* Streams PTY style ioctl to post a signal */
{
int sig = SIGINT;
(void) ioctl(pty, TIOCSIGNAL, &sig);
(void) ioctl(pty, I_FLUSH, FLUSHR);
}
#else
#ifdef TCSIG
(void) ioctl(pty, TCSIG, (char *)SIGINT);
#else /* TCSIG */
@@ -1514,6 +1539,7 @@ interrupt()
*pfrontp++ = slctab[SLC_IP].sptr ?
(unsigned char)*slctab[SLC_IP].sptr : '\177';
#endif /* TCSIG */
#endif
}
/*

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)termstat.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -320,7 +320,7 @@ localstat()
nfrontp += 7;
editmode = useeditmode;
}
/*
* Check for changes to special characters in use.
@@ -422,7 +422,7 @@ clientstat(code, parm1, parm2)
uselinemode = 1;
}
}
/*
* Quit now if we can't do it.
*/
@@ -463,7 +463,7 @@ clientstat(code, parm1, parm2)
send_will(TELOPT_ECHO, 1);
}
break;
case LM_MODE:
{
register int ack, changed;
@@ -512,7 +512,7 @@ clientstat(code, parm1, parm2)
IAC, SE);
nfrontp += 7;
}
editmode = useeditmode;
}
@@ -546,9 +546,9 @@ clientstat(code, parm1, parm2)
(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);
}
#endif /* TIOCSWINSZ */
break;
case TELOPT_TSPEED:
{
def_tspeed = parm1;
@@ -613,7 +613,7 @@ _termstat()
*
* Some things should not be done until after the login process has started
* and all the pty modes are set to what they are supposed to be. This
* function is called when the pty state has been processed for the first time.
* function is called when the pty state has been processed for the first time.
* It calls other functions that do things that were deferred in each module.
*/
void
@@ -632,7 +632,7 @@ defer_terminit()
if (def_col || def_row) {
struct winsize ws;
bzero((char *)&ws, sizeof(ws));
memset((char *)&ws, 0, sizeof(ws));
ws.ws_col = def_col;
ws.ws_row = def_row;
(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);

View File

@@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)utility.c 8.2 (Berkeley) 12/15/93";
static char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95";
#endif /* not lint */
#define PRINTOPTIONS
@@ -220,7 +220,7 @@ netclear()
next = nextitem(next);
} while (wewant(next) && (nfrontp > next));
length = next-thisitem;
bcopy(thisitem, good, length);
memmove(good, thisitem, length);
good += length;
thisitem = next;
} else {
@@ -327,7 +327,7 @@ writenet(ptr, len)
netflush();
}
bcopy(ptr, nfrontp, len);
memmove(nfrontp, ptr, len);
nfrontp += len;
} /* end of writenet */
@@ -368,7 +368,7 @@ fatalperror(f, msg)
{
char buf[BUFSIZ], *strerror();
(void) sprintf(buf, "%s: %s\r\n", msg, strerror(errno));
(void) sprintf(buf, "%s: %s", msg, strerror(errno));
fatal(f, buf);
}
@@ -449,9 +449,9 @@ putf(cp, where)
time_t t;
char db[100];
#ifdef STREAMSPTY
extern char *index();
extern char *strchr();
#else
extern char *rindex();
extern char *strrchr();
#endif
putlocation = where;
@@ -466,9 +466,9 @@ putf(cp, where)
case 't':
#ifdef STREAMSPTY
/* names are like /dev/pts/2 -- we want pts/2 */
slash = index(line+1, '/');
slash = strchr(line+1, '/');
#else
slash = rindex(line, '/');
slash = strrchr(line, '/');
#endif
if (slash == (char *) 0)
putstr(line);
@@ -522,7 +522,7 @@ printsub(direction, pointer, length)
register int i;
char buf[512];
if (!(diagnostic & TD_OPTIONS))
if (!(diagnostic & TD_OPTIONS))
return;
if (direction) {
@@ -713,7 +713,7 @@ printsub(direction, pointer, length)
break;
}
break;
case LM_SLC:
sprintf(nfrontp, "SLC");
nfrontp += strlen(nfrontp);
@@ -863,7 +863,7 @@ printsub(direction, pointer, length)
nfrontp += strlen(nfrontp);
break;
default:
sprintf(nfrontp, " %d", pointer[i]);
nfrontp += strlen(nfrontp);
@@ -966,7 +966,7 @@ printsub(direction, pointer, length)
case TELOPT_AUTHENTICATION:
sprintf(nfrontp, "AUTHENTICATION");
nfrontp += strlen(nfrontp);
if (length < 2) {
sprintf(nfrontp, " (empty suboption??\?)");
nfrontp += strlen(nfrontp);
@@ -1134,9 +1134,9 @@ printsub(direction, pointer, length)
default:
if (TELOPT_OK(pointer[0]))
sprintf(nfrontp, "%s (unknown)", TELOPT(pointer[0]));
sprintf(nfrontp, "%s (unknown)", TELOPT(pointer[0]));
else
sprintf(nfrontp, "%d (unknown)", pointer[i]);
sprintf(nfrontp, "%d (unknown)", pointer[i]);
nfrontp += strlen(nfrontp);
for (i = 1; i < length; i++) {
sprintf(nfrontp, " %d", pointer[i]);
@@ -1171,13 +1171,13 @@ printdata(tag, ptr, cnt)
nfrontp += strlen(nfrontp);
for (i = 0; i < 20 && cnt; i++) {
sprintf(nfrontp, "%02x", *ptr);
nfrontp += strlen(nfrontp);
nfrontp += strlen(nfrontp);
if (isprint(*ptr)) {
xbuf[i] = *ptr;
} else {
xbuf[i] = '.';
}
if (i % 2) {
if (i % 2) {
*nfrontp = ' ';
nfrontp++;
}
@@ -1187,6 +1187,6 @@ printdata(tag, ptr, cnt)
xbuf[i] = '\0';
sprintf(nfrontp, " %s\r\n", xbuf );
nfrontp += strlen(nfrontp);
}
}
}
#endif /* DIAGNOSTICS */