summaryrefslogtreecommitdiffstats
path: root/eBones/libexec
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1995-07-20 11:40:06 +0000
committerpst <pst@FreeBSD.org>1995-07-20 11:40:06 +0000
commitd6b93135e2743f89332a3ea7f97d682dd40c7b85 (patch)
tree16908c200b05bff2e4532927f105621ae791d795 /eBones/libexec
parentb8e783516fe93f74be3f95b44fbeb5719a33d819 (diff)
downloadFreeBSD-src-d6b93135e2743f89332a3ea7f97d682dd40c7b85.zip
FreeBSD-src-d6b93135e2743f89332a3ea7f97d682dd40c7b85.tar.gz
Update telnet to the 95.05.31 release.
Obtained from: Dave Borman <dab@cray.com>
Diffstat (limited to 'eBones/libexec')
-rw-r--r--eBones/libexec/telnetd/Makefile13
-rw-r--r--eBones/libexec/telnetd/authenc.c4
-rw-r--r--eBones/libexec/telnetd/slc.c6
-rw-r--r--eBones/libexec/telnetd/state.c20
-rw-r--r--eBones/libexec/telnetd/sys_term.c216
-rw-r--r--eBones/libexec/telnetd/telnetd.86
-rw-r--r--eBones/libexec/telnetd/telnetd.c46
-rw-r--r--eBones/libexec/telnetd/termstat.c4
-rw-r--r--eBones/libexec/telnetd/utility.c16
9 files changed, 252 insertions, 79 deletions
diff --git a/eBones/libexec/telnetd/Makefile b/eBones/libexec/telnetd/Makefile
index 0bfa3c3..79dbb75 100644
--- a/eBones/libexec/telnetd/Makefile
+++ b/eBones/libexec/telnetd/Makefile
@@ -4,14 +4,23 @@ PROG= telnetd
CFLAGS+=-DLINEMODE -DKLUDGELINEMODE -DUSE_TERMIO -DDIAGNOSTICS
CFLAGS+=-DOLD_ENVIRON -DENV_HACK
CFLAGS+=-I${.CURDIR}/../../lib
-#CFLAGS+=-DAUTHENTICATION -DENCRYPTION
SRCS= authenc.c global.c slc.c state.c sys_term.c telnetd.c \
termstat.c utility.c
DPADD= ${LIBUTIL} ${LIBTERMCAP}
LDADD= -lutil -ltermcap -ltelnet
-#LDADD+= -lkrb -ldes
+
MAN8= telnetd.8
+#ifdef ENCRYPTION
+
+CFLAGS+=-DAUTHENTICATION -DENCRYPTION
+
+.if exists(/usr/lib/libkrb.a)
+LDADD+= -lkrb -ldes
+.endif
+
+#endif /* ENCRYPTION */
+
# These are the sources that have encryption stuff in them.
CRYPT_SRC= authenc.c ext.h state.c telnetd.c termstat.c
CRYPT_SRC+= utility.c Makefile
diff --git a/eBones/libexec/telnetd/authenc.c b/eBones/libexec/telnetd/authenc.c
index fcd17fc..ccb463c 100644
--- a/eBones/libexec/telnetd/authenc.c
+++ b/eBones/libexec/telnetd/authenc.c
@@ -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);
}
diff --git a/eBones/libexec/telnetd/slc.c b/eBones/libexec/telnetd/slc.c
index a03bd9d..6cbb7ab 100644
--- a/eBones/libexec/telnetd/slc.c
+++ b/eBones/libexec/telnetd/slc.c
@@ -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"
@@ -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);
}
}
diff --git a/eBones/libexec/telnetd/state.c b/eBones/libexec/telnetd/state.c
index fc5cbda..4ee8bea 100644
--- a/eBones/libexec/telnetd/state.c
+++ b/eBones/libexec/telnetd/state.c
@@ -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);
@@ -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);
diff --git a/eBones/libexec/telnetd/sys_term.c b/eBones/libexec/telnetd/sys_term.c
index 000cfb5..b699a64 100644
--- a/eBones/libexec/telnetd/sys_term.c
+++ b/eBones/libexec/telnetd/sys_term.c
@@ -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
@@ -943,6 +940,15 @@ tty_iscrnl()
}
/*
+ * 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
*/
struct termspeeds {
@@ -953,30 +959,68 @@ struct termspeeds {
{ 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 }
+ { 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)
@@ -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
@@ -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 */
@@ -1904,6 +1992,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
* from the utmp. If the job has already gone away,
@@ -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);
}
diff --git a/eBones/libexec/telnetd/telnetd.8 b/eBones/libexec/telnetd/telnetd.8
index fee5526..f618385 100644
--- a/eBones/libexec/telnetd/telnetd.8
+++ b/eBones/libexec/telnetd/telnetd.8
@@ -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
diff --git a/eBones/libexec/telnetd/telnetd.c b/eBones/libexec/telnetd/telnetd.c
index 66e040d..bfed2c2 100644
--- a/eBones/libexec/telnetd/telnetd.c
+++ b/eBones/libexec/telnetd/telnetd.c
@@ -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();
}
@@ -838,7 +846,8 @@ doit(who)
fatal(net, "Couldn't resolve your address into a host name.\r\n\
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--;
@@ -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
}
/*
diff --git a/eBones/libexec/telnetd/termstat.c b/eBones/libexec/telnetd/termstat.c
index ec68442..ebc843a 100644
--- a/eBones/libexec/telnetd/termstat.c
+++ b/eBones/libexec/telnetd/termstat.c
@@ -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"
@@ -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);
diff --git a/eBones/libexec/telnetd/utility.c b/eBones/libexec/telnetd/utility.c
index c24feb3..049fcd1 100644
--- a/eBones/libexec/telnetd/utility.c
+++ b/eBones/libexec/telnetd/utility.c
@@ -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);
OpenPOWER on IntegriCloud