diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-03-28 23:22:07 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-03-28 23:22:07 +0000 |
commit | dec5be20ee416901a8dc22b58b852c9d03c1cdd1 (patch) | |
tree | 9274bfde6f93cf450bb439ee0bf161ec17593867 | |
parent | f7c957824795353af8c467307cbe4b14a3a048c4 (diff) |
From NetBSD: merge of 960317
-rw-r--r-- | libexec/rpc.rstatd/rstat_proc.c | 15 | ||||
-rw-r--r-- | libexec/telnetd/Makefile | 8 | ||||
-rw-r--r-- | libexec/telnetd/authenc.c | 13 | ||||
-rw-r--r-- | libexec/telnetd/defs.h | 4 | ||||
-rw-r--r-- | libexec/telnetd/ext.h | 15 | ||||
-rw-r--r-- | libexec/telnetd/global.c | 15 | ||||
-rw-r--r-- | libexec/telnetd/pathnames.h | 4 | ||||
-rw-r--r-- | libexec/telnetd/slc.c | 11 | ||||
-rw-r--r-- | libexec/telnetd/state.c | 31 | ||||
-rw-r--r-- | libexec/telnetd/sys_term.c | 260 | ||||
-rw-r--r-- | libexec/telnetd/telnetd.8 | 4 | ||||
-rw-r--r-- | libexec/telnetd/telnetd.c | 66 | ||||
-rw-r--r-- | libexec/telnetd/telnetd.h | 8 | ||||
-rw-r--r-- | libexec/telnetd/termstat.c | 27 | ||||
-rw-r--r-- | libexec/telnetd/utility.c | 45 |
15 files changed, 386 insertions, 140 deletions
diff --git a/libexec/rpc.rstatd/rstat_proc.c b/libexec/rpc.rstatd/rstat_proc.c index 7eacce07a9e..e6925d68757 100644 --- a/libexec/rpc.rstatd/rstat_proc.c +++ b/libexec/rpc.rstatd/rstat_proc.c @@ -1,3 +1,5 @@ +/* $OpenBSD: rstat_proc.c,v 1.2 1996/03/28 23:21:51 niklas Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -29,7 +31,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)rpc.rstatd.c 1.1 86/09/25 Copyr 1984 Sun Micro";*/ /*static char sccsid[] = "from: @(#)rstat_proc.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char rcsid[] = "$Id: rstat_proc.c,v 1.1 1995/10/18 08:43:21 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: rstat_proc.c,v 1.2 1996/03/28 23:21:51 niklas Exp $"; #endif /* @@ -88,10 +90,6 @@ struct nlist nl[] = { { "_boottime" }, #define X_HZ 5 { "_hz" }, -#ifdef vax -#define X_AVENRUN 6 - { "_avenrun" }, -#endif "", }; struct ifnet_head ifnetq; /* chain of ethernet interfaces */ @@ -241,13 +239,6 @@ updatestat() exit(1); } #endif -#ifdef vax - if (kvm_read(kfd, (long)nl[X_AVENRUN].n_value, (char *)avrun, - sizeof (avrun)) != sizeof (avrun)) { - syslog(LOG_ERR, "can't read avenrun from kmem"); - exit(1); - } -#endif #ifdef BSD (void)getloadavg(avrun, sizeof(avrun) / sizeof(avrun[0])); #endif diff --git a/libexec/telnetd/Makefile b/libexec/telnetd/Makefile index 1413b6b7506..61a56aa8ff0 100644 --- a/libexec/telnetd/Makefile +++ b/libexec/telnetd/Makefile @@ -1,15 +1,17 @@ +# $OpenBSD: Makefile,v 1.2 1996/03/28 23:21:53 niklas Exp $ # from: @(#)Makefile 8.2 (Berkeley) 12/15/93 -# $Id: Makefile,v 1.1 1995/10/18 08:43:23 deraadt Exp $ +# $NetBSD: Makefile,v 1.6 1996/02/24 01:22:12 jtk Exp $ PROG= telnetd CFLAGS+=-DLINEMODE -DKLUDGELINEMODE -DUSE_TERMIO -DDIAGNOSTICS -CFLAGS+=-DOLD_ENVIRON -DENV_HACK +CFLAGS+=-DOLD_ENVIRON -DENV_HACK -I${.CURDIR} SRCS= authenc.c global.c slc.c state.c sys_term.c telnetd.c \ termstat.c utility.c DPADD= ${LIBUTIL} ${LIBTERM} -LDADD= -lutil -ltermcap -ltelnet +LDADD+= -lutil -ltermcap -ltelnet MAN= telnetd.8 + # 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/libexec/telnetd/authenc.c b/libexec/telnetd/authenc.c index 1223cb943c7..4cea82cc7fe 100644 --- a/libexec/telnetd/authenc.c +++ b/libexec/telnetd/authenc.c @@ -1,3 +1,6 @@ +/* $OpenBSD: authenc.c,v 1.2 1996/03/28 23:21:54 niklas Exp $ */ +/* $NetBSD: authenc.c,v 1.3 1996/02/28 20:38:08 thorpej Exp $ */ + /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -32,8 +35,12 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: authenc.c,v 1.1 1995/10/18 08:43:23 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)authenc.c 8.2 (Berkeley) 5/30/95"; +static char rcsid[] = "$NetBSD: authenc.c,v 1.3 1996/02/28 20:38:08 thorpej Exp $"; +#else +static char rcsid[] = "$OpenBSD: authenc.c,v 1.2 1996/03/28 23:21:54 niklas Exp $"; +#endif #endif /* not lint */ #if defined(AUTHENTICATION) @@ -46,7 +53,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/libexec/telnetd/defs.h b/libexec/telnetd/defs.h index d68e4fcf0ad..a6a47ff10fa 100644 --- a/libexec/telnetd/defs.h +++ b/libexec/telnetd/defs.h @@ -1,3 +1,6 @@ +/* $OpenBSD: defs.h,v 1.2 1996/03/28 23:21:55 niklas Exp $ */ +/* $NetBSD: defs.h,v 1.6 1996/02/28 20:38:10 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -31,7 +34,6 @@ * SUCH DAMAGE. * * from: @(#)defs.h 8.1 (Berkeley) 6/4/93 - * $Id: defs.h,v 1.1 1995/10/18 08:43:23 deraadt Exp $ */ /* diff --git a/libexec/telnetd/ext.h b/libexec/telnetd/ext.h index 869a29270a8..9ab99b556ef 100644 --- a/libexec/telnetd/ext.h +++ b/libexec/telnetd/ext.h @@ -1,3 +1,6 @@ +/* $OpenBSD: ext.h,v 1.2 1996/03/28 23:21:56 niklas Exp $ */ +/* $NetBSD: ext.h,v 1.6 1996/02/28 20:38:13 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)ext.h 8.1 (Berkeley) 6/4/93 - * $Id: ext.h,v 1.1 1995/10/18 08:43:23 deraadt Exp $ + * from: @(#)ext.h 8.2 (Berkeley) 12/15/93 */ /* @@ -90,13 +92,8 @@ extern int pty, net; extern char *line; extern int SYNCHing; /* we are in TELNET SYNCH mode */ -#ifndef P -# ifdef __STDC__ -# define P(x) x -# else -# define P(x) () -# endif -#endif +#include <sys/cdefs.h> +#define P __P extern void _termstat P((void)), diff --git a/libexec/telnetd/global.c b/libexec/telnetd/global.c index cc1171d248d..9250a129cc7 100644 --- a/libexec/telnetd/global.c +++ b/libexec/telnetd/global.c @@ -1,3 +1,6 @@ +/* $OpenBSD: global.c,v 1.2 1996/03/28 23:21:57 niklas Exp $ */ +/* $NetBSD: global.c,v 1.6 1996/02/28 20:38:14 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -32,8 +35,12 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)global.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: global.c,v 1.1 1995/10/18 08:43:24 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)global.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = "$NetBSD: global.c,v 1.6 1996/02/28 20:38:14 thorpej Exp $"; +#else +static char rcsid[] = "$OpenBSD: global.c,v 1.2 1996/03/28 23:21:57 niklas Exp $"; +#endif #endif /* not lint */ /* @@ -44,6 +51,6 @@ static char *rcsid = "$Id: global.c,v 1.1 1995/10/18 08:43:24 deraadt Exp $"; * we will actually allocate the space. */ -#include "defs.h" +#include <defs.h> #define extern -#include "ext.h" +#include <ext.h> diff --git a/libexec/telnetd/pathnames.h b/libexec/telnetd/pathnames.h index 7248a3e27ab..1b4cfe799cd 100644 --- a/libexec/telnetd/pathnames.h +++ b/libexec/telnetd/pathnames.h @@ -1,3 +1,6 @@ +/* $OpenBSD: pathnames.h,v 1.2 1996/03/28 23:21:57 niklas Exp $ */ +/* $NetBSD: pathnames.h,v 1.5 1996/02/28 20:38:15 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -31,7 +34,6 @@ * SUCH DAMAGE. * * from: @(#)pathnames.h 8.1 (Berkeley) 6/4/93 - * $Id: pathnames.h,v 1.1 1995/10/18 08:43:24 deraadt Exp $ */ #if BSD > 43 diff --git a/libexec/telnetd/slc.c b/libexec/telnetd/slc.c index 77aa67509f7..f2cf2a3ee99 100644 --- a/libexec/telnetd/slc.c +++ b/libexec/telnetd/slc.c @@ -1,3 +1,6 @@ +/* $OpenBSD: slc.c,v 1.2 1996/03/28 23:21:58 niklas Exp $ */ +/* $NetBSD: slc.c,v 1.5 1996/02/28 20:38:16 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -32,8 +35,12 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)slc.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: slc.c,v 1.1 1995/10/18 08:43:24 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)slc.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = "$NetBSD: slc.c,v 1.5 1996/02/28 20:38:16 thorpej Exp $"; +#else +static char rcsid[] = "$OpenBSD: slc.c,v 1.2 1996/03/28 23:21:58 niklas Exp $"; +#endif #endif /* not lint */ #include "telnetd.h" diff --git a/libexec/telnetd/state.c b/libexec/telnetd/state.c index 195d07bccd1..1d14d5efe56 100644 --- a/libexec/telnetd/state.c +++ b/libexec/telnetd/state.c @@ -1,3 +1,6 @@ +/* $OpenBSD: state.c,v 1.3 1996/03/28 23:21:59 niklas Exp $ */ +/* $NetBSD: state.c,v 1.9 1996/02/28 20:38:19 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -32,8 +35,12 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)state.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: state.c,v 1.2 1995/10/28 02:33:51 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95"; +static char rcsid[] = "$NetBSD: state.c,v 1.9 1996/02/28 20:38:19 thorpej Exp $"; +#else +static char rcsid[] = "$OpenBSD: state.c,v 1.3 1996/03/28 23:21:59 niklas Exp $"; +#endif #endif /* not lint */ #include "telnetd.h" @@ -355,7 +362,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); @@ -377,7 +384,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 { @@ -691,7 +698,6 @@ wontoption(option) */ if (lmodetype != REAL_LINEMODE) break; - lmodetype = KLUDGE_LINEMODE; # endif /* KLUDGELINEMODE */ clientstat(TELOPT_LINEMODE, WONT, 0); break; @@ -1463,8 +1469,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() { @@ -1493,14 +1499,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); } } @@ -1515,15 +1517,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); } } @@ -1536,8 +1537,6 @@ send_status() ADD(TELOPT_LINEMODE); ADD(LM_MODE); ADD_DATA(editmode); - if (editmode == IAC) - ADD(IAC); ADD(SE); ADD(SB); diff --git a/libexec/telnetd/sys_term.c b/libexec/telnetd/sys_term.c index 10cc5439119..f8a9a30650f 100644 --- a/libexec/telnetd/sys_term.c +++ b/libexec/telnetd/sys_term.c @@ -1,3 +1,6 @@ +/* $OpenBSD: sys_term.c,v 1.3 1996/03/28 23:22:00 niklas Exp $ */ +/* $NetBSD: sys_term.c,v 1.8 1996/02/28 20:38:21 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -32,13 +35,20 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)sys_term.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: sys_term.c,v 1.2 1996/02/22 10:39:31 niklas Exp $"; +#if 0 +static char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95"; +static char rcsid[] = "$NetBSD: sys_term.c,v 1.8 1996/02/28 20:38:21 thorpej Exp $"; +#else +static char rcsid[] = "$OpenBSD: sys_term.c,v 1.3 1996/03/28 23:22:00 niklas Exp $"; +#endif #endif /* not lint */ #include "telnetd.h" #include "pathnames.h" +#include <sys/cdefs.h> +#define P __P + #if defined(AUTHENTICATION) #include <libtelnet/auth.h> #endif @@ -70,21 +80,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 */ @@ -216,7 +221,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) */ @@ -228,17 +233,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 @@ -944,40 +951,87 @@ 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 { 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) @@ -1077,7 +1131,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"); @@ -1093,7 +1147,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); @@ -1173,9 +1227,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 /* @@ -1189,7 +1243,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); @@ -1198,18 +1252,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); @@ -1232,9 +1286,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); @@ -1243,18 +1296,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); @@ -1303,7 +1356,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 +1570,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; @@ -1527,6 +1584,8 @@ start_login(host, autologin, name) fatal(net, "makeutx failed"); #endif + scrub_env(); + /* * -h : pass on name of host. * WARNING: -h is accepted by login if and only if @@ -1568,6 +1627,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 +1648,7 @@ start_login(host, autologin, name) if (bftpd) { argv = addarg(argv, "-e"); argv = addarg(argv, BFTPPATH); - } else + } else #endif #if defined (SecurID) /* @@ -1691,11 +1763,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); @@ -1725,7 +1813,7 @@ addarg(argv, val) if (cpp == &argv[(long)argv[-1]]) { --argv; *argv = (char *)((long)(*argv) + 10); - argv = (char **)realloc(argv, (long)(*argv) + 2); + argv = (char **)realloc(argv, sizeof(*argv)*((long)(*argv) + 2)); if (argv == NULL) return(NULL); argv++; @@ -1738,6 +1826,26 @@ addarg(argv, val) #endif /* NEWINIT */ /* + * scrub_env() + * + * Remove a few things from the environment that + * don't need to be there. + */ +scrub_env() +{ + register char **cpp, **cpp2; + + for (cpp2 = cpp = environ; *cpp; cpp++) { + if (strncmp(*cpp, "LD_", 3) && + strncmp(*cpp, "_RLD_", 5) && + strncmp(*cpp, "LIBPATH=", 8) && + strncmp(*cpp, "IFS=", 4)) + *cpp2++ = *cpp; + } + *cpp2 = 0; +} + +/* * cleanup() * * This is the routine to call when we are all through, to @@ -1778,6 +1886,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 @@ -1788,9 +1898,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); @@ -1798,6 +1916,7 @@ cleanup(sig) } incleanup = 1; sigsetmask(t); +#ifdef UNICOS7x if (secflag) { /* * We need to set ourselves back to a null @@ -1807,6 +1926,7 @@ cleanup(sig) setulvl(sysv.sy_minlvl); setucmp((long)0); } +#endif /* UNICOS7x */ t = cleantmp(&wtmp); setutent(); /* just to make sure */ @@ -1907,6 +2027,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, @@ -1962,9 +2104,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)); @@ -1975,6 +2135,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); } @@ -2064,7 +2242,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) diff --git a/libexec/telnetd/telnetd.8 b/libexec/telnetd/telnetd.8 index d2b46203cc2..c4ff02957a8 100644 --- a/libexec/telnetd/telnetd.8 +++ b/libexec/telnetd/telnetd.8 @@ -1,3 +1,6 @@ +.\" $OpenBSD: telnetd.8,v 1.3 1996/03/28 23:22:02 niklas Exp $ +.\" $NetBSD: telnetd.8,v 1.7 1996/02/28 20:30:33 thorpej Exp $ +.\" .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -30,7 +33,6 @@ .\" SUCH DAMAGE. .\" .\" from: @(#)telnetd.8 8.3 (Berkeley) 3/1/94 -.\" $Id: telnetd.8,v 1.2 1996/01/11 17:49:42 deraadt Exp $ .\" .Dd March 1, 1994 .Dt TELNETD 8 diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c index 4ba7ae74357..43d6062e23f 100644 --- a/libexec/telnetd/telnetd.c +++ b/libexec/telnetd/telnetd.c @@ -1,3 +1,6 @@ +/* $OpenBSD: telnetd.c,v 1.2 1996/03/28 23:22:03 niklas Exp $ */ +/* $NetBSD: telnetd.c,v 1.5 1996/02/28 20:38:23 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -38,13 +41,20 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -/* from: static char sccsid[] = "@(#)telnetd.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: telnetd.c,v 1.1 1995/10/18 08:43:24 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95"; +static char rcsid[] = "$NetBSD: telnetd.c,v 1.5 1996/02/28 20:38:23 thorpej Exp $"; +#else +static char rcsid[] = "$OpenBSD: telnetd.c,v 1.2 1996/03/28 23:22:03 niklas Exp $"; +#endif #endif /* not lint */ #include "telnetd.h" #include "pathnames.h" +#include <sys/cdefs.h> +#define P __P + #if defined(_SC_CRAY_SECURE_SYS) && !defined(SCM_SECURITY) /* * UNICOS 6.0/6.1 do not have SCM_SECURITY defined, so we can @@ -435,7 +445,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"); @@ -606,34 +616,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)) @@ -706,8 +722,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(); } @@ -785,7 +803,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]; @@ -805,9 +823,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); @@ -896,6 +915,7 @@ telnet(f, p, host) char *HN; char *IM; void netflush(); + int nfd; /* * Initialize the slc mapping table. @@ -1125,6 +1145,7 @@ telnet(f, p, host) startslave(host); #endif + nfd = ((f > p) ? f : p) + 1; for (;;) { fd_set ibits, obits, xbits; register int c; @@ -1156,7 +1177,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) { @@ -1295,6 +1316,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) && @@ -1311,6 +1335,9 @@ telnet(f, p, host) : LFLOW_OFF, IAC, SE); nfrontp += 6; + DIAG(TD_OPTIONS, printsub('>', + (unsigned char *)nfrontp-4, + 4);); } } pcc--; @@ -1369,7 +1396,7 @@ telnet(f, p, host) } cleanup(0); } /* end of telnet */ - + #ifndef TCSIG # ifdef TIOCSIG # define TCSIG TIOCSIG @@ -1445,7 +1472,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; @@ -1476,6 +1503,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 */ @@ -1483,6 +1518,7 @@ interrupt() *pfrontp++ = slctab[SLC_IP].sptr ? (unsigned char)*slctab[SLC_IP].sptr : '\177'; #endif /* TCSIG */ +#endif } /* diff --git a/libexec/telnetd/telnetd.h b/libexec/telnetd/telnetd.h index 512caa41e6e..38c2f31d8cf 100644 --- a/libexec/telnetd/telnetd.h +++ b/libexec/telnetd/telnetd.h @@ -1,3 +1,6 @@ +/* $OpenBSD: telnetd.h,v 1.2 1996/03/28 23:22:04 niklas Exp $ */ +/* $NetBSD: telnetd.h,v 1.5 1996/02/28 20:38:25 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -31,12 +34,11 @@ * SUCH DAMAGE. * * from: @(#)telnetd.h 8.1 (Berkeley) 6/4/93 - * $Id: telnetd.h,v 1.1 1995/10/18 08:43:25 deraadt Exp $ */ -#include "defs.h" -#include "ext.h" +#include <defs.h> +#include <ext.h> #ifdef DIAGNOSTICS #define DIAG(a,b) if (diagnostic & (a)) b diff --git a/libexec/telnetd/termstat.c b/libexec/telnetd/termstat.c index 554ef1002ad..8c824f87bb3 100644 --- a/libexec/telnetd/termstat.c +++ b/libexec/telnetd/termstat.c @@ -1,3 +1,6 @@ +/* $OpenBSD: termstat.c,v 1.2 1996/03/28 23:22:05 niklas Exp $ */ +/* $NetBSD: termstat.c,v 1.5 1996/02/28 20:38:27 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -32,8 +35,12 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)termstat.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: termstat.c,v 1.1 1995/10/18 08:43:25 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95"; +static char rcsid[] = "$NetBSD: termstat.c,v 1.5 1996/02/28 20:38:27 thorpej Exp $"; +#else +static char rcsid[] = "$OpenBSD: termstat.c,v 1.2 1996/03/28 23:22:05 niklas Exp $"; +#endif #endif /* not lint */ #include "telnetd.h" @@ -302,7 +309,7 @@ localstat() nfrontp += 7; editmode = useeditmode; } - + /* * Check for changes to special characters in use. @@ -404,7 +411,7 @@ clientstat(code, parm1, parm2) uselinemode = 1; } } - + /* * Quit now if we can't do it. */ @@ -445,7 +452,7 @@ clientstat(code, parm1, parm2) send_will(TELOPT_ECHO, 1); } break; - + case LM_MODE: { register int ack, changed; @@ -494,7 +501,7 @@ clientstat(code, parm1, parm2) IAC, SE); nfrontp += 7; } - + editmode = useeditmode; } @@ -528,9 +535,9 @@ clientstat(code, parm1, parm2) (void) ioctl(pty, TIOCSWINSZ, (char *)&ws); } #endif /* TIOCSWINSZ */ - + break; - + case TELOPT_TSPEED: { def_tspeed = parm1; @@ -595,7 +602,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 @@ -614,7 +621,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/libexec/telnetd/utility.c b/libexec/telnetd/utility.c index 5a2f213ae2c..f70a6d08691 100644 --- a/libexec/telnetd/utility.c +++ b/libexec/telnetd/utility.c @@ -1,3 +1,6 @@ +/* $OpenBSD: utility.c,v 1.2 1996/03/28 23:22:06 niklas Exp $ */ +/* $NetBSD: utility.c,v 1.9 1996/02/28 20:38:29 thorpej Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -32,8 +35,12 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)utility.c 8.2 (Berkeley) 12/15/93"; */ -static char *rcsid = "$Id: utility.c,v 1.1 1995/10/18 08:43:25 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95"; +static char rcsid[] = "$NetBSD: utility.c,v 1.9 1996/02/28 20:38:29 thorpej Exp $"; +#else +static char rcsid[] = "$OpenBSD: utility.c,v 1.2 1996/03/28 23:22:06 niklas Exp $"; +#endif #endif /* not lint */ #include <sys/utsname.h> @@ -214,7 +221,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 { @@ -305,7 +312,7 @@ writenet(ptr, len) netflush(); } - bcopy(ptr, nfrontp, len); + memmove(nfrontp, ptr, len); nfrontp += len; } /* end of writenet */ @@ -336,7 +343,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); } @@ -406,7 +413,7 @@ putchr(cc) * between two % signs and expand it... */ static char fmtstr[] = { "%l:%M\ -%P on %A, %d %B %Y" }; +%p on %A, %d %B %Y" }; void putf(cp, where) @@ -418,9 +425,9 @@ putf(cp, where) char db[100]; struct utsname utsinfo; #ifdef STREAMSPTY - extern char *index(); + extern char *strchr(); #else - extern char *rindex(); + extern char *strrchr(); #endif uname(&utsinfo); @@ -437,9 +444,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); @@ -509,7 +516,7 @@ printsub(direction, pointer, length) register int i; char buf[512]; - if (!(diagnostic & TD_OPTIONS)) + if (!(diagnostic & TD_OPTIONS)) return; if (direction) { @@ -700,7 +707,7 @@ printsub(direction, pointer, length) break; } break; - + case LM_SLC: sprintf(nfrontp, "SLC"); nfrontp += strlen(nfrontp); @@ -850,7 +857,7 @@ printsub(direction, pointer, length) nfrontp += strlen(nfrontp); break; - + default: sprintf(nfrontp, " %d", pointer[i]); nfrontp += strlen(nfrontp); @@ -953,7 +960,7 @@ printsub(direction, pointer, length) case TELOPT_AUTHENTICATION: sprintf(nfrontp, "AUTHENTICATION"); nfrontp += strlen(nfrontp); - + if (length < 2) { sprintf(nfrontp, " (empty suboption??\?)"); nfrontp += strlen(nfrontp); @@ -1034,9 +1041,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]); @@ -1071,13 +1078,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++; } @@ -1087,6 +1094,6 @@ printdata(tag, ptr, cnt) xbuf[i] = '\0'; sprintf(nfrontp, " %s\r\n", xbuf ); nfrontp += strlen(nfrontp); - } + } } #endif /* DIAGNOSTICS */ |