Removal of huge amounts of dead code.

Telnetd now hopefully works on most modern STREAMS based systems as
well as BSD systems.

It might have broke on some systems that I haven't tested on, like
CRAY with UNICOS5 and Linux ;-)


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@227 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Unknown User d91-jda
1996-02-04 15:03:03 +00:00
parent 7d42276cab
commit c92fc8f075
5 changed files with 148 additions and 402 deletions

View File

@@ -46,7 +46,7 @@ $(OBJECTS): ../config.h
.c.o: .c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) \ $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) \
@KRBINCPATH@ -I.. -I$(srcdir)/.. $< @KRBINCPATH@ -I.. -I$(srcdir)/.. -I. -I$(srcdir) $<
telnetd: $(OBJECTS) telnetd: $(OBJECTS)
$(CC) -o telnetd $(OBJECTS) $(LIBS) ../libtelnet/libtelnet.a $(KLIB) $(CC) -o telnetd $(OBJECTS) $(LIBS) ../libtelnet/libtelnet.a $(KLIB)

View File

@@ -43,33 +43,12 @@
# define BSD 43 # define BSD 43
#endif #endif
#if defined(CRAY) && !defined(LINEMODE)
# define SYSV_TERMIO
# define LINEMODE
# define KLUDGELINEMODE
# define DIAGNOSTICS
# if defined(UNICOS50) && !defined(UNICOS5)
# define UNICOS5
# endif
# if !defined(UNICOS5)
# define BFTPDAEMON
# define HAS_IP_TOS
# endif
#endif /* CRAY */
#if defined(UNICOS5) && !defined(NO_SETSID)
# define NO_SETSID
#endif
#if defined(PRINTOPTIONS) && defined(DIAGNOSTICS) #if defined(PRINTOPTIONS) && defined(DIAGNOSTICS)
#define TELOPTS #define TELOPTS
#define TELCMDS #define TELCMDS
#define SLC_NAMES #define SLC_NAMES
#endif #endif
#if defined(SYSV_TERMIO) && !defined(USE_TERMIO)
# define USE_TERMIO
#endif
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/time.h> #include <sys/time.h>
#ifdef HAVE_SYS_RESOURCE_H #ifdef HAVE_SYS_RESOURCE_H
@@ -81,9 +60,14 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef FILIO_H
/* including both <sys/ioctl.h> and <termios.h> in SunOS 4 generates a
lot of warnings */
#if defined(HAVE_SYS_IOCTL_H) && !(defined(sun) && !defined(__svr4__))
#include <sys/ioctl.h> #include <sys/ioctl.h>
#else #endif
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h> #include <sys/filio.h>
#endif #endif
@@ -92,9 +76,7 @@
#include <arpa/telnet.h> #include <arpa/telnet.h>
#include <stdio.h> #include <stdio.h>
#ifdef __STDC__
#include <stdlib.h> #include <stdlib.h>
#endif
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include <netdb.h> #include <netdb.h>
@@ -106,28 +88,10 @@
#define LOG_ODELAY 0 #define LOG_ODELAY 0
#endif #endif
#include <ctype.h> #include <ctype.h>
#ifndef NO_STRING_H
#include <string.h> #include <string.h>
#else
#include <strings.h>
#endif
#ifndef USE_TERMIO #include <termios.h>
#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
#ifdef __STDC__
#include <unistd.h> #include <unistd.h>
#endif
#ifndef _POSIX_VDISABLE #ifndef _POSIX_VDISABLE
# ifdef VDISABLE # ifdef VDISABLE

View File

