remove unneeded #ifdefs. improves readability.

(confirmed that exact same *.o is produced)
This commit is contained in:
itojun 2003-07-14 15:55:53 +00:00
parent a55c504a2f
commit 625dced967
12 changed files with 232 additions and 2161 deletions

View File

@ -1,14 +1,12 @@
# $NetBSD: Makefile,v 1.33 2002/08/20 13:12:00 christos Exp $
# $NetBSD: Makefile,v 1.34 2003/07/14 15:55:53 itojun Exp $
# from: @(#)Makefile 8.2 (Berkeley) 12/15/93
.include <bsd.own.mk>
MAN= telnetd.8
CPPFLAGS+=-DINET6
PROG= telnetd
CPPFLAGS+=-DLINEMODE -DKLUDGELINEMODE -DUSE_TERMIO -DDIAGNOSTICS -DOPENPTY_PTY
CPPFLAGS+=-DLINEMODE -DKLUDGELINEMODE -DDIAGNOSTICS
CPPFLAGS+=-DOLD_ENVIRON -DENV_HACK -DSECURELOGIN -DSUPPORT_UTMP -DSUPPORT_UTMPX
SRCS= authenc.c global.c slc.c state.c sys_term.c telnetd.c \
termstat.c utility.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: authenc.c,v 1.9 2001/08/20 11:01:48 wiz Exp $ */
/* $NetBSD: authenc.c,v 1.10 2003/07/14 15:55:53 itojun Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)authenc.c 8.2 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: authenc.c,v 1.9 2001/08/20 11:01:48 wiz Exp $");
__RCSID("$NetBSD: authenc.c,v 1.10 2003/07/14 15:55:53 itojun Exp $");
#endif
#endif /* not lint */
@ -46,7 +46,7 @@ __RCSID("$NetBSD: authenc.c,v 1.9 2001/08/20 11:01:48 wiz Exp $");
#include "telnetd.h"
#include <libtelnet/misc.h>
int
int
telnet_net_write(str, len)
unsigned char *str;
int len;
@ -58,7 +58,7 @@ telnet_net_write(str, len)
return(0);
}
void
void
net_encrypt()
{
#ifdef ENCRYPTION
@ -70,21 +70,21 @@ net_encrypt()
#endif /* ENCRYPTION */
}
int
int
telnet_spin()
{
ttloop();
return(0);
}
char *
char *
telnet_getenv(val)
char *val;
{
return(getenv(val));
}
char *
char *
telnet_gets(prompt, result, length, echo)
char *prompt;
char *result;

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.12 2002/09/18 20:58:56 mycroft Exp $ */
/* $NetBSD: defs.h,v 1.13 2003/07/14 15:55:53 itojun Exp $ */
/*
* Copyright (c) 1989, 1993
@ -41,43 +41,20 @@
#include <sys/types.h>
#include <sys/param.h>
#ifndef BSD
# define BSD 43
#endif
#if defined(CRAY) && !defined(LINEMODE)
# define SYSV_TERMIO
# define LINEMODE
# define KLUDGELINEMODE
# define DIAGNOSTICS
# define BFTPDAEMON
# define HAS_IP_TOS
#endif /* CRAY */
#if defined(PRINTOPTIONS) && defined(DIAGNOSTICS)
#define TELOPTS
#define TELCMDS
#define SLC_NAMES
#endif
#if defined(SYSV_TERMIO) && !defined(USE_TERMIO)
# define USE_TERMIO
#endif
#include <sys/socket.h>
#ifndef CRAY
#include <sys/wait.h>
#endif /* CRAY */
#include <fcntl.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/poll.h>
#ifndef FILIO_H
#include <sys/ioctl.h>
#else
#include <sys/filio.h>
#endif
#include <netinet/in.h>
@ -89,80 +66,21 @@
#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>
#ifndef NO_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#ifndef USE_TERMIO
#include <sgtty.h>
#else
# ifdef SYSV_TERMIO
# include <termio.h>
# else
# include <termios.h>
# endif
#endif
#if !defined(USE_TERMIO) || defined(NO_CC_T)
typedef unsigned char cc_t;
#endif
#include <termios.h>
#include <time.h>
#include <unistd.h>
#ifndef _POSIX_VDISABLE
# ifdef VDISABLE
# define _POSIX_VDISABLE VDISABLE
# else
# define _POSIX_VDISABLE ((unsigned char)'\377')
# endif
#endif
#ifdef CRAY
#include <memory.h>
#endif /* CRAY */
#ifdef __hpux
#include <sys/ptyio.h>
#endif
#if !defined(TIOCSCTTY) && defined(TCSETCTTY)
# define TIOCSCTTY TCSETCTTY
#endif
#ifndef FD_SET
#ifndef HAVE_fd_set
typedef struct fd_set { int fds_bits[1]; } fd_set;
#endif
#define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n)))
#define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n)))
#define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n)))
#define FD_ZERO(p) ((p)->fds_bits[0] = 0)
#endif /* FD_SET */
/*
* I/O data buffers defines
*/
#define NETSLOP 64
#ifdef CRAY
#undef BUFSIZ
#define BUFSIZ 2048
#endif
#define NIACCUM(c) { *netip++ = c; \
#define NIACCUM(c) do { \
*netip++ = c; \
ncc++; \
}
} while (0)
/* clock manipulations */
#define settimer(x) (clocks.x = ++clocks.system)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext.h,v 1.16 2001/08/24 00:14:03 wiz Exp $ */
/* $NetBSD: ext.h,v 1.17 2003/07/14 15:55:53 itojun Exp $ */
/*
* Copyright (c) 1989, 1993
@ -56,135 +56,120 @@ extern int restartany; /* restart output on any character state */
#ifdef DIAGNOSTICS
extern int diagnostic; /* telnet diagnostic capabilities */
#endif /* DIAGNOSTICS */
#ifdef BFTPDAEMON
extern int bftpd; /* behave as bftp daemon */
#endif /* BFTPDAEMON */
#if defined(SECURELOGIN)
#ifdef SECURELOGIN
extern int require_secure_login;
#endif
#if defined(AUTHENTICATION)
#ifdef AUTHENTICATION
extern int auth_level;
#endif
#if defined(FORWARD)
extern int got_forwarded_creds;
#endif
extern slcfun slctab[NSLC + 1]; /* slc mapping table */
extern char *terminaltype;
/*
* I/O data buffers, pointers, and counters.
*/
extern char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp;
extern char netibuf[BUFSIZ], *netip;
extern char netobuf[BUFSIZ+NETSLOP], *nfrontp, *nbackp;
extern char *neturg; /* one past last bye of urgent data */
extern int pcc, ncc;
extern int pty, net;
extern char *line;
extern int SYNCHing; /* we are in TELNET SYNCH mode */
#include <sys/cdefs.h>
#define P __P
extern void
_termstat P((void)),
add_slc P((int, int, int)),
check_slc P((void)),
change_slc P((int, int, int)),
cleanup P((int)),
clientstat P((int, int, int)),
copy_termbuf P((char *, int)),
deferslc P((void)),
defer_terminit P((void)),
do_opt_slc P((unsigned char *, int)),
doeof P((void)),
dooption P((int)),
dontoption P((int)),
edithost P((char *, char *)),
fatal P((int, const char *)),
fatalperror P((int, const char *)),
get_slc_defaults P((void)),
init_env P((void)),
init_termbuf P((void)),
interrupt P((void)),
localstat P((void)),
flowstat P((void)),
netclear P((void)),
netflush P((void)),
_termstat __P((void)),
add_slc __P((int, int, int)),
check_slc __P((void)),
change_slc __P((int, int, int)),
cleanup __P((int)),
clientstat __P((int, int, int)),
copy_termbuf __P((char *, int)),
deferslc __P((void)),
defer_terminit __P((void)),
do_opt_slc __P((unsigned char *, int)),
doeof __P((void)),
dooption __P((int)),
dontoption __P((int)),
edithost __P((char *, char *)),
fatal __P((int, const char *)),
fatalperror __P((int, const char *)),
get_slc_defaults __P((void)),
init_env __P((void)),
init_termbuf __P((void)),
interrupt __P((void)),
localstat __P((void)),
flowstat __P((void)),
netclear __P((void)),
netflush __P((void)),
#ifdef DIAGNOSTICS
printoption P((const char *, int)),
printdata P((char *, char *, int)),
#if !defined(ENCRYPTION)
printsub P((int, unsigned char *, int)),
printoption __P((const char *, int)),
printdata __P((char *, char *, int)),
#ifndef ENCRYPTION
printsub __P((int, unsigned char *, int)),
#endif
#endif
ptyflush P((void)),
putchr P((int)),
recv_ayt P((void)),
send_do P((int, int)),
send_dont P((int, int)),
send_slc P((void)),
send_status P((void)),
send_will P((int, int)),
send_wont P((int, int)),
sendbrk P((void)),
sendsusp P((void)),
set_termbuf P((void)),
start_login P((char *, int, char *)),
start_slc P((int)),
startslave P((char *, int, char *)),
suboption P((void)),
telrcv P((void)),
ttloop P((void)),
tty_binaryin P((int)),
tty_binaryout P((int));
ptyflush __P((void)),
putchr __P((int)),
recv_ayt __P((void)),
send_do __P((int, int)),
send_dont __P((int, int)),
send_slc __P((void)),
send_status __P((void)),
send_will __P((int, int)),
send_wont __P((int, int)),
sendbrk __P((void)),
sendsusp __P((void)),
set_termbuf __P((void)),
start_login __P((char *, int, char *)),
start_slc __P((int)),
startslave __P((char *, int, char *)),
suboption __P((void)),
telrcv __P((void)),
ttloop __P((void)),
tty_binaryin __P((int)),
tty_binaryout __P((int));
extern char *
putf P((char *, char *));
putf __P((char *, char *));
extern int
end_slc P((unsigned char **)),
getnpty P((void)),
#ifndef convex
getpty P((int *)),
#endif
spcset P((int, cc_t *, cc_t **)),
stilloob P((int)),
terminit P((void)),
termstat P((void)),
tty_flowmode P((void)),
tty_restartany P((void)),
tty_isbinaryin P((void)),
tty_isbinaryout P((void)),
tty_iscrnl P((void)),
tty_isecho P((void)),
tty_isediting P((void)),
tty_islitecho P((void)),
tty_isnewmap P((void)),
tty_israw P((void)),
tty_issofttab P((void)),
tty_istrapsig P((void)),
tty_linemode P((void));
end_slc __P((unsigned char **)),
getnpty __P((void)),
getpty __P((int *)),
spcset __P((int, cc_t *, cc_t **)),
stilloob __P((int)),
terminit __P((void)),
termstat __P((void)),
tty_flowmode __P((void)),
tty_restartany __P((void)),
tty_isbinaryin __P((void)),
tty_isbinaryout __P((void)),
tty_iscrnl __P((void)),
tty_isecho __P((void)),
tty_isediting __P((void)),
tty_islitecho __P((void)),
tty_isnewmap __P((void)),
tty_israw __P((void)),
tty_issofttab __P((void)),
tty_istrapsig __P((void)),
tty_linemode __P((void));
extern void
tty_rspeed P((int)),
tty_setecho P((int)),
tty_setedit P((int)),
tty_setlinemode P((int)),
tty_setlitecho P((int)),
tty_setsig P((int)),
tty_setsofttab P((int)),
tty_tspeed P((int)),
willoption P((int)),
wontoption P((int)),
writenet P((unsigned char *, int));
tty_rspeed __P((int)),
tty_setecho __P((int)),
tty_setedit __P((int)),
tty_setlinemode __P((int)),
tty_setlitecho __P((int)),
tty_setsig __P((int)),
tty_setsofttab __P((int)),
tty_tspeed __P((int)),
willoption __P((int)),
wontoption __P((int)),
writenet __P((unsigned char *, int));
extern int output_data __P((const char *, ...))
__attribute__((__format__(__printf__, 1, 2)));
@ -194,12 +179,10 @@ extern int output_datalen __P((const char *, size_t));
extern char *nclearto;
#endif /* ENCRYPTION */
/*
* The following are some clocks used to decide how to interpret
* the relationship between various variables.
*/
extern struct {
int
system, /* what the current time is */
@ -215,28 +198,14 @@ extern struct {
gotDM; /* when did we last see a data mark */
} clocks;
#ifndef DEFAULT_IM
# ifdef CRAY
# define DEFAULT_IM "\r\n\r\nCray UNICOS (%h) (%t)\r\n\r\r\n\r"
# else
# ifdef sun
# define DEFAULT_IM "\r\n\r\nSunOS UNIX (%h) (%t)\r\n\r\r\n\r"
# else
# ifdef ultrix
# define DEFAULT_IM "\r\n\r\nULTRIX (%h) (%t)\r\n\r\r\n\r"
# else
# define DEFAULT_IM "\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r"
# endif
# endif
# endif
# define DEFAULT_IM "\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r"
#endif
#if defined(AUTHENTICATION)
#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
#if defined(ENCRYPTION)
#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: pathnames.h,v 1.5 1996/02/28 20:38:15 thorpej Exp $ */
/* $NetBSD: pathnames.h,v 1.6 2003/07/14 15:55:54 itojun Exp $ */
/*
* Copyright (c) 1989, 1993
@ -35,23 +35,8 @@
* from: @(#)pathnames.h 8.1 (Berkeley) 6/4/93
*/
#if BSD > 43
# include <paths.h>
# ifndef _PATH_LOGIN
# define _PATH_LOGIN "/usr/bin/login"
# endif
#else
# define _PATH_TTY "/dev/tty"
# ifndef _PATH_LOGIN
# define _PATH_LOGIN "/bin/login"
# endif
#include <paths.h>
#ifndef _PATH_LOGIN
# define _PATH_LOGIN "/usr/bin/login"
#endif
#ifdef BFTPDAEMON
#define BFTPPATH "/usr/ucb/bftp"
#endif /* BFTPDAEMON */

View File

@ -1,4 +1,4 @@
/* $NetBSD: slc.c,v 1.10 2001/09/16 16:34:26 wiz Exp $ */
/* $NetBSD: slc.c,v 1.11 2003/07/14 15:55:54 itojun Exp $ */
/*
* Copyright (c) 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)slc.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: slc.c,v 1.10 2001/09/16 16:34:26 wiz Exp $");
__RCSID("$NetBSD: slc.c,v 1.11 2003/07/14 15:55:54 itojun Exp $");
#endif
#endif /* not lint */
@ -62,7 +62,7 @@ void process_slc __P((u_int, u_int, cc_t));
*
* Write out the current special characters to the client.
*/
void
void
send_slc()
{
register int i;
@ -86,7 +86,7 @@ send_slc()
*
* Set pty special characters to all the defaults.
*/
void
void
default_slc()
{
register int i;
@ -111,7 +111,7 @@ default_slc()
*
* Initialize the slc mapping table.
*/
void
void
get_slc_defaults()
{
register int i;
@ -133,7 +133,7 @@ get_slc_defaults()
*
* Add an slc triplet to the slc buffer.
*/
void
void
add_slc(func, flag, val)
register char func, flag;
register cc_t val;
@ -158,7 +158,7 @@ add_slc(func, flag, val)
* The parameter getit is non-zero if it is necessary to grab a copy
* of the terminal control structures.
*/
void
void
start_slc(getit)
register int getit;
{
@ -177,7 +177,7 @@ start_slc(getit)
*
* Finish up the slc negotiation. If something to send, then send it.
*/
int
int
end_slc(bufp)
register unsigned char **bufp;
{
@ -223,7 +223,7 @@ end_slc(bufp)
*
* Figure out what to do about the client's slc
*/
void
void
process_slc(func, flag, val)
u_int func, flag;
cc_t val;
@ -289,7 +289,7 @@ process_slc(func, flag, val)
* Process a request to change one of our special characters.
* Compare client's request with what we are capable of supporting.
*/
void
void
change_slc(func, flag, val)
int func, flag;
cc_t val;
@ -387,7 +387,7 @@ change_slc(func, flag, val)
} /* end of change_slc */
#if defined(USE_TERMIO) && (VEOF == VMIN)
#if VEOF == VMIN
cc_t oldeofc = '\004';
#endif
@ -399,13 +399,13 @@ cc_t oldeofc = '\004';
* likely to have changed. If a local change occurs, kick the support level
* and flags up to the defaults.
*/
void
void
check_slc()
{
register int i;
for (i = 1; i <= NSLC; i++) {
#if defined(USE_TERMIO) && (VEOF == VMIN)
#if VEOF == VMIN
/*
* In a perfect world this would be a neat little
* function. But in this world, we should not notify
@ -419,7 +419,7 @@ check_slc()
else if (slctab[i].sptr)
oldeofc = *(slctab[i].sptr);
}
#endif /* defined(USE_TERMIO) && defined(SYSV_TERMIO) */
#endif /* VEOF == VMIN */
if (slctab[i].sptr &&
(*(slctab[i].sptr) != slctab[i].current.val)) {
slctab[i].current.val = *(slctab[i].sptr);
@ -442,7 +442,7 @@ check_slc()
*
* ptr points to the beginning of the buffer, len is the length.
*/
void
void
do_opt_slc(ptr, len)
register unsigned char *ptr;
register int len;
@ -483,7 +483,7 @@ do_opt_slc(ptr, len)
*
* Do slc stuff that was deferred.
*/
void
void
deferslc()
{
if (def_slcbuf) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: state.c,v 1.22 2002/02/11 10:57:58 wiz Exp $ */
/* $NetBSD: state.c,v 1.23 2003/07/14 15:55:54 itojun Exp $ */
/*
* Copyright (c) 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: state.c,v 1.22 2002/02/11 10:57:58 wiz Exp $");
__RCSID("$NetBSD: state.c,v 1.23 2003/07/14 15:55:54 itojun Exp $");
#endif
#endif /* not lint */
@ -89,7 +89,7 @@ unsigned char *subsave;
#define TS_DO 7 /* do " */
#define TS_DONT 8 /* dont " */
void
void
telrcv()
{
register int c;
@ -422,7 +422,7 @@ gotiac: switch (c) {
* is complete.
*
*/
void
void
send_do(option, init)
int option, init;
{
@ -458,7 +458,7 @@ extern void encrypt_send_support __P((void));
#endif /* ENCRYPTION */
#endif
void
void
willoption(option)
int option;
{
@ -652,7 +652,7 @@ willoption(option)
(*func)();
} /* end of willoption */
void
void
send_dont(option, init)
int option, init;
{
@ -668,7 +668,7 @@ send_dont(option, init)
DIAG(TD_OPTIONS, printoption("td: send dont", option));
}
void
void
wontoption(option)
int option;
{
@ -735,7 +735,7 @@ wontoption(option)
slctab[SLC_XOFF].defset.flag |= SLC_CANTCHANGE;
break;
#if defined(AUTHENTICATION)
#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
auth_finished(0, AUTH_REJECT);
break;
@ -788,7 +788,7 @@ wontoption(option)
#endif /* defined(LINEMODE) && defined(KLUDGELINEMODE) */
break;
#if defined(AUTHENTICATION)
#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
auth_finished(0, AUTH_REJECT);
break;
@ -802,7 +802,7 @@ wontoption(option)
} /* end of wontoption */
void
void
send_will(option, init)
int option, init;
{
@ -829,7 +829,7 @@ send_will(option, init)
int turn_on_sga = 0;
#endif
void
void
dooption(option)
int option;
{
@ -942,9 +942,6 @@ dooption(option)
case TELOPT_TSPEED:
case TELOPT_LFLOW:
case TELOPT_XDISPLOC:
#ifdef TELOPT_ENVIRON
case TELOPT_NEW_ENVIRON:
#endif
case TELOPT_OLD_ENVIRON:
default:
break;
@ -961,7 +958,7 @@ dooption(option)
} /* end of dooption */
void
void
send_wont(option, init)
int option, init;
{
@ -977,7 +974,7 @@ send_wont(option, init)
DIAG(TD_OPTIONS, printoption("td: send wont", option));
}
void
void
dontoption(option)
int option;
{
@ -1122,7 +1119,7 @@ envvarok(varp)
* Window size
* Terminal speed
*/
void
void
suboption()
{
register int subchar;
@ -1285,9 +1282,7 @@ suboption()
break;
} /* end of case TELOPT_XDISPLOC */
#ifdef TELOPT_NEW_ENVIRON
case TELOPT_NEW_ENVIRON:
#endif
case TELOPT_OLD_ENVIRON: {
register int c;
register char *cp, *varp, *valp;
@ -1304,7 +1299,6 @@ suboption()
return;
}
#ifdef TELOPT_NEW_ENVIRON
if (subchar == TELOPT_NEW_ENVIRON) {
while (!SB_EOF()) {
c = SB_GET();
@ -1312,7 +1306,6 @@ suboption()
break;
}
} else
#endif
{
#ifdef ENV_HACK
/*
@ -1475,7 +1468,7 @@ suboption()
}
break;
} /* end of case TELOPT_NEW_ENVIRON */
#if defined(AUTHENTICATION)
#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
if (SB_EOF())
break;
@ -1547,14 +1540,14 @@ suboption()
} /* end of suboption */
#ifdef LINEMODE
void
void
doclientstat()
{
clientstat(TELOPT_LINEMODE, WILL, 0);
}
#endif /* LINEMODE */
void
void
send_status()
{
#define ADD(c) \

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
.\" $NetBSD: telnetd.8,v 1.25 2003/02/25 10:34:51 wiz Exp $
.\" $NetBSD: telnetd.8,v 1.26 2003/07/14 15:55:55 itojun Exp $
.\"
.\" Copyright (c) 1983, 1993
.\" The Regents of the University of California. All rights reserved.
@ -50,7 +50,6 @@ protocol server
.Op Fl a Ar authmode
.Op Fl edebug
.Op Fl g Ar gettyent
.Op Fl r Ns Ar lowpty-highpty
.Op Fl u Ar len
.Op Fl debug Op Ar port
.Sh DESCRIPTION
@ -235,31 +234,6 @@ have been idle for some period of time to determine
if the client is still there, so that idle connections
from machines that have crashed or can no longer
be reached may be cleaned up.
.It Fl r Ar lowpty-highpty
This option is only enabled when
.Nm
is compiled for
.Dv UNICOS .
It specifies an inclusive range of pseudo-terminal devices to use.
If the system has sysconf variable
.Dv _SC_CRAY_NPTY
configured, the default pty search range is 0 to
.Dv _SC_CRAY_NPTY ;
otherwise, the default range is 0 to 128.
Either
.Ar lowpty
or
.Ar highpty
may be omitted to allow changing
either end of the search range.
If
.Ar lowpty
is omitted, the - character is still required so that
.Nm
can differentiate
.Ar highpty
from
.Ar lowpty .
.It Fl s
This option is only enabled if
.Nm

View File

@ -1,4 +1,4 @@
/* $NetBSD: telnetd.c,v 1.38 2003/07/13 09:40:21 itojun Exp $ */
/* $NetBSD: telnetd.c,v 1.39 2003/07/14 15:55:55 itojun Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@ -69,7 +69,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: telnetd.c,v 1.38 2003/07/13 09:40:21 itojun Exp $");
__RCSID("$NetBSD: telnetd.c,v 1.39 2003/07/14 15:55:55 itojun Exp $");
#endif
#endif /* not lint */
@ -83,43 +83,14 @@ __RCSID("$NetBSD: telnetd.c,v 1.38 2003/07/13 09:40:21 itojun Exp $");
#include <limits.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
* 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
#endif
#if defined(_SC_CRAY_SECURE_SYS)
#include <sys/sysv.h>
#include <sys/secdev.h>
# ifdef SO_SEC_MULTI /* 8.0 code */
#include <sys/secparm.h>
#include <sys/usrv.h>
# endif /* SO_SEC_MULTI */
int secflag;
char tty_dev[16];
struct secdev dv;
struct sysv sysv;
# ifdef SO_SEC_MULTI /* 8.0 code */
struct socksec ss;
# else /* SO_SEC_MULTI */ /* 7.0 code */
struct socket_security ss;
# endif /* SO_SEC_MULTI */
#endif /* _SC_CRAY_SECURE_SYS */
#if defined(KRB5)
#ifdef KRB5
#define Authenticator k5_Authenticator
#include <krb5.h>
#undef Authenticator
#include <com_err.h>
#endif
#if defined(AUTHENTICATION)
#ifdef AUTHENTICATION
int auth_level = 0;
#endif
@ -127,41 +98,16 @@ int auth_level = 0;
#include <libtelnet/misc.h>
#endif
#if defined(SECURELOGIN)
#ifdef SECURELOGIN
int require_secure_login = 0;
#endif
#if !defined(UTMPX) && !(defined(CRAY) || defined(__hpux)) && BSD <= 43
extern int utmp_len;
#endif
extern int require_hwpreauth;
#ifdef KRB5
extern krb5_context telnet_context;
#endif
int registerd_host_only = 0;
#ifdef STREAMSPTY
# include <stropts.h>
# include <termio.h>
/* make sure we don't get the bsd version */
# include "/usr/include/sys/tty.h"
# include <sys/ptyvar.h>
/*
* Because of the way ptyibuf is used with streams messages, we need
* ptyibuf+1 to be on a full-word boundary. The following weirdness
* is simply to make that happen.
*/
long ptyibufbuf[BUFSIZ/sizeof(long)+1];
char *ptyibuf = ((char *)&ptyibufbuf[1])-1;
char *ptyip = ((char *)&ptyibufbuf[1])-1;
char ptyibuf2[BUFSIZ*4];
unsigned char ctlbuf[BUFSIZ];
struct strbuf strbufc, strbufd;
int readstream();
#else /* ! STREAMPTY */
/*
* I/O data buffers,
@ -170,14 +116,9 @@ int readstream();
char ptyibuf[BUFSIZ], *ptyip = ptyibuf;
char ptyibuf2[BUFSIZ];
#endif /* ! STREAMPTY */
int hostinfo = 1; /* do we print login banner? */
#ifdef CRAY
extern int newmap; /* nonzero if \n maps to ^M^J */
int lowpty = 0, highpty; /* low, high pty numbers */
#endif /* CRAY */
int debug = 0;
int keepalive = 1;
@ -204,9 +145,6 @@ char valid_opts[] = {
#ifdef AUTHENTICATION
'a', ':', 'X', ':',
#endif
#ifdef BFTPDAEMON
'B',
#endif
#ifdef ENCRYPTION
'e', ':',
#endif
@ -216,9 +154,6 @@ char valid_opts[] = {
#ifdef LINEMODE
'l',
#endif
#ifdef CRAY
'r', ':',
#endif
#ifdef SECURELOGIN
's',
#endif
@ -251,13 +186,6 @@ main(argc, argv)
progname = *argv;
#ifdef CRAY
/*
* Get number of pty's before trying to process options,
* which may include changing pty range.
*/
highpty = getnpty();
#endif /* CRAY */
while ((ch = getopt(argc, argv, valid_opts)) != -1) {
switch (ch) {
@ -289,11 +217,6 @@ main(argc, argv)
break;
#endif /* AUTHENTICATION */
#ifdef BFTPDAEMON
case 'B':
bftpd++;
break;
#endif /* BFTPDAEMON */
case 'd':
if (strcmp(optarg, "ebug") == 0) {
@ -372,33 +295,6 @@ main(argc, argv)
keepalive = 0;
break;
#ifdef CRAY
case 'r':
{
char *strchr();
char *c;
/*
* 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.
*/
c = strchr(optarg, '-');
if (c) {
*c++ = '\0';
highpty = atoi(c);
}
if (*optarg != '\0')
lowpty = atoi(optarg);
if ((lowpty > highpty) || (lowpty < 0) ||
(highpty > 32767)) {
usage();
/* NOT REACHED */
}
break;
}
#endif /* CRAY */
#ifdef KRB5
case 'R':
@ -425,23 +321,12 @@ main(argc, argv)
break;
#endif /* SECURELOGIN */
case 'S':
#ifdef HAS_GETTOS
if ((tos = parsetos(optarg, "tcp")) < 0)
fprintf(stderr, "%s%s%s\n",
"telnetd: Bad TOS argument '", optarg,
"'; will try to use default TOS");
#else
fprintf(stderr, "%s%s\n", "TOS option unavailable; ",
"-S flag not supported\n");
#endif
break;
case 'u':
#if !defined(UTMPX) && !(defined(CRAY) || defined(__hpux)) && BSD <= 43
utmp_len = atoi(optarg);
#else
fprintf(stderr, "telnetd: -u option unneeded\n");
#endif
break;
case 'U':
@ -524,72 +409,11 @@ main(argc, argv)
(void) dup2(ns, 0);
(void) close(ns);
(void) close(s);
#ifdef convex
} else if (argc == 1) {
; /* VOID*/ /* Just ignore the host/port name */
#endif
} else if (argc > 0) {
usage();
/* NOT REACHED */
}
#if defined(_SC_CRAY_SECURE_SYS)
secflag = sysconf(_SC_CRAY_SECURE_SYS);
/*
* Get socket's security label
*/
if (secflag) {
int szss = sizeof(ss);
#ifdef SO_SEC_MULTI /* 8.0 code */
int sock_multi;
int szi = sizeof(int);
#endif /* SO_SEC_MULTI */
memset((char *)&dv, 0, sizeof(dv));
if (getsysv(&sysv, sizeof(struct sysv)) != 0) {
perror("getsysv");
exit(1);
}
/*
* Get socket security label and set device values
* {security label to be set on ttyp device}
*/
#ifdef SO_SEC_MULTI /* 8.0 code */
if ((getsockopt(0, SOL_SOCKET, SO_SECURITY,
(char *)&ss, &szss) < 0) ||
(getsockopt(0, SOL_SOCKET, SO_SEC_MULTI,
(char *)&sock_multi, &szi) < 0)) {
perror("getsockopt");
exit(1);
} else {
dv.dv_actlvl = ss.ss_actlabel.lt_level;
dv.dv_actcmp = ss.ss_actlabel.lt_compart;
if (!sock_multi) {
dv.dv_minlvl = dv.dv_maxlvl = dv.dv_actlvl;
dv.dv_valcmp = dv.dv_actcmp;
} else {
dv.dv_minlvl = ss.ss_minlabel.lt_level;
dv.dv_maxlvl = ss.ss_maxlabel.lt_level;
dv.dv_valcmp = ss.ss_maxlabel.lt_compart;
}
dv.dv_devflg = 0;
}
#else /* SO_SEC_MULTI */ /* 7.0 code */
if (getsockopt(0, SOL_SOCKET, SO_SECURITY,
(char *)&ss, &szss) >= 0) {
dv.dv_actlvl = ss.ss_slevel;
dv.dv_actcmp = ss.ss_compart;
dv.dv_minlvl = ss.ss_minlvl;
dv.dv_maxlvl = ss.ss_maxlvl;
dv.dv_valcmp = ss.ss_maxcmp;
}
#endif /* SO_SEC_MULTI */
}
#endif /* _SC_CRAY_SECURE_SYS */
openlog("telnetd", LOG_PID, LOG_DAEMON);
fromlen = sizeof (from);
if (getpeername(0, (struct sockaddr *)&from, &fromlen) < 0) {
@ -605,11 +429,6 @@ main(argc, argv)
#if defined(IPPROTO_IP) && defined(IP_TOS)
if (((struct sockaddr *)&from)->sa_family == AF_INET) {
# if defined(HAS_GETTOS)
struct tosent *tp;
if (tos < 0 && (tp = gettosbyname("telnet", "tcp")))
tos = tp->t_tos;
# endif
if (tos < 0)
tos = 020; /* Low Delay bit */
if (tos
@ -628,15 +447,12 @@ main(argc, argv)
#endif
} /* end of main */
void
void
usage()
{
fprintf(stderr, "Usage: telnetd");
#ifdef AUTHENTICATION
fprintf(stderr, " [-a (debug|other|user|valid|off|none)]\n\t");
#endif
#ifdef BFTPDAEMON
fprintf(stderr, " [-B]");
#endif
fprintf(stderr, " [-debug]");
#ifdef DIAGNOSTICS
@ -653,16 +469,10 @@ usage()
fprintf(stderr, " [-l]");
#endif
fprintf(stderr, " [-n]");
#ifdef CRAY
fprintf(stderr, " [-r[lowpty]-[highpty]]");
#endif
fprintf(stderr, "\n\t");
#ifdef SECURELOGIN
fprintf(stderr, " [-s]");
#endif
#ifdef HAS_GETTOS
fprintf(stderr, " [-S tos]");
#endif
#ifdef AUTHENTICATION
fprintf(stderr, " [-X auth-type]");
#endif
@ -681,14 +491,14 @@ static unsigned char ttytype_sbbuf[] = {
IAC, SB, TELOPT_TTYPE, TELQUAL_SEND, IAC, SE
};
int
int
getterminaltype(name)
char *name;
{
int retval = -1;
settimer(baseline);
#if defined(AUTHENTICATION)
#ifdef AUTHENTICATION
/*
* Handle the Authentication option before we do anything else.
*/
@ -823,7 +633,7 @@ getterminaltype(name)
return(retval);
} /* end of getterminaltype */
void
void
_gettermname()
{
/*
@ -841,7 +651,7 @@ _gettermname()
ttloop();
}
int
int
terminaltypeok(s)
char *s;
{
@ -862,19 +672,11 @@ terminaltypeok(s)
return(1);
}
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif /* MAXHOSTNAMELEN */
char *hostname;
char host_name[MAXHOSTNAMELEN + 1];
char remote_host_name[MAXHOSTNAMELEN + 1];
#ifndef convex
extern void telnet P((int, int));
#else
extern void telnet P((int, int, char *));
#endif
extern void telnet __P((int, int));
/*
* Get a pty, scan input lines.
@ -893,40 +695,9 @@ doit(who)
/*
* Find an available pty to use.
*/
#ifndef convex
pty = getpty(&ptynum);
if (pty < 0)
fatal(net, "All network ports in use");
#else
for (;;) {
char *lp;
if ((lp = getpty()) == NULL)
fatal(net, "Out of ptys");
if ((pty = open(lp, 2)) >= 0) {
(void)strlcpy(line, lp, sizeof(NULL16STR));
line[5] = 't';
break;
}
}
#endif
#if defined(_SC_CRAY_SECURE_SYS)
/*
* set ttyp line security label
*/
if (secflag) {
char slave_dev[16];
snprintf(tty_dev, sizeof(tty_dev), "/dev/pty/%03d", ptynum);
if (setdevs(tty_dev, &dv) < 0)
fatal(net, "cannot set pty security");
snprintf(slave_dev, sizeof(slave_dev) "/dev/ttyp%03d", ptynum);
if (setdevs(slave_dev, &dv) < 0)
fatal(net, "cannot set tty security");
}
#endif /* _SC_CRAY_SECURE_SYS */
flags = registerd_host_only ? NI_NAMEREQD : 0;
@ -934,12 +705,6 @@ doit(who)
error = getnameinfo(who, who->sa_len, remote_host_name,
sizeof(remote_host_name), NULL, 0, flags);
#if !defined(UTMPX) && !(defined(CRAY) || defined(__hpux)) && BSD <= 43
if (!error && strlen(remote_host_name) > utmp_len)
error = getnameinfo(who, who->sa_len, remote_host_name,
sizeof(remote_host_name), NULL, 0, NI_NUMERICHOST);
#endif
if (error) {
fatal(net, "Couldn't resolve your address into a host name.\r\n\
Please contact your net administrator");
@ -951,7 +716,7 @@ doit(who)
remote_host_name[sizeof(remote_host_name)-1] = 0;
host = remote_host_name;
(void)gethostname(host_name, sizeof (host_name));
(void)gethostname(host_name, sizeof(host_name));
host_name[sizeof(host_name) - 1] = '\0';
hostname = host_name;
@ -970,22 +735,9 @@ doit(who)
/*
* Start up the login process on the slave side of the terminal
*/
#ifndef convex
startslave(host, level, user_name);
#if defined(_SC_CRAY_SECURE_SYS)
if (secflag) {
if (setulvl(dv.dv_actlvl) < 0)
fatal(net,"cannot setulvl()");
if (setucmp(dv.dv_actcmp) < 0)
fatal(net, "cannot setucmp()");
}
#endif /* _SC_CRAY_SECURE_SYS */
telnet(net, pty); /* begin server processing */
#else
telnet(net, pty, host);
#endif
/*NOTREACHED*/
} /* end of doit */
@ -994,16 +746,9 @@ doit(who)
* Main loop. Select from pty and network, and
* hand data to telnet receiver finite state machine.
*/
void
#ifndef convex
void
telnet(f, p)
#else
telnet(f, p, host)
#endif
int f, p;
#ifdef convex
char *host;
#endif
{
int on = 1;
#define TABBUFSIZ 512
@ -1109,12 +854,10 @@ telnet(f, p, host)
if (my_state_is_wont(TELOPT_ECHO))
send_will(TELOPT_ECHO, 1);
#ifndef STREAMSPTY
/*
* Turn on packet mode
*/
(void) ioctl(p, TIOCPKT, (char *)&on);
#endif
#if defined(LINEMODE) && defined(KLUDGELINEMODE)
/*
@ -1136,26 +879,18 @@ telnet(f, p, host)
(void) ioctl(f, FIONBIO, (char *)&on);
(void) ioctl(p, FIONBIO, (char *)&on);
#if defined(SO_OOBINLINE)
(void) setsockopt(f, SOL_SOCKET, SO_OOBINLINE,
(char *)&on, sizeof on);
#endif /* defined(SO_OOBINLINE) */
(void) setsockopt(f, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof on);
#ifdef SIGTSTP
(void) signal(SIGTSTP, SIG_IGN);
#endif
#ifdef SIGTTOU
/*
* Ignoring SIGTTOU keeps the kernel from blocking us
* in ttioct() in /sys/tty.c.
*/
(void) signal(SIGTTOU, SIG_IGN);
#endif
(void) signal(SIGCHLD, cleanup);
#ifdef TIOCNOTTY
{
register int t;
t = open(_PATH_TTY, O_RDWR);
@ -1164,7 +899,6 @@ telnet(f, p, host)
(void) close(t);
}
}
#endif
/*
@ -1225,9 +959,6 @@ telnet(f, p, host)
DIAG(TD_REPORT,
{output_data("td: Entering processing loop\r\n");});
#ifdef convex
startslave(host);
#endif
set[0].fd = f;
set[1].fd = p;
@ -1275,63 +1006,7 @@ telnet(f, p, host)
* Something to read from the network...
*/
if (set[0].revents && POLLIN) {
#if !defined(SO_OOBINLINE)
/*
* In 4.2 (and 4.3 beta) systems, the
* OOB indication and data handling in the kernel
* is such that if two separate TCP Urgent requests
* come in, one byte of TCP data will be overlaid.
* This is fatal for Telnet, but we try to live
* with it.
*
* In addition, in 4.2 (and...), a special protocol
* is needed to pick up the TCP Urgent data in
* the correct sequence.
*
* What we do is: if we think we are in urgent
* mode, we look to see if we are "at the mark".
* If we are, we do an OOB receive. If we run
* this twice, we will do the OOB receive twice,
* but the second will fail, since the second
* time we were "at the mark", but there wasn't
* any data there (the kernel doesn't reset
* "at the mark" until we do a normal read).
* Once we've read the OOB data, we go ahead
* and do normal reads.
*
* There is also another problem, which is that
* since the OOB byte we read doesn't put us
* out of OOB state, and since that byte is most
* likely the TELNET DM (data mark), we would
* stay in the TELNET SYNCH (SYNCHing) state.
* So, clocks to the rescue. If we've "just"
* received a DM, then we test for the
* presence of OOB data when the receive OOB
* fails (and AFTER we did the normal mode read
* to clear "at the mark").
*/
if (SYNCHing) {
int atmark;
(void) ioctl(f, SIOCATMARK, (char *)&atmark);
if (atmark) {
ncc = recv(f, netibuf, sizeof (netibuf), MSG_OOB);
if ((ncc == -1) && (errno == EINVAL)) {
ncc = read(f, netibuf, sizeof (netibuf));
if (sequenceIs(didnetreceive, gotDM)) {
SYNCHing = stilloob(f);
}
}
} else {
ncc = read(f, netibuf, sizeof (netibuf));
}
} else {
ncc = read(f, netibuf, sizeof (netibuf));
}
settimer(didnetreceive);
#else /* !defined(SO_OOBINLINE)) */
ncc = read(f, netibuf, sizeof (netibuf));
#endif /* !defined(SO_OOBINLINE)) */
if (ncc < 0 && errno == EWOULDBLOCK)
ncc = 0;
else {
@ -1349,20 +1024,14 @@ telnet(f, p, host)
* Something to read from the pty...
*/
if (set[1].revents & POLLIN) {
#ifndef STREAMSPTY
pcc = read(p, ptyibuf, BUFSIZ);
#else
pcc = readstream(p, ptyibuf, BUFSIZ);
#endif
/*
* On some systems, if we try to read something
* off the master side before the slave side is
* opened, we get EIO.
*/
if (pcc < 0 && (errno == EWOULDBLOCK ||
#ifdef EAGAIN
errno == EAGAIN ||
#endif
errno == EIO)) {
pcc = 0;
} else {
@ -1380,7 +1049,6 @@ telnet(f, p, host)
#endif /* LINEMODE */
if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) {
netclear(); /* clear buffer back */
#ifndef NO_URGENT
/*
* There are client telnets on some
* operating systems get screwed up
@ -1391,8 +1059,6 @@ telnet(f, p, host)
neturg = nfrontp - 1; /* off by one XXX */
DIAG(TD_OPTIONS,
printoption("td: send IAC", DM));
#endif
}
if (his_state_is_will(TELOPT_LFLOW) &&
(ptyibuf[0] &
@ -1443,128 +1109,17 @@ telnet(f, p, host)
cleanup(0);
} /* end of telnet */
#ifndef TCSIG
# ifdef TIOCSIG
# define TCSIG TIOCSIG
# endif
#endif
#ifdef STREAMSPTY
int flowison = -1; /* current state of flow: -1 is unknown */
int readstream(p, ibuf, bufsize)
int p;
char *ibuf;
int bufsize;
{
int flags = 0;
int ret = 0;
struct termios *tsp;
struct termio *tp;
struct iocblk *ip;
char vstop, vstart;
int ixon;
int newflow;
strbufc.maxlen = BUFSIZ;
strbufc.buf = (char *)ctlbuf;
strbufd.maxlen = bufsize-1;
strbufd.len = 0;
strbufd.buf = ibuf+1;
ibuf[0] = 0;
ret = getmsg(p, &strbufc, &strbufd, &flags);
if (ret < 0) /* error of some sort -- probably EAGAIN */
return(-1);
if (strbufc.len <= 0 || ctlbuf[0] == M_DATA) {
/* data message */
if (strbufd.len > 0) { /* real data */
return(strbufd.len + 1); /* count header char */
} else {
/* nothing there */
errno = EAGAIN;
return(-1);
}
}
/*
* It's a control message. Return 1, to look at the flag we set
*/
switch (ctlbuf[0]) {
case M_FLUSH:
if (ibuf[1] & FLUSHW)
ibuf[0] = TIOCPKT_FLUSHWRITE;
return(1);
case M_IOCTL:
ip = (struct iocblk *) (ibuf+1);
switch (ip->ioc_cmd) {
case TCSETS:
case TCSETSW:
case TCSETSF:
tsp = (struct termios *)
(ibuf+1 + sizeof(struct iocblk));
vstop = tsp->c_cc[VSTOP];
vstart = tsp->c_cc[VSTART];
ixon = tsp->c_iflag & IXON;
break;
case TCSETA:
case TCSETAW:
case TCSETAF:
tp = (struct termio *) (ibuf+1 + sizeof(struct iocblk));
vstop = tp->c_cc[VSTOP];
vstart = tp->c_cc[VSTART];
ixon = tp->c_iflag & IXON;
break;
default:
errno = EAGAIN;
return(-1);
}
newflow = (ixon && (vstart == 021) && (vstop == 023)) ? 1 : 0;
if (newflow != flowison) { /* it's a change */
flowison = newflow;
ibuf[0] = newflow ? TIOCPKT_DOSTOP : TIOCPKT_NOSTOP;
return(1);
}
}
/* nothing worth doing anything about */
errno = EAGAIN;
return(-1);
}
#endif /* STREAMSPTY */
/*
* Send interrupt to process on other side of pty.
* If it is in raw mode, just write NULL;
* otherwise, write intr char.
*/
void
void
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 */
init_termbuf();
*pfrontp++ = slctab[SLC_IP].sptr ?
(unsigned char)*slctab[SLC_IP].sptr : '\177';
#endif /* TCSIG */
#endif
(void) ioctl(pty, TIOCSIG, (char *)SIGINT);
}
/*
@ -1572,55 +1127,42 @@ interrupt()
* If it is in raw mode, just write NULL;
* otherwise, write quit char.
*/
void
void
sendbrk()
{
ptyflush(); /* half-hearted */
#ifdef TCSIG
(void) ioctl(pty, TCSIG, (char *)SIGQUIT);
#else /* TCSIG */
init_termbuf();
*pfrontp++ = slctab[SLC_ABORT].sptr ?
(unsigned char)*slctab[SLC_ABORT].sptr : '\034';
#endif /* TCSIG */
(void) ioctl(pty, TIOCSIG, (char *)SIGQUIT);
}
void
void
sendsusp()
{
#ifdef SIGTSTP
ptyflush(); /* half-hearted */
# ifdef TCSIG
(void) ioctl(pty, TCSIG, (char *)SIGTSTP);
# else /* TCSIG */
*pfrontp++ = slctab[SLC_SUSP].sptr ?
(unsigned char)*slctab[SLC_SUSP].sptr : '\032';
# endif /* TCSIG */
#endif /* SIGTSTP */
(void) ioctl(pty, TIOCSIG, (char *)SIGTSTP);
}
/*
* When we get an AYT, if ^T is enabled, use that. Otherwise,
* just send back "[Yes]".
*/
void
void
recv_ayt()
{
#if defined(SIGINFO) && defined(TCSIG)
#if defined(SIGINFO)
if (slctab[SLC_AYT].sptr && *slctab[SLC_AYT].sptr != _POSIX_VDISABLE) {
(void) ioctl(pty, TCSIG, (char *)SIGINFO);
(void) ioctl(pty, TIOCSIG, (char *)SIGINFO);
return;
}
#endif
(void) output_data("\r\n[Yes]\r\n");
}
void
void
doeof()
{
init_termbuf();
#if defined(LINEMODE) && defined(USE_TERMIO) && (VEOF == VMIN)
#if defined(LINEMODE) && (VEOF == VMIN)
if (!tty_isediting()) {
extern char oldeofc;
*pfrontp++ = oldeofc;

View File

@ -1,4 +1,4 @@
/* $NetBSD: termstat.c,v 1.11 2001/08/24 00:14:04 wiz Exp $ */
/* $NetBSD: termstat.c,v 1.12 2003/07/14 15:55:56 itojun Exp $ */
/*
* Copyright (c) 1989, 1993
@ -38,13 +38,13 @@
#if 0
static char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: termstat.c,v 1.11 2001/08/24 00:14:04 wiz Exp $");
__RCSID("$NetBSD: termstat.c,v 1.12 2003/07/14 15:55:56 itojun Exp $");
#endif
#endif /* not lint */
#include "telnetd.h"
#if defined(ENCRYPTION)
#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@ -52,9 +52,7 @@ __RCSID("$NetBSD: termstat.c,v 1.11 2001/08/24 00:14:04 wiz Exp $");
* local variables
*/
int def_tspeed = -1, def_rspeed = -1;
#ifdef TIOCSWINSZ
int def_row = 0, def_col = 0;
#endif
#ifdef LINEMODE
static int _terminit = 0;
#endif /* LINEMODE */
@ -137,7 +135,7 @@ static int _terminit = 0;
* then linemode is off, if server won't SGA, then linemode
* is on.
*/
void
void
localstat()
{
int need_will_echo = 0;
@ -353,7 +351,7 @@ done:
*
* Check for changes to flow control
*/
void
void
flowstat()
{
if (his_state_is_will(TELOPT_LFLOW)) {
@ -383,7 +381,7 @@ flowstat()
* at a time, and if using kludge linemode, then only linemode may be
* affected.
*/
void
void
clientstat(code, parm1, parm2)
register int code, parm1, parm2;
{
@ -515,7 +513,6 @@ clientstat(code, parm1, parm2)
#endif /* LINEMODE */
case TELOPT_NAWS:
#ifdef TIOCSWINSZ
{
struct winsize ws;
@ -538,7 +535,6 @@ clientstat(code, parm1, parm2)
ws.ws_row = parm2;
(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);
}
#endif /* TIOCSWINSZ */
break;
@ -587,7 +583,7 @@ clientstat(code, parm1, parm2)
* 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
void
defer_terminit()
{
@ -599,7 +595,6 @@ defer_terminit()
def_tspeed = def_rspeed = 0;
}
#ifdef TIOCSWINSZ
if (def_col || def_row) {
struct winsize ws;
@ -608,7 +603,6 @@ defer_terminit()
ws.ws_row = def_row;
(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);
}
#endif
/*
* The only other module that currently defers anything.
@ -622,7 +616,7 @@ defer_terminit()
*
* Returns true if the pty state has been processed yet.
*/
int
int
terminit()
{
return(_terminit);

View File

@ -1,4 +1,4 @@
/* $NetBSD: utility.c,v 1.22 2003/05/09 20:43:47 christos Exp $ */
/* $NetBSD: utility.c,v 1.23 2003/07/14 15:55:56 itojun Exp $ */
/*
* Copyright (c) 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: utility.c,v 1.22 2003/05/09 20:43:47 christos Exp $");
__RCSID("$NetBSD: utility.c,v 1.23 2003/07/14 15:55:56 itojun Exp $");
#endif
#endif /* not lint */
@ -64,7 +64,7 @@ extern int not42;
* too full.
*/
void
void
ttloop()
{
@ -92,7 +92,7 @@ ttloop()
/*
* Check a descriptor to see if out of band data exists on it.
*/
int
int
stilloob(s)
int s; /* socket number */
{
@ -115,7 +115,7 @@ stilloob(s)
}
}
void
void
ptyflush()
{
int n;
@ -146,7 +146,7 @@ ptyflush()
* if the current address is a TELNET IAC ("I Am a Command")
* character.
*/
char *
char *
nextitem(current)
char *current;
{
@ -193,7 +193,7 @@ nextitem(current)
* caller should be setting the urgent data pointer AFTER calling
* us in any case.
*/
void
void
netclear()
{
register char *thisitem, *next;
@ -246,7 +246,7 @@ netclear()
* Send as much data as possible to the network,
* handling requests for urgent data.
*/
void
void
netflush()
{
int n;
@ -322,7 +322,7 @@ netflush()
* ptr - A pointer to a character string to write
* len - How many bytes to write
*/
void
void
writenet(ptr, len)
register unsigned char *ptr;
register int len;
@ -342,9 +342,7 @@ writenet(ptr, len)
/*
* miscellaneous functions doing a variety of little jobs follow ...
*/
void
void
fatal(f, msg)
int f;
const char *msg;
@ -367,7 +365,7 @@ fatal(f, msg)
exit(1);
}
void
void
fatalperror(f, msg)
int f;
const char *msg;
@ -380,7 +378,7 @@ fatalperror(f, msg)
char editedhost[MAXHOSTNAMELEN];
void
void
edithost(pat, host)
register char *pat;
register char *host;
@ -422,7 +420,7 @@ edithost(pat, host)
static char *putlocation;
void
void
putstr(s)
register char *s;
{
@ -431,7 +429,7 @@ putstr(s)
putchr(*s++);
}
void
void
putchr(cc)
int cc;
{
@ -445,7 +443,7 @@ putchr(cc)
static char fmtstr[] = { "%l:%M\
%p on %A, %d %B %Y" };
char *
char *
putf(cp, where)
register char *cp;
char *where;
@ -467,12 +465,7 @@ putf(cp, where)
switch (*++cp) {
case 't':
#ifdef STREAMSPTY
/* names are like /dev/pts/2 -- we want pts/2 */
slash = strchr(line+1, '/');
#else
slash = strrchr(line, '/');
#endif
if (slash == (char *) 0)
putstr(line);
else
@ -519,7 +512,7 @@ putf(cp, where)
/*
* Print telnet options and commands in plain text, if possible.
*/
void
void
printoption(fmt, option)
register const char *fmt;
register int option;
@ -533,7 +526,7 @@ printoption(fmt, option)
return;
}
void
void
printsub(direction, pointer, length)
char direction; /* '<' or '>' */
unsigned char *pointer; /* where suboption data sits */
@ -908,7 +901,7 @@ printsub(direction, pointer, length)
}
break;
#if defined(AUTHENTICATION)
#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
output_data("AUTHENTICATION");
@ -1066,7 +1059,7 @@ printsub(direction, pointer, length)
/*
* Dump a data buffer in hex and ascii to the output data stream.
*/
void
void
printdata(tag, ptr, cnt)
register char *tag;
register char *ptr;