2) Fix for SYSV VEOF/VMIN overlap
3) Add two missing "break" statements
4) Add SLC_FORW[12] support
5) start of TOS support
6) Make sure things get initialized properly
7) Don't send Urgent mode data, since some clients go into infinate loops...
SCCS-vsn: libexec/telnetd/defs.h 5.4
SCCS-vsn: libexec/telnetd/ext.h 5.4
SCCS-vsn: libexec/telnetd/slc.c 5.2
SCCS-vsn: libexec/telnetd/state.c 5.5
SCCS-vsn: libexec/telnetd/sys_term.c 5.5
SCCS-vsn: libexec/telnetd/telnetd.c 5.42
SCCS-vsn: libexec/telnetd/termstat.c 5.4
SCCS-vsn: libexec/telnetd/Makefile 5.7
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# @(#)Makefile 5.6 (Berkeley) %G%
+# @(#)Makefile 5.7 (Berkeley) %G%
LIBC= /lib/libc.a
# 4.4BSD
# LIBS= -lutil -ltermcap
LIBC= /lib/libc.a
# 4.4BSD
# LIBS= -lutil -ltermcap
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#)defs.h 5.3 (Berkeley) %G%
+ * @(#)defs.h 5.4 (Berkeley) %G%
#include <errno.h>
#include <netdb.h>
#include <syslog.h>
#include <errno.h>
#include <netdb.h>
#include <syslog.h>
+#ifndef LOG_DAEMON
+#define LOG_DAEMON 0
+#endif
+#ifndef LOG_ODELAY
+#define LOG_ODELAY 0
+#endif
#include <ctype.h>
#include <strings.h>
#ifndef USE_TERMIO
#include <sgtty.h>
#include <ctype.h>
#include <strings.h>
#ifndef USE_TERMIO
#include <sgtty.h>
+typedef unsigned char cc_t;
#else
# ifdef SYSV_TERMIO
# include <termio.h>
#else
# ifdef SYSV_TERMIO
# include <termio.h>
typedef struct fd_set { int fds_bits[1]; } fd_set;
typedef struct fd_set { int fds_bits[1]; } fd_set;
#define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n)))
#define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n)))
#define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n)))
#define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n)))
*/
typedef struct {
unsigned char flag; /* the flags for this function */
*/
typedef struct {
unsigned char flag; /* the flags for this function */
- unsigned char val; /* the value of the special character */
+ cc_t val; /* the value of the special character */
} slcent, *Slcent;
typedef struct {
slcent defset; /* the default settings */
slcent current; /* the current settings */
} slcent, *Slcent;
typedef struct {
slcent defset; /* the default settings */
slcent current; /* the current settings */
- unsigned char *sptr; /* a pointer to the char in */
+ cc_t *sptr; /* a pointer to the char in */
/* system data structures */
} slcfun, *Slcfun;
/* system data structures */
} slcfun, *Slcfun;
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#)ext.h 5.3 (Berkeley) %G%
+ * @(#)ext.h 5.4 (Berkeley) %G%
+#if defined(CRAY2) && defined(UNICOS5)
extern int unpcc; /* characters left unprocessed by CRAY-2 terminal routine */
extern char *unptyip; /* pointer to remaining characters in buffer */
#endif
extern int unpcc; /* characters left unprocessed by CRAY-2 terminal routine */
extern char *unptyip; /* pointer to remaining characters in buffer */
#endif
+#if defined(CRAY2) && defined(UNICOS5)
extern int needtermstat;
#endif
extern int needtermstat;
#endif
-static char sccsid[] = "@(#)slc.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)slc.c 5.2 (Berkeley) %G%";
#endif /* not lint */
#include "telnetd.h"
#endif /* not lint */
#include "telnetd.h"
-static char *def_slcbuf = (char *)0;;
+static char *def_slcbuf = (char *)0;
static int def_slclen = 0;
static int slcchange; /* change to slc is requested */
static char *slcptr; /* pointer into slc buffer */
static int def_slclen = 0;
static int slcchange; /* change to slc is requested */
static char *slcptr; /* pointer into slc buffer */
* Add an slc triplet to the slc buffer.
*/
add_slc(func, flag, val)
* Add an slc triplet to the slc buffer.
*/
add_slc(func, flag, val)
- register unsigned char func, flag, val;
+ register unsigned char func, flag;
+ cc_t val;
+ if ((*slcptr++ = func) == 0xff)
+ if ((*slcptr++ = flag) == 0xff)
+ if ((*slcptr++ = (unsigned char)val) == 0xff)
* Figure out what to do about the client's slc
*/
process_slc(func, flag, val)
* Figure out what to do about the client's slc
*/
process_slc(func, flag, val)
- register unsigned char func, flag, val;
+ register unsigned char func, flag;
+ cc_t val;
{
register int hislevel, mylevel, ack;
{
register int hislevel, mylevel, ack;
* Compare client's request with what we are capable of supporting.
*/
change_slc(func, flag, val)
* Compare client's request with what we are capable of supporting.
*/
change_slc(func, flag, val)
- register unsigned char func, flag, val;
+ register unsigned char func, flag;
+ cc_t val;
{
register int hislevel, mylevel;
{
register int hislevel, mylevel;
} /* end of change_slc */
} /* end of change_slc */
+#if defined(USE_TERMIO) && defined(SYSV_TERMIO)
+cc_t oldeofc = '\004';
+#endif
+
* ICANON is off, because it is not representing
* a special character.
*/
* ICANON is off, because it is not representing
* a special character.
*/
- if (!tty_isediting() && i == SLC_EOF)
- continue;
+ if (i == SLC_EOF) {
+ if (!tty_isediting())
+ continue;
+ else if (slctab[i].sptr)
+ oldeofc = *(slctab[i].sptr);
+ }
#endif /* defined(USE_TERMIO) && defined(SYSV_TERMIO) */
if (slctab[i].sptr &&
(*(slctab[i].sptr) != slctab[i].current.val)) {
#endif /* defined(USE_TERMIO) && defined(SYSV_TERMIO) */
if (slctab[i].sptr &&
(*(slctab[i].sptr) != slctab[i].current.val)) {
register char *ptr;
register int len;
{
register char *ptr;
register int len;
{
- register unsigned char func, flag, val;
+ register unsigned char func, flag;
+ cc_t val;
register char *end = (char *)(ptr + len);
char *malloc();
register char *end = (char *)(ptr + len);
char *malloc();
if (ptr >= end) break;
flag = *ptr++;
if (ptr >= end) break;
if (ptr >= end) break;
flag = *ptr++;
if (ptr >= end) break;
process_slc(func, flag, val);
process_slc(func, flag, val);
-static char sccsid[] = "@(#)state.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)state.c 5.5 (Berkeley) %G%";
#endif /* not lint */
#include "telnetd.h"
#endif /* not lint */
#include "telnetd.h"
{
register int c;
static int state = TS_DATA;
{
register int c;
static int state = TS_DATA;
+#if defined(CRAY2) && defined(UNICOS5)
char *opfrontp = pfrontp;
#endif
char *opfrontp = pfrontp;
#endif
init_termbuf();
if (slctab[SLC_AO].sptr &&
init_termbuf();
if (slctab[SLC_AO].sptr &&
- *slctab[SLC_AO].sptr != '\377') {
- *pfrontp++ = *slctab[SLC_AO].sptr;
+ *slctab[SLC_AO].sptr != (cc_t)-1) {
+ *pfrontp++ =
+ (unsigned char)*slctab[SLC_AO].sptr;
}
netclear(); /* clear buffer back */
}
netclear(); /* clear buffer back */
ptyflush(); /* half-hearted */
init_termbuf();
ch = (c == EC) ? *slctab[SLC_EC].sptr :
*slctab[SLC_EL].sptr;
ptyflush(); /* half-hearted */
init_termbuf();
ch = (c == EC) ? *slctab[SLC_EC].sptr :
*slctab[SLC_EL].sptr;
- if (ch != '\377')
- *pfrontp++ = ch;
+ if (ch != (cc_t)-1)
+ *pfrontp++ = (unsigned char)ch;
+#if defined(CRAY2) && defined(UNICOS5)
if (!linemode) {
char xptyobuf[BUFSIZ+NETSLOP];
char xbuf2[BUFSIZ];
if (!linemode) {
char xptyobuf[BUFSIZ+NETSLOP];
char xbuf2[BUFSIZ];
if ((*nfrontp++ = *cp++) == IAC)
*nfrontp++ = IAC;
}
if ((*nfrontp++ = *cp++) == IAC)
*nfrontp++ = IAC;
}
+#endif /* defined(CRAY2) && defined(UNICOS5) */
* peer probably should be buffering until this option state negotiation
* is complete.
*
* peer probably should be buffering until this option state negotiation
* is complete.
*
- * In processing options, request signifies whether this is a request
- * to send or a response. request is true if this is a request to
- * send generated locally.
*/
send_do(option, init)
int option, init;
*/
send_do(option, init)
int option, init;
/*
* Process client input.
*/
/*
* Process client input.
*/
if (will_wont_resp[option]) {
will_wont_resp[option]--;
if (will_wont_resp[option] && myopts[option] == OPT_NO)
if (will_wont_resp[option]) {
will_wont_resp[option]--;
if (will_wont_resp[option] && myopts[option] == OPT_NO)
} /* end of case TELOPT_LINEMODE */
#endif
case TELOPT_STATUS: {
} /* end of case TELOPT_LINEMODE */
#endif
case TELOPT_STATUS: {
+ break;
+ } /* end of case TELOPT_STATUS */
-static char sccsid[] = "@(#)sys_term.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)sys_term.c 5.5 (Berkeley) %G%";
#endif /* not lint */
#include "telnetd.h"
#endif /* not lint */
#include "telnetd.h"
#else /* USE_TERMIO */
if (bcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
(void) ioctl(pty, TCSETA, (char *)&termbuf);
#else /* USE_TERMIO */
if (bcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
(void) ioctl(pty, TCSETA, (char *)&termbuf);
+# if defined(CRAY2) && defined(UNCIOS5)
needtermstat = 1;
# endif
#endif /* USE_TERMIO */
needtermstat = 1;
# endif
#endif /* USE_TERMIO */
#ifndef USE_TERMIO
spcset(func, valp, valpp)
int func;
#ifndef USE_TERMIO
spcset(func, valp, valpp)
int func;
-unsigned char *valp;
-unsigned char **valpp;
+cc_t *valp;
+cc_t **valpp;
{
switch(func) {
case SLC_EOF:
*valp = termbuf.tc.t_eofc;
{
switch(func) {
case SLC_EOF:
*valp = termbuf.tc.t_eofc;
- *valpp = (unsigned char *)&termbuf.tc.t_eofc;
+ *valpp = (cc_t *)&termbuf.tc.t_eofc;
return(SLC_VARIABLE);
case SLC_EC:
*valp = termbuf.sg.sg_erase;
return(SLC_VARIABLE);
case SLC_EC:
*valp = termbuf.sg.sg_erase;
- *valpp = (unsigned char *)&termbuf.sg.sg_erase;
+ *valpp = (cc_t *)&termbuf.sg.sg_erase;
return(SLC_VARIABLE);
case SLC_EL:
*valp = termbuf.sg.sg_kill;
return(SLC_VARIABLE);
case SLC_EL:
*valp = termbuf.sg.sg_kill;
- *valpp = (unsigned char *)&termbuf.sg.sg_kill;
+ *valpp = (cc_t *)&termbuf.sg.sg_kill;
return(SLC_VARIABLE);
case SLC_IP:
*valp = termbuf.tc.t_intrc;
return(SLC_VARIABLE);
case SLC_IP:
*valp = termbuf.tc.t_intrc;
- *valpp = (unsigned char *)&termbuf.tc.t_intrc;
+ *valpp = (cc_t *)&termbuf.tc.t_intrc;
return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
case SLC_ABORT:
*valp = termbuf.tc.t_quitc;
return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
case SLC_ABORT:
*valp = termbuf.tc.t_quitc;
- *valpp = (unsigned char *)&termbuf.tc.t_quitc;
+ *valpp = (cc_t *)&termbuf.tc.t_quitc;
return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
case SLC_XON:
*valp = termbuf.tc.t_startc;
return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
case SLC_XON:
*valp = termbuf.tc.t_startc;
- *valpp = (unsigned char *)&termbuf.tc.t_startc;
+ *valpp = (cc_t *)&termbuf.tc.t_startc;
return(SLC_VARIABLE);
case SLC_XOFF:
*valp = termbuf.tc.t_stopc;
return(SLC_VARIABLE);
case SLC_XOFF:
*valp = termbuf.tc.t_stopc;
- *valpp = (unsigned char *)&termbuf.tc.t_stopc;
+ *valpp = (cc_t *)&termbuf.tc.t_stopc;
return(SLC_VARIABLE);
case SLC_AO:
*valp = termbuf.ltc.t_flushc;
return(SLC_VARIABLE);
case SLC_AO:
*valp = termbuf.ltc.t_flushc;
- *valpp = (unsigned char *)&termbuf.ltc.t_flushc;
+ *valpp = (cc_t *)&termbuf.ltc.t_flushc;
return(SLC_VARIABLE);
case SLC_SUSP:
*valp = termbuf.ltc.t_suspc;
return(SLC_VARIABLE);
case SLC_SUSP:
*valp = termbuf.ltc.t_suspc;
- *valpp = (unsigned char *)&termbuf.ltc.t_suspc;
+ *valpp = (cc_t *)&termbuf.ltc.t_suspc;
return(SLC_VARIABLE);
case SLC_EW:
*valp = termbuf.ltc.t_werasc;
return(SLC_VARIABLE);
case SLC_EW:
*valp = termbuf.ltc.t_werasc;
- *valpp = (unsigned char *)&termbuf.ltc.t_werasc;
+ *valpp = (cc_t *)&termbuf.ltc.t_werasc;
return(SLC_VARIABLE);
case SLC_RP:
*valp = termbuf.ltc.t_rprntc;
return(SLC_VARIABLE);
case SLC_RP:
*valp = termbuf.ltc.t_rprntc;
- *valpp = (unsigned char *)&termbuf.ltc.t_rprntc;
+ *valpp = (cc_t *)&termbuf.ltc.t_rprntc;
return(SLC_VARIABLE);
case SLC_LNEXT:
*valp = termbuf.ltc.t_lnextc;
return(SLC_VARIABLE);
case SLC_LNEXT:
*valp = termbuf.ltc.t_lnextc;
- *valpp = (unsigned char *)&termbuf.ltc.t_lnextc;
+ *valpp = (cc_t *)&termbuf.ltc.t_lnextc;
+ return(SLC_VARIABLE);
+ case SLC_FORW1:
+ *valp = termbuf.tc.t_brkc;
+ *valpp = (cc_t *)&termbuf.ltc.t_lnextc;
return(SLC_VARIABLE);
case SLC_BRK:
case SLC_SYNCH:
case SLC_AYT:
case SLC_EOR:
return(SLC_VARIABLE);
case SLC_BRK:
case SLC_SYNCH:
case SLC_AYT:
case SLC_EOR:
- *valp = 0;
- *valpp = 0;
+ *valp = (cc_t)0;
+ *valpp = (cc_t *)0;
return(SLC_DEFAULT);
default:
return(SLC_DEFAULT);
default:
- *valp = 0;
- *valpp = 0;
+ *valp = (cc_t)0;
+ *valpp = (cc_t *)0;
return(SLC_NOSUPPORT);
}
}
return(SLC_NOSUPPORT);
}
}
spcset(func, valp, valpp)
int func;
spcset(func, valp, valpp)
int func;
-unsigned char *valp;
-unsigned char **valpp;
+cc_t *valp;
+cc_t **valpp;
{
#define setval(a, b) *valp = termbuf.c_cc[a]; \
*valpp = &termbuf.c_cc[a]; \
return(b);
{
#define setval(a, b) *valp = termbuf.c_cc[a]; \
*valpp = &termbuf.c_cc[a]; \
return(b);
-#define defval(a) *valp = (a); *valpp = 0; return(SLC_DEFAULT);
+#define defval(a) *valp = ((cc_t)a); *valpp = (cc_t *)0; return(SLC_DEFAULT);
switch(func) {
case SLC_EOF:
switch(func) {
case SLC_EOF:
+#ifdef VEOL
+ case SLC_FORW1:
+ setval(VEOL, SLC_VARIABLE);
+#endif
+#ifdef VEOL2
+ case SLC_FORW2:
+ setval(VEOL2, SLC_VARIABLE);
+#endif
case SLC_BRK:
case SLC_SYNCH:
case SLC_BRK:
case SLC_SYNCH:
}
#endif /* USE_TERMIO */
}
#endif /* USE_TERMIO */
+#ifdef CRAY
+/*
+ * getnpty()
+ *
+ * Return the number of pty's configured into the system.
+ */
+getnpty()
+{
+#ifdef _SC_CRAY_NPTY
+ return sysconf(_SC_CRAY_NPTY);
+#else
+ return 128;
+#endif /* _SC_CRAY_NPTY */
+}
+#endif /* CRAY */
+
+#if defined(CRAY2) && defined(UNICOS5)
tty_isnewmap()
{
return((termbuf.c_oflag & OPOST) && (termbuf.c_oflag & ONLCR) &&
tty_isnewmap()
{
return((termbuf.c_oflag & OPOST) && (termbuf.c_oflag & ONLCR) &&
extern char wtmpf[];
# else /* NEWINIT */
int gotalarm;
extern char wtmpf[];
# else /* NEWINIT */
int gotalarm;
+/* ARGSUSED */
+void
+nologinproc(sig)
+int sig;
init_termbuf();
#ifndef USE_TERMIO
init_termbuf();
#ifndef USE_TERMIO
- termbuf.sg.sg_flags |= CRMOD|ANYP|ECHO;
+ termbuf.sg.sg_flags |= CRMOD|ANYP|ECHO|XTABS;
termbuf.sg.sg_ospeed = termbuf.sg.sg_ispeed = B9600;
#else
termbuf.c_lflag |= ECHO;
termbuf.sg.sg_ospeed = termbuf.sg.sg_ispeed = B9600;
#else
termbuf.c_lflag |= ECHO;
extern char *ptyip;
struct init_request request;
extern char *ptyip;
struct init_request request;
SCPYN(request.tty_id, &line[8]);
SCPYN(request.host, host);
SCPYN(request.term_type, &terminaltype[5]);
SCPYN(request.tty_id, &line[8]);
SCPYN(request.host, host);
SCPYN(request.term_type, &terminaltype[5]);
+#if defined(UNICOS5)
+ request.signal = SIGCLD;
+ request.pid = getpid();
+#endif
if (write(i, (char *)&request, sizeof(request)) < 0) {
char tbuf[128];
(void) sprintf(tbuf, "Can't write to %s\n", INIT_FIFO);
if (write(i, (char *)&request, sizeof(request)) < 0) {
char tbuf[128];
(void) sprintf(tbuf, "Can't write to %s\n", INIT_FIFO);
(void) close(i);
(void) signal(SIGALRM, nologinproc);
for (i = 0; ; i++) {
(void) close(i);
(void) signal(SIGALRM, nologinproc);
for (i = 0; ; i++) {
alarm(15);
n = read(pty, ptyip, BUFSIZ);
if (i == 3 || n >= 0 || !gotalarm)
break;
gotalarm = 0;
alarm(15);
n = read(pty, ptyip, BUFSIZ);
if (i == 3 || n >= 0 || !gotalarm)
break;
gotalarm = 0;
- (void) write(net, "telnetd: waiting for /etc/init to start login process.\r\n", 56);
+ sprintf(tbuf, "telnetd: waiting for /etc/init to start login process on %s\r\n", line);
+ (void) write(net, tbuf, strlen(tbuf));
}
if (n < 0 && gotalarm)
fatal(net, "/etc/init didn't start login process");
}
if (n < 0 && gotalarm)
fatal(net, "/etc/init didn't start login process");
alarm(0);
(void) signal(SIGALRM, SIG_DFL);
alarm(0);
(void) signal(SIGALRM, SIG_DFL);
- /*
- * Set tab expansion the way we like, in case init did something
- * different.
- */
- init_termbuf();
- termbuf.c_oflag &= ~TABDLY;
- termbuf.c_oflag |= TAB0;
- set_termbuf();
return;
#endif /* NEWINIT */
}
return;
#endif /* NEWINIT */
}
* set ttyp modes as we like them to be
*/
init_termbuf();
* set ttyp modes as we like them to be
*/
init_termbuf();
- termbuf.c_oflag = OPOST|ONLCR;
+ termbuf.c_oflag = OPOST|ONLCR|TAB3;
termbuf.c_iflag = IGNPAR|ISTRIP|ICRNL|IXON;
termbuf.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
termbuf.c_cflag = EXTB|HUPCL|CS8;
termbuf.c_iflag = IGNPAR|ISTRIP|ICRNL|IXON;
termbuf.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
termbuf.c_cflag = EXTB|HUPCL|CS8;
kill(0, SIGHUP);
# else /* NEWINIT */
(void) shutdown(net, 2);
kill(0, SIGHUP);
# else /* NEWINIT */
(void) shutdown(net, 2);
# endif /* NEWINT */
#endif /* CRAY */
exit(1);
# endif /* NEWINT */
#endif /* CRAY */
exit(1);
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)telnetd.c 5.41 (Berkeley) %G%";
+static char sccsid[] = "@(#)telnetd.c 5.42 (Berkeley) %G%";
#endif /* not lint */
#include "telnetd.h"
#endif /* not lint */
#include "telnetd.h"
#ifdef CRAY
extern int newmap; /* nonzero if \n maps to ^M^J */
#ifdef CRAY
extern int newmap; /* nonzero if \n maps to ^M^J */
-int lowpty = 0, highpty = 128; /* low, high pty numbers */
+int lowpty = 0, highpty; /* low, high pty numbers */
#endif /* CRAY */
int debug = 0;
char *progname;
#endif /* CRAY */
int debug = 0;
char *progname;
+#if defined(IP_TOS) && defined(NEED_GETTOS)
+struct tosent {
+ char *t_name; /* name */
+ char **t_aliases; /* alias list */
+ char *t_proto; /* protocol */
+ int t_tos; /* Type Of Service bits */
+};
+
+struct tosent *
+gettosbyname(name, proto)
+char *name, *proto;
+{
+ static struct tosent te;
+ static char *aliasp = 0;
+
+ te.t_name = name;
+ te.t_aliases = &aliasp;
+ te.t_proto = proto;
+ te.t_tos = 020; /* Low Delay bit */
+ return(&te);
+}
+#endif
+
main(argc, argv)
char *argv[];
{
struct sockaddr_in from;
int on = 1, fromlen;
main(argc, argv)
char *argv[];
{
struct sockaddr_in from;
int on = 1, fromlen;
+#ifdef IP_TOS
+ struct tosent *tp;
+#endif /* IP_TOS */
pfrontp = pbackp = ptyobuf;
netip = netibuf;
nfrontp = nbackp = netobuf;
progname = *argv;
pfrontp = pbackp = ptyobuf;
netip = netibuf;
nfrontp = nbackp = netobuf;
progname = *argv;
+
+#ifdef CRAY
+ /*
+ * Get number of pty's before trying to process options,
+ * which may include changing pty range.
+ */
+ highpty = getnpty();
+#endif /* CRAY */
+
+ /*
+ * Allow the specification of alterations to the pty search
+ * range. It is legal to specify only one, and not change the
+ * other from its default.
+ */
*argv += 2;
if (**argv == '\0' && argc)
argv++, argc--;
*argv += 2;
if (**argv == '\0' && argc)
argv++, argc--;
if (c) {
*c++ = '\0';
highpty = atoi(c);
if (c) {
*c++ = '\0';
highpty = atoi(c);
- } else
- highpty = -1;
- lowpty = atoi(*argv);
- if ((lowpty > highpty) || (lowpty < 0) || (highpty > 999)) {
+ }
+ if (**argv != '\0')
+ lowpty = atoi(*argv);
+ if ((lowpty > highpty) || (lowpty < 0) || (highpty > 32767)) {
usage:
fprintf(stderr, "Usage: telnetd [-debug] [-h] ");
# ifdef NEWINIT
fprintf(stderr, "[-Iinitid] ");
# endif /* NEWINIT */
usage:
fprintf(stderr, "Usage: telnetd [-debug] [-h] ");
# ifdef NEWINIT
fprintf(stderr, "[-Iinitid] ");
# endif /* NEWINIT */
- fprintf(stderr, "[-l] [-rlowpty-highpty] [port]\n");
+ fprintf(stderr, "[-l] [-r[lowpty]-[highpty]] [port]\n");
if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
}
if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
}
+
+#ifdef IP_TOS
+ if ((tp = gettosbyname("telnet", "tcp")) &&
+ (setsockopt(0, IPPROTO_IP, IP_TOS, &tp->t_tos, sizeof(int)) < 0))
+ syslog(LOG_WARNING, "setsockopt (IP_TOS): %m");
+#endif /* IP_TOS */
net = 0;
doit(&from);
/* NOTREACHED */
} /* end of main */
net = 0;
doit(&from);
/* NOTREACHED */
} /* end of main */
{
int on = 1;
char hostname[MAXHOSTNAMELEN];
{
int on = 1;
char hostname[MAXHOSTNAMELEN];
+#if defined(CRAY2) && defined(UNICOS5)
int termstat();
int interrupt(), sendbrk();
#endif
int termstat();
int interrupt(), sendbrk();
#endif
* respond because it believes that it is already in DO ECHO
* mode, which we do not want.
*/
* respond because it believes that it is already in DO ECHO
* mode, which we do not want.
*/
- if (hiswants[TELOPT_ECHO] == OPT_YES)
+ if (hiswants[TELOPT_ECHO] == OPT_YES) {
/*
* Finally, to clean things up, we turn on our echo. This
/*
* Finally, to clean things up, we turn on our echo. This
(void) ioctl(f, FIONBIO, (char *)&on);
(void) ioctl(p, FIONBIO, (char *)&on);
(void) ioctl(f, FIONBIO, (char *)&on);
(void) ioctl(p, FIONBIO, (char *)&on);
+#if defined(CRAY2) && defined(UNICOS5)
init_termdriver(f, p, interrupt, sendbrk);
#endif
init_termdriver(f, p, interrupt, sendbrk);
#endif
(void) signal(SIGCHLD, cleanup);
(void) signal(SIGCHLD, cleanup);
+#if defined(CRAY2) && defined(UNICOS5)
/*
* Cray-2 will send a signal when pty modes are changed by slave
* side. Set up signal handler now.
/*
* Cray-2 will send a signal when pty modes are changed by slave
* side. Set up signal handler now.
#endif
(void) setpgrp(0, 0);
#endif
(void) setpgrp(0, 0);
+#ifdef TCSETCTTY
+ ioctl(p, TCSETCTTY, 0);
+#endif
/*
* Show banner that getty never gave.
/*
* Show banner that getty never gave.
(void) strncat(ptyibuf2, ptyip, pcc+1);
ptyip = ptyibuf2;
pcc = strlen(ptyip);
(void) strncat(ptyibuf2, ptyip, pcc+1);
ptyip = ptyibuf2;
pcc = strlen(ptyip);
+#ifdef LINEMODE
+ /*
+ * Last check to make sure all our states are correct.
+ */
+ init_termbuf();
+ localstat();
+#endif /* LINEMODE */
for (;;) {
fd_set ibits, obits, xbits;
for (;;) {
fd_set ibits, obits, xbits;
if (ncc < 0 && pcc < 0)
break;
if (ncc < 0 && pcc < 0)
break;
+#if defined(CRAY2) && defined(UNICOS5)
if (needtermstat)
_termstat();
if (needtermstat)
_termstat();
+#endif /* defined(CRAY2) && defined(UNICOS5) */
FD_ZERO(&ibits);
FD_ZERO(&obits);
FD_ZERO(&xbits);
FD_ZERO(&ibits);
FD_ZERO(&obits);
FD_ZERO(&xbits);
else {
if (pcc <= 0)
break;
else {
if (pcc <= 0)
break;
+#if !defined(CRAY2) || !defined(UNICOS5)
#ifdef LINEMODE
/*
* If ioctl from pty, pass it through net
#ifdef LINEMODE
/*
* If ioctl from pty, pass it through net
#endif LINEMODE
if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) {
netclear(); /* clear buffer back */
#endif LINEMODE
if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) {
netclear(); /* clear buffer back */
+#ifdef notdef
+ /*
+ * We really should have this in, but
+ * there are client telnets on some
+ * operating systems get screwed up
+ * royally if we send them urgent
+ * mode data. So, for now, we'll not
+ * do this...
+ */
*nfrontp++ = IAC;
*nfrontp++ = DM;
neturg = nfrontp-1; /* off by one XXX */
*nfrontp++ = IAC;
*nfrontp++ = DM;
neturg = nfrontp-1; /* off by one XXX */
}
if (hisopts[TELOPT_LFLOW] &&
(ptyibuf[0] &
}
if (hisopts[TELOPT_LFLOW] &&
(ptyibuf[0] &
}
pcc--;
ptyip = ptyibuf+1;
}
pcc--;
ptyip = ptyibuf+1;
+#else /* defined(CRAY2) && defined(UNICOS5) */
if (!uselinemode) {
unpcc = pcc;
unptyip = ptyibuf;
if (!uselinemode) {
unpcc = pcc;
unptyip = ptyibuf;
ptyip = ptyibuf2;
} else
ptyip = ptyibuf;
ptyip = ptyibuf2;
} else
ptyip = ptyibuf;
+#endif /* defined(CRAY2) && defined(UNICOS5) */
c = *ptyip++ & 0377, pcc--;
if (c == IAC)
*nfrontp++ = c;
c = *ptyip++ & 0377, pcc--;
if (c == IAC)
*nfrontp++ = c;
+#if defined(CRAY2) && defined(UNICOS5)
else if (c == '\n' &&
myopts[TELOPT_BINARY] == OPT_NO && newmap)
*nfrontp++ = '\r';
else if (c == '\n' &&
myopts[TELOPT_BINARY] == OPT_NO && newmap)
*nfrontp++ = '\r';
+#endif /* defined(CRAY2) && defined(UNICOS5) */
*nfrontp++ = c;
if ((c == '\r') && (myopts[TELOPT_BINARY] == OPT_NO)) {
if (pcc > 0 && ((*ptyip & 0377) == '\n')) {
*nfrontp++ = c;
if ((c == '\r') && (myopts[TELOPT_BINARY] == OPT_NO)) {
if (pcc > 0 && ((*ptyip & 0377) == '\n')) {
+#if defined(CRAY2) && defined(UNICOS5)
/*
* If chars were left over from the terminal driver,
* note their existence.
/*
* If chars were left over from the terminal driver,
* note their existence.
unpcc = 0;
ptyip = unptyip;
}
unpcc = 0;
ptyip = unptyip;
}
+#endif /* defined(CRAY2) && defined(UNICOS5) */
if (FD_ISSET(f, &obits) && (nfrontp - nbackp) > 0)
netflush();
if (FD_ISSET(f, &obits) && (nfrontp - nbackp) > 0)
netflush();
(void) ioctl(pty, TCSIG, (char *)SIGINT);
#else /* TCSIG */
init_termbuf();
(void) ioctl(pty, TCSIG, (char *)SIGINT);
#else /* TCSIG */
init_termbuf();
- *pfrontp++ = slctab[SLC_IP].sptr ? *slctab[SLC_IP].sptr : '\177';
+ *pfrontp++ = slctab[SLC_IP].sptr ?
+ (unsigned char)*slctab[SLC_IP].sptr : '\177';
(void) ioctl(pty, TCSIG, (char *)SIGQUIT);
#else /* TCSIG */
init_termbuf();
(void) ioctl(pty, TCSIG, (char *)SIGQUIT);
#else /* TCSIG */
init_termbuf();
- *pfrontp++ = slctab[SLC_ABORT].sptr ? *slctab[SLC_ABORT].sptr : '\034';
+ *pfrontp++ = slctab[SLC_ABORT].sptr ?
+ (unsigned char)*slctab[SLC_ABORT].sptr : '\034';
# ifdef TCSIG
(void) ioctl(pty, TCSIG, (char *)SIGTSTP);
# else /* TCSIG */
# ifdef TCSIG
(void) ioctl(pty, TCSIG, (char *)SIGTSTP);
# else /* TCSIG */
- *pfrontp++ = slctab[SLC_SUSP].sptr ? *slctab[SLC_SUSP].sptr : '\032';
+ *pfrontp++ = slctab[SLC_SUSP].sptr ?
+ (unsigned char)*slctab[SLC_SUSP].sptr : '\032';
# endif /* TCSIG */
#endif /* SIGTSTP */
}
doeof()
{
# endif /* TCSIG */
#endif /* SIGTSTP */
}
doeof()
{
+#if defined(USE_TERMIO) && defined(SYSV_TERMIO)
+ extern char oldeofc;
+#endif
- *pfrontp++ = slctab[SLC_EOF].sptr ? *slctab[SLC_EOF].sptr : '\004';
+#if defined(USE_TERMIO) && defined(SYSV_TERMIO)
+ if (!tty_isediting()) {
+ *pfrontp++ = oldeofc;
+ return;
+ }
+#endif
+ *pfrontp++ = slctab[SLC_EOF].sptr ?
+ (unsigned char)*slctab[SLC_EOF].sptr : '\004';
-static char sccsid[] = "@(#)termstat.c 5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)termstat.c 5.4 (Berkeley) %G%";
#endif /* not lint */
#include "telnetd.h"
#endif /* not lint */
#include "telnetd.h"
+#if defined(CRAY2) && defined(UNICOS5)
int newmap = 1; /* nonzero if \n maps to ^M^J */
#endif
int newmap = 1; /* nonzero if \n maps to ^M^J */
#endif
+#ifdef defined(CRAY2) && defined(UNICOS5)
/*
* Keep track of that ol' CR/NL mapping while we're in the
* neighborhood.
*/
newmap = tty_isnewmap();
/*
* Keep track of that ol' CR/NL mapping while we're in the
* neighborhood.
*/
newmap = tty_isnewmap();
+#endif defined(CRAY2) && defined(UNICOS5)
/*
* Check for state of BINARY options.
/*
* Check for state of BINARY options.
* pty. This becomes the test for linemode on/off when
* using kludge linemode.
*/
* pty. This becomes the test for linemode on/off when
* using kludge linemode.
*/
- if (lmodetype == KLUDGE_LINEMODE && uselinemode && tty_israw())
+ if (lmodetype == KLUDGE_LINEMODE && uselinemode && tty_israw()) {
+ tty_setlinemode(uselinemode);
+ }
# endif /* KLUDGELINEMODE */
/*
# endif /* KLUDGELINEMODE */
/*
*/
if (terminit() == 0) {
def_col = parm1;
*/
if (terminit() == 0) {
def_col = parm1;
return;
}
#endif /* LINEMODE */
return;
}
#endif /* LINEMODE */
break;
} /* end of switch */
break;
} /* end of switch */
+#if defined(CRAY2) && defined(UNICOS5)
/*
* Just in case of the likely event that we changed the pty state.
*/
rcv_ioctl();
/*
* Just in case of the likely event that we changed the pty state.
*/
rcv_ioctl();
+#endif /* defined(CRAY2) && defined(UNICOS5) */
netflush();
} /* end of clientstat */
netflush();
} /* end of clientstat */
+#if defined(CRAY2) && defined(UNICOS5)
termstat()
{
needtermstat = 1;
termstat()
{
needtermstat = 1;
localstat();
rcv_ioctl();
}
localstat();
rcv_ioctl();
}
+#endif /* defined(CRAY2) && defined(UNICOS5) */