@@ -378,7 +378,7 @@ change_slc(func, flag, val)
} /* end of change_slc */ } /* end of change_slc */
#if defined(USE_TERMIO) && (VEOF == VMIN) #if VEOF == VMIN
cc_t oldeofc = '\004'; cc_t oldeofc = '\004';
#endif #endif
@@ -396,7 +396,7 @@ check_slc()
register int i; register int i;
for (i = 1; i <= NSLC; 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 * In a perfect world this would be a neat little
* function. But in this world, we should not notify * function. But in this world, we should not notify
@@ -410,7 +410,7 @@ check_slc()
else if (slctab[i].sptr) else if (slctab[i].sptr)
oldeofc = *(slctab[i].sptr); oldeofc = *(slctab[i].sptr);
} }
#endif /* defined(USE_TERMIO) && defined(SYSV_TERMIO) */ #endif
if (slctab[i].sptr && if (slctab[i].sptr &&
(*(slctab[i].sptr) != slctab[i].current.val)) { (*(slctab[i].sptr) != slctab[i].current.val)) {
slctab[i].current.val = *(slctab[i].sptr); slctab[i].current.val = *(slctab[i].sptr);

View File

@@ -38,7 +38,7 @@ RCSID("$Id$");
#include "telnetd.h" #include "telnetd.h"
#include "pathnames.h" #include "pathnames.h"
#if defined(AUTHENTICATION) #ifdef AUTHENTICATION
#include <libtelnet/auth.h> #include <libtelnet/auth.h>
#endif #endif
@@ -83,14 +83,18 @@ extern struct sysv sysv;
#endif /* NEWINIT */ #endif /* NEWINIT */
#ifdef STREAMSPTY #ifdef STREAMSPTY
#ifdef HAVE_SAC_H
#include <sac.h> #include <sac.h>
#endif
#include <sys/stropts.h> #include <sys/stropts.h>
#endif #endif
#define SCPYN(a, b) (void) strncpy(a, b, sizeof(a)) #define SCPYN(a, b) (void) strncpy(a, b, sizeof(a))
#define SCMPN(a, b) strncmp(a, b, sizeof(a)) #define SCMPN(a, b) strncmp(a, b, sizeof(a))
#ifdef STREAMS #ifdef HAVE_SYS_STREAM_H
#include <sys/stream.h> #include <sys/stream.h>
#endif #endif
#ifdef __hpux #ifdef __hpux
@@ -123,22 +127,6 @@ extern struct sysv sysv;
# define EXTPROC 0400 # define EXTPROC 0400
#endif #endif
#ifndef USE_TERMIO
struct termbuf {
struct sgttyb sg;
struct tchars tc;
struct ltchars ltc;
int state;
int lflags;
} termbuf, termbuf2;
# define cfsetospeed(tp, val) (tp)->sg.sg_ospeed = (val)
# define cfsetispeed(tp, val) (tp)->sg.sg_ispeed = (val)
# define cfgetospeed(tp) (tp)->sg.sg_ospeed
# define cfgetispeed(tp) (tp)->sg.sg_ispeed
#else /* USE_TERMIO */
# ifdef SYSV_TERMIO
# define termios termio
# endif
# ifndef TCSANOW # ifndef TCSANOW
# ifdef TCSETS # ifdef TCSETS
# define TCSANOW TCSETS # define TCSANOW TCSETS
@@ -173,7 +161,6 @@ struct termios termbuf, termbuf2; /* pty control structure */
# ifdef STREAMSPTY # ifdef STREAMSPTY
int ttyfd = -1; int ttyfd = -1;
# endif # endif
#endif /* USE_TERMIO */
char *new_login = LOGIN_PATH; char *new_login = LOGIN_PATH;
@@ -191,20 +178,11 @@ char *new_login = LOGIN_PATH;
void void
init_termbuf() init_termbuf()
{ {
#ifndef USE_TERMIO
(void) ioctl(pty, TIOCGETP, (char *)&termbuf.sg);
(void) ioctl(pty, TIOCGETC, (char *)&termbuf.tc);
(void) ioctl(pty, TIOCGLTC, (char *)&termbuf.ltc);
# ifdef TIOCGSTATE
(void) ioctl(pty, TIOCGSTATE, (char *)&termbuf.state);
# endif
#else
# ifdef STREAMSPTY # ifdef STREAMSPTY
(void) tcgetattr(ttyfd, &termbuf); (void) tcgetattr(ttyfd, &termbuf);
# else # else
(void) tcgetattr(pty, &termbuf); (void) tcgetattr(pty, &termbuf);
# endif # endif
#endif
termbuf2 = termbuf; termbuf2 = termbuf;
} }
@@ -227,19 +205,6 @@ set_termbuf()
/* /*
* Only make the necessary changes. * Only make the necessary changes.
*/ */
#ifndef USE_TERMIO
if (memcmp((char *)&termbuf.sg, (char *)&termbuf2.sg,
sizeof(termbuf.sg)))
(void) ioctl(pty, TIOCSETN, (char *)&termbuf.sg);
if (memcmp((char *)&termbuf.tc, (char *)&termbuf2.tc,
sizeof(termbuf.tc)))
(void) ioctl(pty, TIOCSETC, (char *)&termbuf.tc);
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 (memcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf))) if (memcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
# ifdef STREAMSPTY # ifdef STREAMSPTY
(void) tcsetattr(ttyfd, TCSANOW, &termbuf); (void) tcsetattr(ttyfd, TCSANOW, &termbuf);
@@ -249,7 +214,6 @@ set_termbuf()
# if defined(CRAY2) && defined(UNICOS5) # if defined(CRAY2) && defined(UNICOS5)
needtermstat = 1; needtermstat = 1;
# endif # endif
#endif /* USE_TERMIO */
} }
@@ -264,81 +228,6 @@ set_termbuf()
* It returns the SLC_ level of support for this function. * It returns the SLC_ level of support for this function.
*/ */
#ifndef USE_TERMIO
int
spcset(func, valp, valpp)
int func;
cc_t *valp;
cc_t **valpp;
{
switch(func) {
case SLC_EOF:
*valp = termbuf.tc.t_eofc;
*valpp = (cc_t *)&termbuf.tc.t_eofc;
return(SLC_VARIABLE);
case SLC_EC:
*valp = termbuf.sg.sg_erase;
*valpp = (cc_t *)&termbuf.sg.sg_erase;
return(SLC_VARIABLE);
case SLC_EL:
*valp = termbuf.sg.sg_kill;
*valpp = (cc_t *)&termbuf.sg.sg_kill;
return(SLC_VARIABLE);
case SLC_IP:
*valp = 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;
*valpp = (cc_t *)&termbuf.tc.t_quitc;
return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
case SLC_XON:
*valp = termbuf.tc.t_startc;
*valpp = (cc_t *)&termbuf.tc.t_startc;
return(SLC_VARIABLE);
case SLC_XOFF:
*valp = termbuf.tc.t_stopc;
*valpp = (cc_t *)&termbuf.tc.t_stopc;
return(SLC_VARIABLE);
case SLC_AO:
*valp = termbuf.ltc.t_flushc;
*valpp = (cc_t *)&termbuf.ltc.t_flushc;
return(SLC_VARIABLE);
case SLC_SUSP:
*valp = termbuf.ltc.t_suspc;
*valpp = (cc_t *)&termbuf.ltc.t_suspc;
return(SLC_VARIABLE);
case SLC_EW:
*valp = termbuf.ltc.t_werasc;
*valpp = (cc_t *)&termbuf.ltc.t_werasc;
return(SLC_VARIABLE);
case SLC_RP:
*valp = termbuf.ltc.t_rprntc;
*valpp = (cc_t *)&termbuf.ltc.t_rprntc;
return(SLC_VARIABLE);
case SLC_LNEXT:
*valp = 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:
*valp = (cc_t)0;
*valpp = (cc_t *)0;
return(SLC_DEFAULT);
default:
*valp = (cc_t)0;
*valpp = (cc_t *)0;
return(SLC_NOSUPPORT);
}
}
#else /* USE_TERMIO */
int int
spcset(func, valp, valpp) spcset(func, valp, valpp)
@@ -434,7 +323,6 @@ spcset(func, valp, valpp)
return(SLC_NOSUPPORT); return(SLC_NOSUPPORT);
} }
} }
#endif /* USE_TERMIO */
#ifdef CRAY #ifdef CRAY
/* /*
@@ -465,47 +353,59 @@ getnpty()
* *
* Returns the file descriptor of the opened pty. * Returns the file descriptor of the opened pty.
*/ */
#ifndef __GNUC__
char *line = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
#else
static char Xline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; static char Xline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
char *line = Xline; char *line = Xline;
#endif
#ifdef CRAY #ifdef CRAY
char *myline = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; char *myline = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
#endif /* CRAY */ #endif /* CRAY */
int static char* k_ptsname(int p)
getpty(ptynum)
int *ptynum;
{ {
register int p; #ifdef HAVE_PTSNAME
#ifdef _AIX return ptsname(p);
p=open("/dev/ptc", 2); #endif
if(p > 0){ #ifdef HAVE_TTYNAME
strcpy(line, ttyname(p)); return ttyname(p);
return p; #endif
return NULL;
}
int getpty(int *ptynum)
{
int p;
char *cp, *p1, *p2;
int i;
int dummy;
#ifdef HAVE_OPENPTY
int master;
int slave;
if(openpty(&master, &slave, line, 0, 0) == 0){
close(slave);
return master;
} }
#else #else
#ifdef STREAMSPTY #ifdef STREAMSPTY
int t; char *clone[] = { "/dev/ptc", "/dev/ptmx", "/dev/ptm",
char *ptsname(); "/dev/ptym/clone", 0 };
p = open("/dev/ptmx", 2); char **q;
if (p > 0) { for(q=clone; *q; q++){
grantpt(p); p=open(*q, O_RDWR);
unlockpt(p); if(p >= 0){
strcpy(line, ptsname(p)); #ifdef HAVE_GRANTPT
return(p); grantpt(p);
}
#else /* ! STREAMSPTY */
#ifndef CRAY
register char *cp, *p1, *p2;
register int i;
#if defined(sun) && defined(TIOCGPGRP) && BSD < 199207
int dummy;
#endif #endif
#ifdef HAVE_UNLOCKPT
unlockpt(p);
#endif
strcpy(line, k_ptsname(p));
return p;
}
}
#endif /* STREAMSPTY */
#ifndef CRAY
#ifndef __hpux #ifndef __hpux
(void) sprintf(line, "/dev/ptyXX"); (void) sprintf(line, "/dev/ptyXX");
@@ -517,6 +417,7 @@ int *ptynum;
p2 = &line[14]; p2 = &line[14];
#endif #endif
for (cp = "pqrstuvwxyzPQRST"; *cp; cp++) { for (cp = "pqrstuvwxyzPQRST"; *cp; cp++) {
struct stat stb; struct stat stb;
@@ -592,10 +493,9 @@ int *ptynum;
} }
#endif /* CRAY */ #endif /* CRAY */
#endif /* STREAMSPTY */ #endif /* STREAMSPTY */
#endif /* AIX */ #endif /* OPENPTY */
return(-1); return(-1);
} }
#endif /* convex */
#ifdef LINEMODE #ifdef LINEMODE
/* /*
@@ -627,11 +527,7 @@ static int linestate;
tty_linemode() tty_linemode()
{ {
#ifndef convex #ifndef convex
#ifndef USE_TERMIO
return(termbuf.state & TS_EXTPROC);
#else
return(termbuf.c_lflag & EXTPROC); return(termbuf.c_lflag & EXTPROC);
#endif
#else #else
return(linestate); return(linestate);
#endif #endif
@@ -665,79 +561,45 @@ tty_setlinemode(on)
int int
tty_isecho() tty_isecho()
{ {
#ifndef USE_TERMIO
return (termbuf.sg.sg_flags & ECHO);
#else
return (termbuf.c_lflag & ECHO); return (termbuf.c_lflag & ECHO);
#endif
} }
int int
tty_flowmode() tty_flowmode()
{ {
#ifndef USE_TERMIO
return(((termbuf.tc.t_startc) > 0 && (termbuf.tc.t_stopc) > 0) ? 1 : 0);
#else
return((termbuf.c_iflag & IXON) ? 1 : 0); return((termbuf.c_iflag & IXON) ? 1 : 0);
#endif
} }
int int
tty_restartany() tty_restartany()
{ {
#ifndef USE_TERMIO
# ifdef DECCTQ
return((termbuf.lflags & DECCTQ) ? 0 : 1);
# else
return(-1);
# endif
#else
return((termbuf.c_iflag & IXANY) ? 1 : 0); return((termbuf.c_iflag & IXANY) ? 1 : 0);
#endif
} }
void void
tty_setecho(on) tty_setecho(on)
int on; int on;
{ {
#ifndef USE_TERMIO
if (on)
termbuf.sg.sg_flags |= ECHO|CRMOD;
else
termbuf.sg.sg_flags &= ~(ECHO|CRMOD);
#else
if (on) if (on)
termbuf.c_lflag |= ECHO; termbuf.c_lflag |= ECHO;
else else
termbuf.c_lflag &= ~ECHO; termbuf.c_lflag &= ~ECHO;
#endif
} }
int int
tty_israw() tty_israw()
{ {
#ifndef USE_TERMIO
return(termbuf.sg.sg_flags & RAW);
#else
return(!(termbuf.c_lflag & ICANON)); return(!(termbuf.c_lflag & ICANON));
#endif
} }
#if defined (AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R) #if defined (AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
int int
tty_setraw(on) tty_setraw(on)
{ {
# ifndef USE_TERMIO
if (on)
termbuf.sg.sg_flags |= RAW;
else
termbuf.sg.sg_flags &= ~RAW;
# else
if (on) if (on)
termbuf.c_lflag &= ~ICANON; termbuf.c_lflag &= ~ICANON;
else else
termbuf.c_lflag |= ICANON; termbuf.c_lflag |= ICANON;
# endif
} }
#endif #endif
@@ -745,30 +607,17 @@ tty_setraw(on)
tty_binaryin(on) tty_binaryin(on)
int on; int on;
{ {
#ifndef USE_TERMIO
if (on)
termbuf.lflags |= LPASS8;
else
termbuf.lflags &= ~LPASS8;
#else
if (on) { if (on) {
termbuf.c_iflag &= ~ISTRIP; termbuf.c_iflag &= ~ISTRIP;
} else { } else {
termbuf.c_iflag |= ISTRIP; termbuf.c_iflag |= ISTRIP;
} }
#endif
} }
void void
tty_binaryout(on) tty_binaryout(on)
int on; int on;
{ {
#ifndef USE_TERMIO
if (on)
termbuf.lflags |= LLITOUT;
else
termbuf.lflags &= ~LLITOUT;
#else
if (on) { if (on) {
termbuf.c_cflag &= ~(CSIZE|PARENB); termbuf.c_cflag &= ~(CSIZE|PARENB);
termbuf.c_cflag |= CS8; termbuf.c_cflag |= CS8;
@@ -778,108 +627,69 @@ tty_binaryout(on)
termbuf.c_cflag |= CS7|PARENB; termbuf.c_cflag |= CS7|PARENB;
termbuf.c_oflag |= OPOST; termbuf.c_oflag |= OPOST;
} }
#endif
} }
int int
tty_isbinaryin() tty_isbinaryin()
{ {
#ifndef USE_TERMIO
return(termbuf.lflags & LPASS8);
#else
return(!(termbuf.c_iflag & ISTRIP)); return(!(termbuf.c_iflag & ISTRIP));
#endif
} }
int int
tty_isbinaryout() tty_isbinaryout()
{ {
#ifndef USE_TERMIO
return(termbuf.lflags & LLITOUT);
#else
return(!(termbuf.c_oflag&OPOST)); return(!(termbuf.c_oflag&OPOST));
#endif
} }
#ifdef LINEMODE #ifdef LINEMODE
int int
tty_isediting() tty_isediting()
{ {
#ifndef USE_TERMIO
return(!(termbuf.sg.sg_flags & (CBREAK|RAW)));
#else
return(termbuf.c_lflag & ICANON); return(termbuf.c_lflag & ICANON);
#endif
} }
int int
tty_istrapsig() tty_istrapsig()
{ {
#ifndef USE_TERMIO
return(!(termbuf.sg.sg_flags&RAW));
#else
return(termbuf.c_lflag & ISIG); return(termbuf.c_lflag & ISIG);
#endif
} }
void void
tty_setedit(on) tty_setedit(on)
int on; int on;
{ {
#ifndef USE_TERMIO
if (on)
termbuf.sg.sg_flags &= ~CBREAK;
else
termbuf.sg.sg_flags |= CBREAK;
#else
if (on) if (on)
termbuf.c_lflag |= ICANON; termbuf.c_lflag |= ICANON;
else else
termbuf.c_lflag &= ~ICANON; termbuf.c_lflag &= ~ICANON;
#endif
} }
void void
tty_setsig(on) tty_setsig(on)
int on; int on;
{ {
#ifndef USE_TERMIO
if (on)
;
#else
if (on) if (on)
termbuf.c_lflag |= ISIG; termbuf.c_lflag |= ISIG;
else else
termbuf.c_lflag &= ~ISIG; termbuf.c_lflag &= ~ISIG;
#endif
} }
#endif /* LINEMODE */ #endif /* LINEMODE */
int int
tty_issofttab() tty_issofttab()
{ {
#ifndef USE_TERMIO
return (termbuf.sg.sg_flags & XTABS);
#else
# ifdef OXTABS # ifdef OXTABS
return (termbuf.c_oflag & OXTABS); return (termbuf.c_oflag & OXTABS);
# endif # endif
# ifdef TABDLY # ifdef TABDLY
return ((termbuf.c_oflag & TABDLY) == TAB3); return ((termbuf.c_oflag & TABDLY) == TAB3);
# endif # endif
#endif
} }
void void
tty_setsofttab(on) tty_setsofttab(on)
int on; int on;
{ {
#ifndef USE_TERMIO
if (on)
termbuf.sg.sg_flags |= XTABS;
else
termbuf.sg.sg_flags &= ~XTABS;
#else
if (on) { if (on) {
# ifdef OXTABS # ifdef OXTABS
termbuf.c_oflag |= OXTABS; termbuf.c_oflag |= OXTABS;
@@ -897,15 +707,11 @@ tty_setsofttab(on)
termbuf.c_oflag |= TAB0; termbuf.c_oflag |= TAB0;
# endif # endif
} }
#endif
} }
int int
tty_islitecho() tty_islitecho()
{ {
#ifndef USE_TERMIO
return (!(termbuf.lflags & LCTLECH));
#else
# ifdef ECHOCTL # ifdef ECHOCTL
return (!(termbuf.c_lflag & ECHOCTL)); return (!(termbuf.c_lflag & ECHOCTL));
# endif # endif
@@ -915,19 +721,12 @@ tty_islitecho()
# if !defined(ECHOCTL) && !defined(TCTLECH) # if !defined(ECHOCTL) && !defined(TCTLECH)
return (0); /* assumes ctl chars are echoed '^x' */ return (0); /* assumes ctl chars are echoed '^x' */
# endif # endif
#endif
} }
void void
tty_setlitecho(on) tty_setlitecho(on)
int on; int on;
{ {
#ifndef USE_TERMIO
if (on)
termbuf.lflags &= ~LCTLECH;
else
termbuf.lflags |= LCTLECH;
#else
# ifdef ECHOCTL # ifdef ECHOCTL
if (on) if (on)
termbuf.c_lflag &= ~ECHOCTL; termbuf.c_lflag &= ~ECHOCTL;
@@ -940,17 +739,12 @@ tty_setlitecho(on)
else else
termbuf.c_lflag |= TCTLECH; termbuf.c_lflag |= TCTLECH;
# endif # endif
#endif
} }
int int
tty_iscrnl() tty_iscrnl()
{ {
#ifndef USE_TERMIO
return (termbuf.sg.sg_flags & CRMOD);
#else
return (termbuf.c_iflag & ICRNL); return (termbuf.c_iflag & ICRNL);
#endif
} }
/* /*
@@ -1053,10 +847,9 @@ extern char wtmpf[];
# else /* NEWINIT */ # else /* NEWINIT */
int gotalarm; int gotalarm;
/* ARGSUSED */ /* ARGSUSED */
void void
nologinproc(sig) nologinproc(int sig)
int sig;
{ {
gotalarm++; gotalarm++;
} }
@@ -1072,6 +865,31 @@ extern void utmp_sig_notify P((int));
# endif /* PARENT_DOES_UTMP */ # endif /* PARENT_DOES_UTMP */
#endif #endif
#ifdef STREAMSPTY
static void maybe_push_modules(int fd, char **modules)
{
char **p;
int err;
for(p=modules; *p; p++){
err=ioctl(fd, I_FIND, *p);
if(err == 1)
break;
if(err < 0 && errno != EINVAL)
fatalperror(net, "I_FIND");
/* module not pushed or does not exist */
}
/* p points to null or to an already pushed module, now push all
modules before this one */
for(p--; p >= modules; p--){
err = ioctl(fd, I_PUSH, *p);
if(err < 0 && errno != EINVAL)
fatalperror(net, "I_PUSH");
}
}
#endif
/* /*
* getptyslave() * getptyslave()
* *
@@ -1079,8 +897,7 @@ extern void utmp_sig_notify P((int));
* that is necessary. The return value is a file descriptor * that is necessary. The return value is a file descriptor
* for the slave side. * for the slave side.
*/ */
int int getptyslave(void)
getptyslave()
{ {
register int t = -1; register int t = -1;
@@ -1110,6 +927,11 @@ getptyslave()
* Make sure that we don't have a controlling tty, and * Make sure that we don't have a controlling tty, and
* that we are the session (process group) leader. * that we are the session (process group) leader.
*/ */
#if HAVE_SETSID
if(setsid()<0)
fatalperror(net, "setsid()");
#else
# ifdef TIOCNOTTY # ifdef TIOCNOTTY
t = open(_PATH_TTY, O_RDWR); t = open(_PATH_TTY, O_RDWR);
if (t >= 0) { if (t >= 0) {
@@ -1117,7 +939,7 @@ getptyslave()
(void) close(t); (void) close(t);
} }
# endif # endif
#endif
# ifdef PARENT_DOES_UTMP # ifdef PARENT_DOES_UTMP
/* /*
@@ -1131,23 +953,34 @@ getptyslave()
fatalperror(net, line); fatalperror(net, line);
#ifdef STREAMSPTY #ifdef STREAMSPTY
#ifdef USE_TERMIO
ttyfd = t; ttyfd = t;
#endif
if (ioctl(t, I_PUSH, "ptem") < 0)
fatal(net, "I_PUSH ptem");
if (ioctl(t, I_PUSH, "ldterm") < 0)
fatal(net, "I_PUSH ldterm");
/* /*
* Not all systems have (or need) modules ttcompat and pckt so * Not all systems have (or need) modules ttcompat and pckt so
* don't flag it as a fatal error if they don't exist. * don't flag it as a fatal error if they don't exist.
*/ */
if (ioctl(t, I_PUSH, "ttcompat") < 0 && errno != EINVAL)
fatal(net, "I_PUSH ttcompat");
if (ioctl(pty, I_PUSH, "pckt") < 0 && errno != EINVAL)
fatal(net, "I_PUSH pckt");
#endif
{
/* these are the streams modules that we want pushed. note
that they are in reverse order, ptem will be pushed
first. maybe_push_modules() will try to push all modules
before the first one that isn't already pushed. i.e if
ldterm is pushed, only ttcompat will be attempted.
all this is because we don't know which modules are
available, and we don't know which modules are already
pushed (via autopush, for instance).
*/
char *ttymodules[] = { "ttcompat", "ldterm", "ptem", NULL };
char *ptymodules[] = { "pckt", NULL };
maybe_push_modules(t, ttymodules);
maybe_push_modules(pty, ptymodules);
}
#endif
/* /*
* set up the tty modes as we like them to be. * set up the tty modes as we like them to be.
*/ */
@@ -1164,9 +997,6 @@ getptyslave()
/* /*
* Settings for sgtty based systems * Settings for sgtty based systems
*/ */
# ifndef USE_TERMIO
termbuf.sg.sg_flags |= CRMOD|ANYP|ECHO|XTABS;
# endif /* USE_TERMIO */
/* /*
* Settings for UNICOS (and HPUX) * Settings for UNICOS (and HPUX)
@@ -1183,7 +1013,7 @@ getptyslave()
* systems, other than 4.4BSD. In 4.4BSD the * systems, other than 4.4BSD. In 4.4BSD the
* kernel does the initial terminal setup. * kernel does the initial terminal setup.
*/ */
# if defined(USE_TERMIO) && !(defined(CRAY) || defined(__hpux)) && (BSD <= 43) # if !(defined(CRAY) || defined(__hpux)) && (BSD <= 43)
# ifndef OXTABS # ifndef OXTABS
# define OXTABS 0 # define OXTABS 0
# endif # endif
@@ -1191,7 +1021,7 @@ getptyslave()
termbuf.c_oflag |= ONLCR|OXTABS; termbuf.c_oflag |= ONLCR|OXTABS;
termbuf.c_iflag |= ICRNL; termbuf.c_iflag |= ICRNL;
termbuf.c_iflag &= ~IXOFF; termbuf.c_iflag &= ~IXOFF;
# endif /* defined(USE_TERMIO) && !defined(CRAY) && (BSD <= 43) */ # endif
tty_rspeed((def_rspeed > 0) ? def_rspeed : 9600); tty_rspeed((def_rspeed > 0) ? def_rspeed : 9600);
tty_tspeed((def_tspeed > 0) ? def_tspeed : 9600); tty_tspeed((def_tspeed > 0) ? def_tspeed : 9600);
# ifdef LINEMODE # ifdef LINEMODE
@@ -1330,11 +1160,10 @@ int cleanopen(char *line)
#if BSD <= 43 #if BSD <= 43
int int login_tty(int t)
login_tty(t)
int t;
{ {
#ifndef _AIX #if 0 /* setsid done in other place */
#if defined(HAVE_SETSID) && !defined(_AIX)
if (setsid() < 0) { if (setsid() < 0) {
#ifdef ultrix #ifdef ultrix
/* /*
@@ -1346,6 +1175,7 @@ login_tty(t)
#endif #endif
fatalperror(net, "setsid()"); fatalperror(net, "setsid()");
} }
#endif /* HAVE_SETSID */
#endif #endif
# if defined(TIOCSCTTY) && !defined(__hpux) # if defined(TIOCSCTTY) && !defined(__hpux)
if (ioctl(t, TIOCSCTTY, (char *)0) < 0) if (ioctl(t, TIOCSCTTY, (char *)0) < 0)
@@ -1370,11 +1200,8 @@ login_tty(t)
#if defined HAVE_SETPGID #if defined HAVE_SETPGID
(void) setpgid(0, 0); (void) setpgid(0, 0);
#else #else
# if defined(SOLARIS) || defined(__hpux) || defined(__sgi) || defined(_AIX) (void) setpgrp(0, 0); /* if setpgid isn't available, setpgrp
(void) setpgrp(); probably takes arguments */
# else
(void) setpgrp(0, 0);
# endif
#endif #endif
close(open(line, O_RDWR)); close(open(line, O_RDWR));
# endif # endif
@@ -1481,7 +1308,7 @@ startslave(host, autologin, autoname)
utmp_sig_notify(pid); utmp_sig_notify(pid);
# endif /* PARENT_DOES_UTMP */ # endif /* PARENT_DOES_UTMP */
} else { } else {
getptyslave(autologin); getptyslave();
start_login(host, autologin, autoname); start_login(host, autologin, autoname);
/*NOTREACHED*/ /*NOTREACHED*/
} }
@@ -1611,10 +1438,6 @@ void start_login(char *host, int autologin, char *name)
register int pid = getpid(); register int pid = getpid();
struct utmpx utmpx; struct utmpx utmpx;
#endif #endif
#ifdef SOLARIS
char *term;
char termbuf[64];
#endif
#ifdef HAVE_UTMPX_H #ifdef HAVE_UTMPX_H
/* /*
@@ -1669,20 +1492,6 @@ void start_login(char *host, int autologin, char *name)
{ {
addarg(&argv, "-h"); addarg(&argv, "-h");
addarg(&argv, host); addarg(&argv, host);
#ifdef SOLARIS_LOGIN
/*
* SVR4 version of -h takes TERM= as second arg, or -
*/
term = getenv("TERM");
if (term == NULL || term[0] == 0) {
term = "-";
} else {
strcpy(termbuf, "TERM=");
strncat(termbuf, term, sizeof(termbuf) - 6);
term = termbuf;
}
addarg(&argv, term);
#endif
} }
#endif #endif
#if !defined(NO_LOGIN_P) #if !defined(NO_LOGIN_P)
@@ -1787,7 +1596,6 @@ void start_login(char *host, int autologin, char *name)
tty_setecho(isecho); tty_setecho(isecho);
tty_setraw(israw); tty_setraw(israw);
set_termbuf(); set_termbuf();
#ifndef SOLARIS
if (!israw) { if (!israw) {
/* /*
* Write a newline to ensure * Write a newline to ensure
@@ -1796,7 +1604,6 @@ void start_login(char *host, int autologin, char *name)
*/ */
write(xpty, "\n", 1); write(xpty, "\n", 1);
} }
#endif
} }
pty = xpty; pty = xpty;
} }
@@ -1828,16 +1635,6 @@ void start_login(char *host, int autologin, char *name)
*/ */
unsetenv("USER"); unsetenv("USER");
} }
#ifdef SOLARIS_LOGIN
else {
char **p;
addarg(&argv, ""); /* no login name */
for (p = environ; *p; p++) {
addarg(&argv, *p);
}
}
#endif /* SOLARIS */
#if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R) #if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
if (pty > 2) if (pty > 2)
close(pty); close(pty);

