NEWINIT, UNICOS7x, UNICOS5: removed
STREAMSPTY: added variable `really_stream' Now able to handle the case where the OS supports stream ptys but we run out of them and start using ordinary BSD ones. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@722 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
		| @@ -46,45 +46,34 @@ RCSID("$Id$"); | |||||||
| # define PARENT_DOES_UTMP | # define PARENT_DOES_UTMP | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef	NEWINIT | #ifdef  NEWINIT | ||||||
| #include <initreq.h> | #error NEWINIT not supported | ||||||
| int	utmp_len = MaxHostNameLen;	/* sizeof(init_request.host) */ | #endif | ||||||
| #else	/* NEWINIT*/ |  | ||||||
| # ifdef	HAVE_UTMPX | #ifdef	HAVE_UTMPX | ||||||
| # include <utmpx.h> | #include <utmpx.h> | ||||||
| struct	utmpx wtmp; | struct	utmpx wtmp; | ||||||
| # else | #else | ||||||
| # include <utmp.h> | #include <utmp.h> | ||||||
| struct	utmp wtmp; | struct	utmp wtmp; | ||||||
| # endif /* HAVE_UTMPX */ | #endif /* HAVE_UTMPX */ | ||||||
|  |  | ||||||
| #ifdef HAVE_UT_HOST | #ifdef HAVE_UT_HOST | ||||||
| int	utmp_len = sizeof(wtmp.ut_host); | int	utmp_len = sizeof(wtmp.ut_host); | ||||||
| #else | #else | ||||||
| int	utmp_len = MaxHostNameLen; | int	utmp_len = MaxHostNameLen; | ||||||
| #endif | #endif | ||||||
| # ifndef PARENT_DOES_UTMP | #ifndef PARENT_DOES_UTMP | ||||||
| char	wtmpf[]	= "/usr/adm/wtmp"; | char	wtmpf[]	= "/usr/adm/wtmp"; | ||||||
| char	utmpf[] = "/etc/utmp"; | char	utmpf[] = "/etc/utmp"; | ||||||
| # else /* PARENT_DOES_UTMP */ | #else /* PARENT_DOES_UTMP */ | ||||||
| char	wtmpf[]	= "/etc/wtmp"; | char	wtmpf[]	= "/etc/wtmp"; | ||||||
| # endif /* PARENT_DOES_UTMP */ | #endif /* PARENT_DOES_UTMP */ | ||||||
|  |  | ||||||
| # ifdef CRAY | #ifdef CRAY | ||||||
| #include <tmpdir.h> | #include <tmpdir.h> | ||||||
| #include <sys/wait.h> | #include <sys/wait.h> | ||||||
| #  if (UNICOS_LVL == '7.0') || (UNICOS_LVL == '7.1') | #endif	/* CRAY */ | ||||||
| #   define UNICOS7x |  | ||||||
| #  endif |  | ||||||
|  |  | ||||||
| #  ifdef UNICOS7x |  | ||||||
| #include <sys/sysv.h> |  | ||||||
| #include <sys/secstat.h> |  | ||||||
| extern int secflag; |  | ||||||
| extern struct sysv sysv; |  | ||||||
| #  endif /* UNICOS7x */ |  | ||||||
| # endif	/* CRAY */ |  | ||||||
| #endif	/* NEWINIT */ |  | ||||||
|  |  | ||||||
| #ifdef	STREAMSPTY | #ifdef	STREAMSPTY | ||||||
|  |  | ||||||
| @@ -127,10 +116,6 @@ extern struct sysv sysv; | |||||||
| #undef	t_lnextc | #undef	t_lnextc | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(UNICOS5) && defined(CRAY2) && !defined(EXTPROC) |  | ||||||
| # define EXTPROC 0400 |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| # ifndef	TCSANOW | # ifndef	TCSANOW | ||||||
| #  ifdef TCSETS | #  ifdef TCSETS | ||||||
| #   define	TCSANOW		TCSETS | #   define	TCSANOW		TCSETS | ||||||
| @@ -163,7 +148,8 @@ extern struct sysv sysv; | |||||||
| # endif /* TCSANOW */ | # endif /* TCSANOW */ | ||||||
| struct termios termbuf, termbuf2;	/* pty control structure */ | struct termios termbuf, termbuf2;	/* pty control structure */ | ||||||
| # ifdef  STREAMSPTY | # ifdef  STREAMSPTY | ||||||
| int ttyfd = -1; | static int ttyfd = -1; | ||||||
|  | int really_stream = 0; | ||||||
| # endif | # endif | ||||||
|  |  | ||||||
| char *new_login = LOGIN_PATH; | char *new_login = LOGIN_PATH; | ||||||
| @@ -183,10 +169,11 @@ void | |||||||
| init_termbuf(void) | init_termbuf(void) | ||||||
| { | { | ||||||
| # ifdef  STREAMSPTY | # ifdef  STREAMSPTY | ||||||
| 	(void) tcgetattr(ttyfd, &termbuf); | 	if (really_stream) | ||||||
| # else | 		(void) tcgetattr(ttyfd, &termbuf); | ||||||
| 	(void) tcgetattr(ourpty, &termbuf); | 	else | ||||||
| # endif | # endif | ||||||
|  | 		(void) tcgetattr(ourpty, &termbuf); | ||||||
| 	termbuf2 = termbuf; | 	termbuf2 = termbuf; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -211,13 +198,11 @@ set_termbuf(void) | |||||||
| 	 */ | 	 */ | ||||||
| 	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); | 		if (really_stream) | ||||||
| # else | 			(void) tcsetattr(ttyfd, TCSANOW, &termbuf); | ||||||
| 		(void) tcsetattr(ourpty, TCSANOW, &termbuf); | 		else | ||||||
| # endif |  | ||||||
| # if	defined(CRAY2) && defined(UNICOS5) |  | ||||||
| 	needtermstat = 1; |  | ||||||
| # endif | # endif | ||||||
|  | 			(void) tcsetattr(ourpty, TCSANOW, &termbuf); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -456,6 +441,7 @@ int getpty(int *ptynum) | |||||||
| 	    unlockpt(p); | 	    unlockpt(p); | ||||||
| #endif | #endif | ||||||
| 	    strcpy(line, ptsname(p)); | 	    strcpy(line, ptsname(p)); | ||||||
|  | 	    really_stream = 1; | ||||||
| 	    return p; | 	    return p; | ||||||
| 	  } | 	  } | ||||||
| 	} | 	} | ||||||
| @@ -881,39 +867,15 @@ tty_rspeed(int val) | |||||||
| #endif	/* DECODE_BAUD */ | #endif	/* DECODE_BAUD */ | ||||||
| } | } | ||||||
|  |  | ||||||
| #if	defined(CRAY2) && defined(UNICOS5) |  | ||||||
| 	int |  | ||||||
| tty_isnewmap() |  | ||||||
| { |  | ||||||
| 	return((termbuf.c_oflag & OPOST) && (termbuf.c_oflag & ONLCR) && |  | ||||||
| 			!(termbuf.c_oflag & ONLRET)); |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef PARENT_DOES_UTMP | #ifdef PARENT_DOES_UTMP | ||||||
| # ifndef NEWINIT |  | ||||||
| extern	struct utmp wtmp; | extern	struct utmp wtmp; | ||||||
| extern char wtmpf[]; | extern char wtmpf[]; | ||||||
| # else	/* NEWINIT */ |  | ||||||
| int	gotalarm; |  | ||||||
|  |  | ||||||
| /* ARGSUSED */ |  | ||||||
| void |  | ||||||
| nologinproc(int sig) |  | ||||||
| { |  | ||||||
| 	gotalarm++; |  | ||||||
| } |  | ||||||
| # endif	/* NEWINIT */ |  | ||||||
| #endif /* PARENT_DOES_UTMP */ |  | ||||||
|  |  | ||||||
| #ifndef	NEWINIT |  | ||||||
| # ifdef PARENT_DOES_UTMP |  | ||||||
| extern void utmp_sig_init P((void)); | extern void utmp_sig_init P((void)); | ||||||
| extern void utmp_sig_reset P((void)); | extern void utmp_sig_reset P((void)); | ||||||
| extern void utmp_sig_wait P((void)); | extern void utmp_sig_wait P((void)); | ||||||
| extern void utmp_sig_notify P((int)); | extern void utmp_sig_notify P((int)); | ||||||
| # endif /* PARENT_DOES_UTMP */ | # endif /* PARENT_DOES_UTMP */ | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef STREAMSPTY | #ifdef STREAMSPTY | ||||||
|  |  | ||||||
| @@ -984,7 +946,6 @@ void getptyslave(void) | |||||||
| { | { | ||||||
| 	register int t = -1; | 	register int t = -1; | ||||||
|  |  | ||||||
| #if	!defined(CRAY) || !defined(NEWINIT) |  | ||||||
| # ifdef	LINEMODE | # ifdef	LINEMODE | ||||||
| 	int waslm; | 	int waslm; | ||||||
| # endif | # endif | ||||||
| @@ -1044,6 +1005,7 @@ void getptyslave(void) | |||||||
| 	 * 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 (really_stream) | ||||||
| 	{ | 	{ | ||||||
| 	  /* these are the streams modules that we want pushed. note | 	  /* these are the streams modules that we want pushed. note | ||||||
| 	     that they are in reverse order, ptem will be pushed | 	     that they are in reverse order, ptem will be pushed | ||||||
| @@ -1118,7 +1080,6 @@ void getptyslave(void) | |||||||
| 	set_termbuf(); | 	set_termbuf(); | ||||||
| 	if (login_tty(t) == -1) | 	if (login_tty(t) == -1) | ||||||
| 		fatalperror(net, "login_tty"); | 		fatalperror(net, "login_tty"); | ||||||
| #endif	/* !defined(CRAY) || !defined(NEWINIT) */ |  | ||||||
| 	if (net > 2) | 	if (net > 2) | ||||||
| 		(void) close(net); | 		(void) close(net); | ||||||
| #if	defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R) | #if	defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R) | ||||||
| @@ -1134,7 +1095,6 @@ void getptyslave(void) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| #if	!defined(CRAY) || !defined(NEWINIT) |  | ||||||
| #ifndef	O_NOCTTY | #ifndef	O_NOCTTY | ||||||
| #define	O_NOCTTY	0 | #define	O_NOCTTY	0 | ||||||
| #endif | #endif | ||||||
| @@ -1146,44 +1106,25 @@ void getptyslave(void) | |||||||
| int cleanopen(char *line) | int cleanopen(char *line) | ||||||
| { | { | ||||||
| 	register int t; | 	register int t; | ||||||
| #ifdef	UNICOS7x |  | ||||||
| 	struct secstat secbuf; |  | ||||||
| #endif	/* UNICOS7x */ |  | ||||||
|  |  | ||||||
| #ifndef STREAMSPTY | #ifdef STREAMSPTY | ||||||
| 	/* | 	if (!really_stream) | ||||||
| 	 * Make sure that other people can't open the |  | ||||||
| 	 * slave side of the connection. |  | ||||||
| 	 */ |  | ||||||
| 	(void) chown(line, 0, 0); |  | ||||||
| 	(void) chmod(line, 0600); |  | ||||||
| #endif | #endif | ||||||
|  | 	{ | ||||||
|  | 		/* | ||||||
|  | 		 * Make sure that other people can't open the | ||||||
|  | 		 * slave side of the connection. | ||||||
|  | 		 */ | ||||||
|  | 		(void) chown(line, 0, 0); | ||||||
|  | 		(void) chmod(line, 0600); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| # if !defined(CRAY) && (BSD > 43) | # if !defined(CRAY) && (BSD > 43) | ||||||
| 	(void) revoke(line); | 	(void) revoke(line); | ||||||
| # endif | # endif | ||||||
| #ifdef	UNICOS7x |  | ||||||
| 	if (secflag) { |  | ||||||
| 		if (secstat(line, &secbuf) < 0) |  | ||||||
| 			return(-1); |  | ||||||
| 		if (setulvl(secbuf.st_slevel) < 0) |  | ||||||
| 			return(-1); |  | ||||||
| 		if (setucmp(secbuf.st_compart) < 0) |  | ||||||
| 			return(-1); |  | ||||||
| 	} |  | ||||||
| #endif	/* UNICOS7x */ |  | ||||||
|  |  | ||||||
| 	t = open(line, O_RDWR|O_NOCTTY); | 	t = open(line, O_RDWR|O_NOCTTY); | ||||||
|  |  | ||||||
| #ifdef	UNICOS7x |  | ||||||
| 	if (secflag) { |  | ||||||
| 		if (setulvl(sysv.sy_minlvl) < 0) |  | ||||||
| 			return(-1); |  | ||||||
| 		if (setucmp(0) < 0) |  | ||||||
| 			return(-1); |  | ||||||
| 	} |  | ||||||
| #endif	/* UNICOS7x */ |  | ||||||
|  |  | ||||||
| 	if (t < 0) | 	if (t < 0) | ||||||
| 		return(-1); | 		return(-1); | ||||||
|  |  | ||||||
| @@ -1209,28 +1150,8 @@ int cleanopen(char *line) | |||||||
| 		(void) ioctl(t, TCVHUP, (char *)0); | 		(void) ioctl(t, TCVHUP, (char *)0); | ||||||
| 		(void) signal(SIGHUP, SIG_DFL); | 		(void) signal(SIGHUP, SIG_DFL); | ||||||
|  |  | ||||||
| #ifdef	UNICOS7x |  | ||||||
| 		if (secflag) { |  | ||||||
| 			if (secstat(line, &secbuf) < 0) |  | ||||||
| 				return(-1); |  | ||||||
| 			if (setulvl(secbuf.st_slevel) < 0) |  | ||||||
| 				return(-1); |  | ||||||
| 			if (setucmp(secbuf.st_compart) < 0) |  | ||||||
| 				return(-1); |  | ||||||
| 		} |  | ||||||
| #endif	/* UNICOS7x */ |  | ||||||
|  |  | ||||||
| 		i = open(line, O_RDWR); | 		i = open(line, O_RDWR); | ||||||
|  |  | ||||||
| #ifdef	UNICOS7x |  | ||||||
| 		if (secflag) { |  | ||||||
| 			if (setulvl(sysv.sy_minlvl) < 0) |  | ||||||
| 				return(-1); |  | ||||||
| 			if (setucmp(0) < 0) |  | ||||||
| 				return(-1); |  | ||||||
| 		} |  | ||||||
| #endif	/* UNICOS7x */ |  | ||||||
|  |  | ||||||
| 		if (i < 0) | 		if (i < 0) | ||||||
| 			return(-1); | 			return(-1); | ||||||
| 		(void) close(t); | 		(void) close(t); | ||||||
| @@ -1239,7 +1160,6 @@ int cleanopen(char *line) | |||||||
| # endif	/* defined(CRAY) && defined(TCVHUP) */ | # endif	/* defined(CRAY) && defined(TCVHUP) */ | ||||||
| 	return(t); | 	return(t); | ||||||
| } | } | ||||||
| #endif	/* !defined(CRAY) || !defined(NEWINIT) */ |  | ||||||
|  |  | ||||||
| #if !defined(BSD4_4) | #if !defined(BSD4_4) | ||||||
|  |  | ||||||
| @@ -1300,10 +1220,6 @@ int login_tty(int t) | |||||||
| } | } | ||||||
| #endif	/* BSD <= 43 */ | #endif	/* BSD <= 43 */ | ||||||
|  |  | ||||||
| #ifdef	NEWINIT |  | ||||||
| char *gen_id = "fe"; |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * startslave(host) |  * startslave(host) | ||||||
|  * |  * | ||||||
| @@ -1317,12 +1233,6 @@ startslave(char *host, int autologin, char *autoname) | |||||||
| { | { | ||||||
| 	register int i; | 	register int i; | ||||||
| 	char name[256]; | 	char name[256]; | ||||||
| #ifdef	NEWINIT |  | ||||||
| 	extern char *ptyip; |  | ||||||
| 	struct init_request request; |  | ||||||
| 	void nologinproc(); |  | ||||||
| 	register int n; |  | ||||||
| #endif	/* NEWINIT */ |  | ||||||
|  |  | ||||||
| #if	defined(AUTHENTICATION) | #if	defined(AUTHENTICATION) | ||||||
| 	if (!autoname || !autoname[0]) | 	if (!autoname || !autoname[0]) | ||||||
| @@ -1343,7 +1253,6 @@ startslave(char *host, int autologin, char *autoname) | |||||||
| #endif | #endif | ||||||
| 	  writenet((unsigned char*)tbuf, strlen(tbuf)); | 	  writenet((unsigned char*)tbuf, strlen(tbuf)); | ||||||
|       } |       } | ||||||
| #ifndef	NEWINIT |  | ||||||
| # ifdef	PARENT_DOES_UTMP | # ifdef	PARENT_DOES_UTMP | ||||||
| 	utmp_sig_init(); | 	utmp_sig_init(); | ||||||
| # endif	/* PARENT_DOES_UTMP */ | # endif	/* PARENT_DOES_UTMP */ | ||||||
| @@ -1392,60 +1301,6 @@ startslave(char *host, int autologin, char *autoname) | |||||||
| 	  start_login(host, autologin, autoname); | 	  start_login(host, autologin, autoname); | ||||||
| 	  /*NOTREACHED*/ | 	  /*NOTREACHED*/ | ||||||
| 	} | 	} | ||||||
| #else	/* NEWINIT */ |  | ||||||
|  |  | ||||||
| 	/* |  | ||||||
| 	 * Init will start up login process if we ask nicely.  We only wait |  | ||||||
| 	 * for it to start up and begin normal telnet operation. |  | ||||||
| 	 */ |  | ||||||
| 	if ((i = open(INIT_FIFO, O_WRONLY)) < 0) { |  | ||||||
| 		char tbuf[128]; |  | ||||||
| 		(void) sprintf(tbuf, "Can't open %s\n", INIT_FIFO); |  | ||||||
| 		fatalperror(net, tbuf); |  | ||||||
| 	} |  | ||||||
| 	memset((char *)&request, 0, sizeof(request)); |  | ||||||
| 	request.magic = INIT_MAGIC; |  | ||||||
| 	SCPYN(request.gen_id, gen_id); |  | ||||||
| 	SCPYN(request.tty_id, &line[8]); |  | ||||||
| 	SCPYN(request.host, host); |  | ||||||
| 	SCPYN(request.term_type, terminaltype ? terminaltype : "network"); |  | ||||||
| #if	!defined(UNICOS5) |  | ||||||
| 	request.signal = SIGCLD; |  | ||||||
| 	request.pid = getpid(); |  | ||||||
| #endif |  | ||||||
| #ifdef BFTPDAEMON |  | ||||||
| 	/* |  | ||||||
| 	 * Are we working as the bftp daemon? |  | ||||||
| 	 */ |  | ||||||
| 	if (bftpd) { |  | ||||||
| 		SCPYN(request.exec_name, BFTPPATH); |  | ||||||
| 	} |  | ||||||
| #endif /* BFTPDAEMON */ |  | ||||||
| 	if (write(i, (char *)&request, sizeof(request)) < 0) { |  | ||||||
| 		char tbuf[128]; |  | ||||||
| 		(void) sprintf(tbuf, "Can't write to %s\n", INIT_FIFO); |  | ||||||
| 		fatalperror(net, tbuf); |  | ||||||
| 	} |  | ||||||
| 	(void) close(i); |  | ||||||
| 	(void) signal(SIGALRM, nologinproc); |  | ||||||
| 	for (i = 0; ; i++) { |  | ||||||
| 		char tbuf[128]; |  | ||||||
| 		alarm(15); |  | ||||||
| 		n = read(ourpty, ptyip, BUFSIZ); |  | ||||||
| 		if (i == 3 || n >= 0 || !gotalarm) |  | ||||||
| 			break; |  | ||||||
| 		gotalarm = 0; |  | ||||||
| 		sprintf(tbuf, "telnetd: waiting for /etc/init to start login process on %s\r\n", line); |  | ||||||
| 		(void) write(net, tbuf, strlen(tbuf)); |  | ||||||
| 	} |  | ||||||
| 	if (n < 0 && gotalarm) |  | ||||||
| 		fatal(net, "/etc/init didn't start login process"); |  | ||||||
| 	pcc += n; |  | ||||||
| 	alarm(0); |  | ||||||
| 	(void) signal(SIGALRM, SIG_DFL); |  | ||||||
|  |  | ||||||
| 	return; |  | ||||||
| #endif	/* NEWINIT */ |  | ||||||
| } | } | ||||||
|  |  | ||||||
| char	*envinit[3]; | char	*envinit[3]; | ||||||
| @@ -1468,8 +1323,6 @@ init_env(void) | |||||||
| 	environ = envinit; | 	environ = envinit; | ||||||
| } | } | ||||||
|  |  | ||||||
| #ifndef	NEWINIT |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * scrub_env() |  * scrub_env() | ||||||
|  * |  * | ||||||
| @@ -1589,16 +1442,6 @@ void start_login(char *host, int autologin, char *name) | |||||||
| 		setenv("LINEMODE", "kludge", 1); | 		setenv("LINEMODE", "kludge", 1); | ||||||
| # endif | # endif | ||||||
| #endif | #endif | ||||||
| #ifdef	BFTPDAEMON |  | ||||||
| 	/* |  | ||||||
| 	 * Are we working as the bftp daemon?  If so, then ask login |  | ||||||
| 	 * to start bftp instead of shell. |  | ||||||
| 	 */ |  | ||||||
| 	if (bftpd) { |  | ||||||
| 		addarg(&argv, "-e"); |  | ||||||
| 		addarg(&argv, BFTPPATH); |  | ||||||
| 	} else |  | ||||||
| #endif |  | ||||||
| #if	defined (SecurID) | #if	defined (SecurID) | ||||||
| 	/* | 	/* | ||||||
| 	 * don't worry about the -f that might get sent. | 	 * don't worry about the -f that might get sent. | ||||||
| @@ -1659,11 +1502,13 @@ void start_login(char *host, int autologin, char *name) | |||||||
| 			addarg(&argv, LOGIN_HOST); | 			addarg(&argv, LOGIN_HOST); | ||||||
|  |  | ||||||
| 			xpty = ourpty; | 			xpty = ourpty; | ||||||
| # ifndef  STREAMSPTY | #ifdef STREAMSPTY | ||||||
| 			pty = 0; | 			if (really_stream) | ||||||
| # else | 				ttyfd = 0; | ||||||
| 			ttyfd = 0; | 			else | ||||||
| # endif | #endif | ||||||
|  | 				pty = 0; | ||||||
|  |  | ||||||
| 			init_termbuf(); | 			init_termbuf(); | ||||||
| 			isecho = tty_isecho(); | 			isecho = tty_isecho(); | ||||||
| 			israw = tty_israw(); | 			israw = tty_israw(); | ||||||
| @@ -1769,8 +1614,6 @@ int addarg(struct arg_val *argv, char *val) | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| #endif	/* NEWINIT */ |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * rmut() |  * rmut() | ||||||
|  * |  * | ||||||
| @@ -1923,10 +1766,6 @@ rmut (char *line) | |||||||
| void | void | ||||||
| cleanup(int sig) | cleanup(int sig) | ||||||
| { | { | ||||||
| # ifdef	NEWINIT |  | ||||||
|     shutdown(net, 2); |  | ||||||
|     exit(1); |  | ||||||
| # else	/* NEWINIT */ |  | ||||||
| #  ifdef CRAY | #  ifdef CRAY | ||||||
|     static int incleanup = 0; |     static int incleanup = 0; | ||||||
|     register int t; |     register int t; | ||||||
| @@ -1960,17 +1799,6 @@ cleanup(int sig) | |||||||
|     } |     } | ||||||
|     incleanup = 1; |     incleanup = 1; | ||||||
|     sigsetmask(t); |     sigsetmask(t); | ||||||
| #ifdef	UNICOS7x |  | ||||||
|     if (secflag) { |  | ||||||
| 	/* |  | ||||||
| 	 *	We need to set ourselves back to a null |  | ||||||
| 	 *	label to clean up. |  | ||||||
| 	 */ |  | ||||||
| 	 |  | ||||||
| 	setulvl(sysv.sy_minlvl); |  | ||||||
| 	setucmp((long)0); |  | ||||||
|     } |  | ||||||
| #endif	/* UNICOS7x */ |  | ||||||
|      |      | ||||||
|     t = cleantmp(&wtmp); |     t = cleantmp(&wtmp); | ||||||
|     setutent();	/* just to make sure */ |     setutent();	/* just to make sure */ | ||||||
| @@ -1983,7 +1811,6 @@ cleanup(int sig) | |||||||
| 	cleantmp(&wtmp); | 	cleantmp(&wtmp); | ||||||
| #  endif /* CRAY */ | #  endif /* CRAY */ | ||||||
|     exit(1); |     exit(1); | ||||||
| # endif	/* NEWINT */ |  | ||||||
| } | } | ||||||
|  |  | ||||||
| #else /* PARENT_DOES_UTMP */ | #else /* PARENT_DOES_UTMP */ | ||||||
| @@ -2016,7 +1843,7 @@ cleanup(int sig) | |||||||
|  |  | ||||||
| #endif /* PARENT_DOES_UTMP */ | #endif /* PARENT_DOES_UTMP */ | ||||||
|  |  | ||||||
| #if defined(PARENT_DOES_UTMP) && !defined(NEWINIT) | #if defined(PARENT_DOES_UTMP) | ||||||
| /* | /* | ||||||
|  * _utmp_sig_rcv |  * _utmp_sig_rcv | ||||||
|  * utmp_sig_init |  * utmp_sig_init | ||||||
|   | |||||||
| @@ -153,15 +153,9 @@ char valid_opts[] = { | |||||||
| #ifdef	AUTHENTICATION | #ifdef	AUTHENTICATION | ||||||
| 	'a', ':', 'X', ':', | 	'a', ':', 'X', ':', | ||||||
| #endif | #endif | ||||||
| #ifdef BFTPDAEMON |  | ||||||
| 	'B', |  | ||||||
| #endif |  | ||||||
| #ifdef DIAGNOSTICS | #ifdef DIAGNOSTICS | ||||||
| 	'D', ':', | 	'D', ':', | ||||||
| #endif | #endif | ||||||
| #if	defined(CRAY) && defined(NEWINIT) |  | ||||||
| 	'I', ':', |  | ||||||
| #endif |  | ||||||
| #ifdef	LINEMODE | #ifdef	LINEMODE | ||||||
| 	'l', | 	'l', | ||||||
| #endif | #endif | ||||||
| @@ -241,12 +235,6 @@ int main(int argc, char **argv) | |||||||
| 			break; | 			break; | ||||||
| #endif	/* AUTHENTICATION */ | #endif	/* AUTHENTICATION */ | ||||||
|  |  | ||||||
| #ifdef BFTPDAEMON |  | ||||||
| 		case 'B': |  | ||||||
| 			bftpd++; |  | ||||||
| 			break; |  | ||||||
| #endif /* BFTPDAEMON */ |  | ||||||
|  |  | ||||||
| 		case 'd': | 		case 'd': | ||||||
| 			if (strcmp(optarg, "ebug") == 0) { | 			if (strcmp(optarg, "ebug") == 0) { | ||||||
| 				debug++; | 				debug++; | ||||||
| @@ -283,15 +271,6 @@ int main(int argc, char **argv) | |||||||
| 			hostinfo = 0; | 			hostinfo = 0; | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| #if	defined(CRAY) && defined(NEWINIT) |  | ||||||
| 		case 'I': |  | ||||||
| 		    { |  | ||||||
| 			extern char *gen_id; |  | ||||||
| 			gen_id = optarg; |  | ||||||
| 			break; |  | ||||||
| 		    } |  | ||||||
| #endif	/* defined(CRAY) && defined(NEWINIT) */ |  | ||||||
|  |  | ||||||
| #ifdef	LINEMODE | #ifdef	LINEMODE | ||||||
| 		case 'l': | 		case 'l': | ||||||
| 			alwayslinemode = 1; | 			alwayslinemode = 1; | ||||||
| @@ -555,9 +534,6 @@ usage() | |||||||
| 	fprintf(stderr, "Usage: telnetd"); | 	fprintf(stderr, "Usage: telnetd"); | ||||||
| #ifdef	AUTHENTICATION | #ifdef	AUTHENTICATION | ||||||
| 	fprintf(stderr, " [-a (debug|other|user|valid|off|none)]\n\t"); | 	fprintf(stderr, " [-a (debug|other|user|valid|off|none)]\n\t"); | ||||||
| #endif |  | ||||||
| #ifdef BFTPDAEMON |  | ||||||
| 	fprintf(stderr, " [-B]"); |  | ||||||
| #endif | #endif | ||||||
| 	fprintf(stderr, " [-debug]"); | 	fprintf(stderr, " [-debug]"); | ||||||
| #ifdef DIAGNOSTICS | #ifdef DIAGNOSTICS | ||||||
| @@ -567,9 +543,6 @@ usage() | |||||||
| 	fprintf(stderr, " [-edebug]"); | 	fprintf(stderr, " [-edebug]"); | ||||||
| #endif | #endif | ||||||
| 	fprintf(stderr, " [-h]"); | 	fprintf(stderr, " [-h]"); | ||||||
| #if	defined(CRAY) && defined(NEWINIT) |  | ||||||
| 	fprintf(stderr, " [-Iinitid]"); |  | ||||||
| #endif |  | ||||||
| #if	defined(LINEMODE) && defined(KLUDGELINEMODE) | #if	defined(LINEMODE) && defined(KLUDGELINEMODE) | ||||||
| 	fprintf(stderr, " [-k]"); | 	fprintf(stderr, " [-k]"); | ||||||
| #endif | #endif | ||||||
| @@ -937,21 +910,6 @@ void doit(struct sockaddr_in *who) | |||||||
| 	/*NOTREACHED*/ | 	/*NOTREACHED*/ | ||||||
| }  /* end of doit */ | }  /* end of doit */ | ||||||
|  |  | ||||||
| #if	defined(CRAY2) && defined(UNICOS5) && defined(UNICOS50) |  | ||||||
| 	int |  | ||||||
| Xterm_output(ibufp, obuf, icountp, ocount) |  | ||||||
| 	char **ibufp, *obuf; |  | ||||||
| 	int *icountp, ocount; |  | ||||||
| { |  | ||||||
| 	int ret; |  | ||||||
| 	ret = term_output(*ibufp, obuf, *icountp, ocount); |  | ||||||
| 	*ibufp += *icountp; |  | ||||||
| 	*icountp = 0; |  | ||||||
| 	return(ret); |  | ||||||
| } |  | ||||||
| #define	term_output	Xterm_output |  | ||||||
| #endif	/* defined(CRAY2) && defined(UNICOS5) && defined(UNICOS50) */ |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Main loop.  Select from pty and network, and |  * Main loop.  Select from pty and network, and | ||||||
|  * hand data to telnet receiver finite state machine. |  * hand data to telnet receiver finite state machine. | ||||||
| @@ -1075,12 +1033,13 @@ telnet(f, p, host) | |||||||
| 	if (my_state_is_wont(TELOPT_ECHO)) | 	if (my_state_is_wont(TELOPT_ECHO)) | ||||||
| 		send_will(TELOPT_ECHO, 1); | 		send_will(TELOPT_ECHO, 1); | ||||||
|  |  | ||||||
| #ifndef	STREAMSPTY | #ifdef	STREAMSPTY | ||||||
| 	/* | 	if (!really_stream) | ||||||
| 	 * Turn on packet mode |  | ||||||
| 	 */ |  | ||||||
| 	(void) ioctl(p, TIOCPKT, (char *)&on); |  | ||||||
| #endif | #endif | ||||||
|  | 		/* | ||||||
|  | 		 * Turn on packet mode | ||||||
|  | 		 */ | ||||||
|  | 		(void) ioctl(p, TIOCPKT, (char *)&on); | ||||||
|  |  | ||||||
| #if	defined(LINEMODE) && defined(KLUDGELINEMODE) | #if	defined(LINEMODE) && defined(KLUDGELINEMODE) | ||||||
| 	/* | 	/* | ||||||
| @@ -1101,9 +1060,6 @@ telnet(f, p, host) | |||||||
|  |  | ||||||
| 	(void) ioctl(f, FIONBIO, (char *)&on); | 	(void) ioctl(f, FIONBIO, (char *)&on); | ||||||
| 	(void) ioctl(p, FIONBIO, (char *)&on); | 	(void) ioctl(p, FIONBIO, (char *)&on); | ||||||
| #if	defined(CRAY2) && defined(UNICOS5) |  | ||||||
| 	init_termdriver(f, p, interrupt, sendbrk); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #if	defined(SO_OOBINLINE) | #if	defined(SO_OOBINLINE) | ||||||
| 	(void) setsockopt(net, SOL_SOCKET, SO_OOBINLINE, | 	(void) setsockopt(net, SOL_SOCKET, SO_OOBINLINE, | ||||||
| @@ -1123,21 +1079,6 @@ telnet(f, p, host) | |||||||
|  |  | ||||||
| 	(void) signal(SIGCHLD, cleanup); | 	(void) signal(SIGCHLD, cleanup); | ||||||
|  |  | ||||||
| #if	defined(CRAY2) && defined(UNICOS5) |  | ||||||
| 	/* |  | ||||||
| 	 * Cray-2 will send a signal when pty modes are changed by slave |  | ||||||
| 	 * side.  Set up signal handler now. |  | ||||||
| 	 */ |  | ||||||
| 	if ((int)signal(SIGUSR1, termstat) < 0) |  | ||||||
| 		perror("signal"); |  | ||||||
| 	else if (ioctl(p, TCSIGME, (char *)SIGUSR1) < 0) |  | ||||||
| 		perror("ioctl:TCSIGME"); |  | ||||||
| 	/* |  | ||||||
| 	 * Make processing loop check terminal characteristics early on. |  | ||||||
| 	 */ |  | ||||||
| 	termstat(); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef  TIOCNOTTY | #ifdef  TIOCNOTTY | ||||||
| 	{ | 	{ | ||||||
| 		register int t; | 		register int t; | ||||||
| @@ -1149,11 +1090,6 @@ telnet(f, p, host) | |||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if	defined(CRAY) && defined(NEWINIT) && defined(TIOCSCTTY) |  | ||||||
| 	(void) setsid(); |  | ||||||
| 	ioctl(p, TIOCSCTTY, 0); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * Show banner that getty never gave. | 	 * Show banner that getty never gave. | ||||||
| 	 * | 	 * | ||||||
| @@ -1162,10 +1098,8 @@ telnet(f, p, host) | |||||||
| 	 * other pty --> client data. | 	 * other pty --> client data. | ||||||
| 	 */ | 	 */ | ||||||
|  |  | ||||||
| #if	!defined(CRAY) || !defined(NEWINIT) |  | ||||||
| 	if (getenv("USER")) | 	if (getenv("USER")) | ||||||
| 		hostinfo = 0; | 		hostinfo = 0; | ||||||
| #endif |  | ||||||
|  |  | ||||||
| 	if (getent(defent, "default") == 1) { | 	if (getent(defent, "default") == 1) { | ||||||
| 		char *getstr(); | 		char *getstr(); | ||||||
| @@ -1214,10 +1148,6 @@ telnet(f, p, host) | |||||||
| 		if (ncc < 0 && pcc < 0) | 		if (ncc < 0 && pcc < 0) | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| #if	defined(CRAY2) && defined(UNICOS5) |  | ||||||
| 		if (needtermstat) |  | ||||||
| 			_termstat(); |  | ||||||
| #endif	/* defined(CRAY2) && defined(UNICOS5) */ |  | ||||||
| 		FD_ZERO(&ibits); | 		FD_ZERO(&ibits); | ||||||
| 		FD_ZERO(&obits); | 		FD_ZERO(&obits); | ||||||
| 		FD_ZERO(&xbits); | 		FD_ZERO(&xbits); | ||||||
| @@ -1335,11 +1265,13 @@ telnet(f, p, host) | |||||||
| 		 * Something to read from the pty... | 		 * Something to read from the pty... | ||||||
| 		 */ | 		 */ | ||||||
| 		if (FD_ISSET(p, &ibits)) { | 		if (FD_ISSET(p, &ibits)) { | ||||||
| #ifndef	STREAMSPTY | #ifdef STREAMSPTY | ||||||
| 			pcc = read(p, ptyibuf, BUFSIZ); | 			if (really_stream) | ||||||
| #else | 				pcc = readstream(p, ptyibuf, BUFSIZ); | ||||||
| 			pcc = readstream(p, ptyibuf, BUFSIZ); | 			else | ||||||
| #endif | #endif | ||||||
|  | 				pcc = read(p, ptyibuf, BUFSIZ); | ||||||
|  |  | ||||||
| 			/* | 			/* | ||||||
| 			 * On some systems, if we try to read something | 			 * On some systems, if we try to read something | ||||||
| 			 * off the master side before the slave side is | 			 * off the master side before the slave side is | ||||||
| @@ -1354,7 +1286,6 @@ telnet(f, p, host) | |||||||
| 			} else { | 			} else { | ||||||
| 				if (pcc <= 0) | 				if (pcc <= 0) | ||||||
| 					break; | 					break; | ||||||
| #if	!defined(CRAY2) || !defined(UNICOS5) |  | ||||||
| #ifdef	LINEMODE | #ifdef	LINEMODE | ||||||
| 				/* | 				/* | ||||||
| 				 * If ioctl from pty, pass it through net | 				 * If ioctl from pty, pass it through net | ||||||
| @@ -1403,16 +1334,6 @@ telnet(f, p, host) | |||||||
| 				} | 				} | ||||||
| 				pcc--; | 				pcc--; | ||||||
| 				ptyip = ptyibuf+1; | 				ptyip = ptyibuf+1; | ||||||
| #else	/* defined(CRAY2) && defined(UNICOS5) */ |  | ||||||
| 				if (!uselinemode) { |  | ||||||
| 					unpcc = pcc; |  | ||||||
| 					unptyip = ptyibuf; |  | ||||||
| 					pcc = term_output(&unptyip, ptyibuf2, |  | ||||||
| 								&unpcc, BUFSIZ); |  | ||||||
| 					ptyip = ptyibuf2; |  | ||||||
| 				} else |  | ||||||
| 					ptyip = ptyibuf; |  | ||||||
| #endif	/* defined(CRAY2) && defined(UNICOS5) */ |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -1422,11 +1343,6 @@ telnet(f, p, host) | |||||||
| 			c = *ptyip++ & 0377, pcc--; | 			c = *ptyip++ & 0377, pcc--; | ||||||
| 			if (c == IAC) | 			if (c == IAC) | ||||||
| 				*nfrontp++ = c; | 				*nfrontp++ = c; | ||||||
| #if	defined(CRAY2) && defined(UNICOS5) |  | ||||||
| 			else if (c == '\n' && |  | ||||||
| 				     my_state_is_wont(TELOPT_BINARY) && newmap) |  | ||||||
| 				*nfrontp++ = '\r'; |  | ||||||
| #endif	/* defined(CRAY2) && defined(UNICOS5) */ |  | ||||||
| 			*nfrontp++ = c; | 			*nfrontp++ = c; | ||||||
| 			if ((c == '\r') && (my_state_is_wont(TELOPT_BINARY))) { | 			if ((c == '\r') && (my_state_is_wont(TELOPT_BINARY))) { | ||||||
| 				if (pcc > 0 && ((*ptyip & 0377) == '\n')) { | 				if (pcc > 0 && ((*ptyip & 0377) == '\n')) { | ||||||
| @@ -1436,17 +1352,6 @@ telnet(f, p, host) | |||||||
| 					*nfrontp++ = '\0'; | 					*nfrontp++ = '\0'; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| #if	defined(CRAY2) && defined(UNICOS5) |  | ||||||
| 		/* |  | ||||||
| 		 * If chars were left over from the terminal driver, |  | ||||||
| 		 * note their existence. |  | ||||||
| 		 */ |  | ||||||
| 		if (!uselinemode && unpcc) { |  | ||||||
| 			pcc = unpcc; |  | ||||||
| 			unpcc = 0; |  | ||||||
| 			ptyip = unptyip; |  | ||||||
| 		} |  | ||||||
| #endif	/* defined(CRAY2) && defined(UNICOS5) */ |  | ||||||
|  |  | ||||||
| 		if (FD_ISSET(f, &obits) && (nfrontp - nbackp) > 0) | 		if (FD_ISSET(f, &obits) && (nfrontp - nbackp) > 0) | ||||||
| 			netflush(); | 			netflush(); | ||||||
| @@ -1569,6 +1474,7 @@ interrupt() | |||||||
|  |  | ||||||
| #if defined(STREAMSPTY) && defined(TIOCSIGNAL) | #if defined(STREAMSPTY) && defined(TIOCSIGNAL) | ||||||
| 	/* Streams PTY style ioctl to post a signal */ | 	/* Streams PTY style ioctl to post a signal */ | ||||||
|  | 	if (really_stream) | ||||||
| 	{ | 	{ | ||||||
| 		int sig = SIGINT; | 		int sig = SIGINT; | ||||||
| 		(void) ioctl(ourpty, TIOCSIGNAL, &sig); | 		(void) ioctl(ourpty, TIOCSIGNAL, &sig); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Assar Westerlund
					Assar Westerlund