View File

@@ -78,14 +78,21 @@ int registerd_host_only = 0;
#ifdef STREAMSPTY #ifdef STREAMSPTY
# include <stropts.h> # include <stropts.h>
# include <termio.h> # include <termios.h>
/* make sure we don't get the bsd version */ #ifdef HAVE_SYS_STREAM_H
# ifndef __sgi #include <sys/stream.h>
# include "/usr/include/sys/tty.h" #endif
# include <sys/ptyvar.h> # ifdef HAVE_SYS_STRTTY_H
# else /* __sgi */
# include <sys/strtty.h> # include <sys/strtty.h>
# endif /* __sgi */ # endif
/* make sure we don't get the bsd version */
/* what is this here for? solaris? /joda */
# ifdef HAVE_SYS_TTY_H
# include "/usr/include/sys/tty.h"
# endif
# ifdef HAVE_SYS_PTYVAR_H
# include <sys/ptyvar.h>
# endif
/* /*
* Because of the way ptyibuf is used with streams messages, we need * Because of the way ptyibuf is used with streams messages, we need
@@ -99,7 +106,7 @@ char ptyibuf2[BUFSIZ];
unsigned char ctlbuf[BUFSIZ]; unsigned char ctlbuf[BUFSIZ];
struct strbuf strbufc, strbufd; struct strbuf strbufc, strbufd;
int readstream(); int readstream(int, char*, int);
#else /* ! STREAMPTY */ #else /* ! STREAMPTY */
@@ -1442,15 +1449,14 @@ telnet(f, p, host)
int flowison = -1; /* current state of flow: -1 is unknown */ int flowison = -1; /* current state of flow: -1 is unknown */
int readstream(p, ibuf, bufsize) int readstream(int p, char *ibuf, int bufsize)
int p;
char *ibuf;
int bufsize;
{ {
int flags = 0; int flags = 0;
int ret = 0; int ret = 0;
struct termios *tsp; struct termios *tsp;
#if 0
struct termio *tp; struct termio *tp;
#endif
struct iocblk *ip; struct iocblk *ip;
char vstop, vstart; char vstop, vstart;
int ixon; int ixon;
@@ -1501,6 +1507,7 @@ int readstream(p, ibuf, bufsize)
vstart = tsp->c_cc[VSTART]; vstart = tsp->c_cc[VSTART];
ixon = tsp->c_iflag & IXON; ixon = tsp->c_iflag & IXON;
break; break;
#if 0
case TCSETA: case TCSETA:
case TCSETAW: case TCSETAW:
case TCSETAF: case TCSETAF:
@@ -1509,6 +1516,7 @@ int readstream(p, ibuf, bufsize)
vstart = tp->c_cc[VSTART]; vstart = tp->c_cc[VSTART];
ixon = tp->c_iflag & IXON; ixon = tp->c_iflag & IXON;
break; break;
#endif
default: default:
errno = EAGAIN; errno = EAGAIN;
return(-1); return(-1);
@@ -1610,7 +1618,7 @@ doeof()
{ {
init_termbuf(); init_termbuf();
#if defined(LINEMODE) && defined(USE_TERMIO) && (VEOF == VMIN) #if defined(LINEMODE) && (VEOF == VMIN)
if (!tty_isediting()) { if (!tty_isediting()) {
extern char oldeofc; extern char oldeofc;
*pfrontp++ = oldeofc; *pfrontp++ = oldeofc;
@@ -1621,26 +1629,3 @@ doeof()
(unsigned char)*slctab[SLC_EOF].sptr : '\004'; (unsigned char)*slctab[SLC_EOF].sptr : '\004';
} }
/* sigh -- make libtermcap.a happy */
#ifdef SOLARIS2
char *index(char *a, int b)
{
return(strchr(a,b));
}
char *rindex(char *a, int b)
{
return(strrchr(a,b));
}
void bzero(void *sp, int len)
{
memset(sp, 0, len);
}
int bcopy(void *s1, void *s2, int len)
{
memcpy(s2, s1, len);
return 0;
}
int bcmp(void *s1, void *s2, int len) {
memcmp(s2, s1, len);
}
#endif