From f24591ec633bd7abb33bc70deebdeb2c4ed70bca Mon Sep 17 00:00:00 2001 From: Bryan Stansell Date: Wed, 13 Jan 1999 14:38:26 -0800 Subject: [PATCH] Imported from conserver-GNAC-6.06.tar.gz --- conserver.cf/test.cf | 6 +- conserver/Makefile | 108 +++++-------- conserver/access.c | 9 +- conserver/access.h | 8 +- conserver/client.c | 9 +- conserver/client.h | 8 +- conserver/cons-gnac.h | 349 +---------------------------------------- conserver/cons-test.h | 346 +--------------------------------------- conserver/cons.h | 2 +- conserver/consent.c | 11 +- conserver/consent.h | 8 +- conserver/fallback.c | 9 +- conserver/group.c | 40 ++++- conserver/group.h | 8 +- conserver/identd.c | 179 --------------------- conserver/main.c | 11 +- conserver/main.h | 8 +- conserver/master.c | 32 +++- conserver/master.h | 8 +- conserver/port.h | 357 ++++++++++++++++++++++++++++++++++++++++++ conserver/readcfg.c | 9 +- conserver/readcfg.h | 8 +- conserver/version.h | 10 +- console/Makefile | 78 ++++----- console/console.c | 11 +- 25 files changed, 621 insertions(+), 1011 deletions(-) delete mode 100644 conserver/identd.c create mode 100644 conserver/port.h diff --git a/conserver.cf/test.cf b/conserver.cf/test.cf index 56ab590..ca1e844 100644 --- a/conserver.cf/test.cf +++ b/conserver.cf/test.cf @@ -15,8 +15,10 @@ # name : tty[@host] : baud[parity] : device : group DOMAINHACK= LOGDIR=/tmp -login3:|:9600p:&:10m -test:!ts4:10002:&:1m +ts6-10:!ts6:10010:&: +ts6-11:!ts6:10011:&: +ts6-12:!ts6:10012:&: +ts6-13:!ts6:10013:&: %% # list of clients we allow # type machines diff --git a/conserver/Makefile b/conserver/Makefile index 890e0c4..78300ef 100644 --- a/conserver/Makefile +++ b/conserver/Makefile @@ -1,31 +1,21 @@ -# $Id: Makefile,v 1.3 1998-11-17 23:45:05-08 bryan Exp $ +# $Id: Makefile,v 1.7 1999-01-13 14:15:46-08 bryan Exp $ # # Makefile for console server # -# two steps (1) and (2) -# (1) change ETC below to where you would like the console server installed -# I would not change the name, you have to much with the docs then... PROG= conserver -ETC= ${DESTDIR}/usr/local/etc -DOC= ${DESTDIR}/usr/local/man - -# if we have to PUCC ptyd daemon we can use it to get ptys, else use fallback.o -# and change the CDEFS line below to =0 -FALLBACK=fallback.o -PUCCLIB= -#FALLBACK= -#PUCCLIB=-lpucc - -I=/usr/include -S=/usr/include/sys -L=/usr/local/include -P= +PREFIX=/usr/local +BIN=${PREFIX}/bin +ETC=${PREFIX}/etc +MAN=${PREFIX}/man +MANSECT=8 +INSTALL=/usr/ucb/install INCLUDE= DEBUG=-O -CDEFS= -DSUN5 -DHAVE_PTYD=0 -DDO_VIRTUAL=1 +CDEFS= CFLAGS= ${DEBUG} ${CDEFS} ${INCLUDE} +LIBS=-lsocket -lnsl HDR= cons.h \ access.h client.h consent.h group.h main.h master.h \ @@ -33,77 +23,53 @@ HDR= cons.h \ SRC= access.c client.c consent.c group.c main.c master.c \ readcfg.c fallback.c OBJ= access.o client.o consent.o group.o main.o master.o \ - readcfg.o ${FALLBACK} -MAN= conserver.man -OTHER= README Sun-serial -SOURCE= Makefile ${OTHER} ${MAN} ${HDR} ${SRC} + readcfg.o fallback.o +INIT= init.script all: ${PROG} -${PROG}:$P ${OBJ} - ${CC} -o $@ ${CFLAGS} ${OBJ} ${PUCCLIB} -lsocket -lnsl +${PROG}: ${OBJ} + ${CC} -o $@ ${CFLAGS} ${OBJ} ${LIBS} clean: FRC rm -f Makefile.bak ${PROG} a.out *.o core errs lint.out tags -deinstall: ${MAN} ${DOC} FRC - install -R ${ETC}/${PROG} - mkcat -r${DOC} -D ${MAN} - depend: ${HDR} ${SRC} FRC - maketd ${CDEFS} ${INCLUDE} ${SRC} + makedepend ${CDEFS} ${INCLUDE} ${SRC} -dirs: ${ETC} ${LIB} +dirs: ${BIN} ${ETC} -distrib: FRC - distrib -c ${ETC}/${PROG} +install: all dirs ${INIT} FRC + ${INSTALL} -cs ${PROG} ${BIN}/${PROG} + ${INSTALL} -c ${INIT} ${ETC}/${INIT} -install: all dirs FRC - install -c -s ${PROG} ${ETC}/${PROG} +${MAN}/man${MANSECT}: + ${INSTALL} -d $@ + +install.man: ${MAN}/man${MANSECT} + ${INSTALL} -c conserver.man ${MAN}/man${MANSECT}/conserver.${MANSECT} lint: ${HDR} ${SRC} FRC lint -h ${CDEFS} ${INCLUDE} ${SRC} -mkcat: ${MAN} ${DOC} FRC - mkcat -r${DOC} ${MAN} - -print: source FRC - lpr -J"${PROG} source" ${SOURCE} - -source: ${SOURCE} - -spotless: clean - rcsclean ${SOURCE} - tags: ${HDR} ${SRC} ctags -t ${HDR} ${SRC} -/ ${ETC} ${LIB}: - install -dr $@ - -${SOURCE}: - co -q $@ +/ ${BIN} ${ETC}: + ${INSTALL} -d $@ FRC: -# DO NOT DELETE THIS LINE - maketd DEPENDS ON IT +# DO NOT DELETE THIS LINE -- make depend depends on it. -access.o: access.c access.h client.h cons.h consent.h group.h main.h readcfg.h - -client.o: client.c client.h cons.h consent.h - -consent.o: client.h cons.h consent.c consent.h main.h - -group.o: access.h client.h cons.h consent.h group.c group.h main.h version.h - -main.o: access.h client.h cons.h consent.h group.h main.c master.h readcfg.h version.h - -master.o: access.h client.h cons.h consent.h group.h main.h master.c master.h \ - readcfg.h version.h - -readcfg.o: access.h client.h cons.h consent.h group.h main.h master.h \ - readcfg.c readcfg.h - -fallback.o: fallback.c - -# *** Do not add anything here - It will go away. *** +access.o: cons.h port.h access.h consent.h client.h group.h readcfg.h main.h +client.o: cons.h port.h consent.h client.h +consent.o: cons.h port.h consent.h client.h main.h +fallback.o: cons.h port.h +group.o: cons.h port.h consent.h client.h access.h group.h version.h main.h +main.o: cons.h port.h consent.h client.h group.h master.h access.h readcfg.h +main.o: version.h +master.o: cons.h port.h consent.h client.h group.h access.h master.h +master.o: readcfg.h version.h main.h +readcfg.o: cons.h port.h consent.h client.h group.h access.h readcfg.h +readcfg.o: master.h main.h diff --git a/conserver/access.c b/conserver/access.c index 7cceafb..e55c4fd 100644 --- a/conserver/access.c +++ b/conserver/access.c @@ -1,6 +1,12 @@ /* - * $Id: access.c,v 5.9 1993-05-17 07:36:01-07 ksb Exp $ + * $Id: access.c,v 5.11 1999-01-13 11:48:11-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * @@ -48,6 +54,7 @@ static char copyright[] = #include #include "cons.h" +#include "port.h" #include "access.h" #include "consent.h" #include "client.h" diff --git a/conserver/access.h b/conserver/access.h index 9b466cb..e258be0 100644 --- a/conserver/access.h +++ b/conserver/access.h @@ -1,6 +1,12 @@ /* - * $Id: access.h,v 5.6 1993-02-09 03:53:43-08 ldv Exp $ + * $Id: access.h,v 5.7 1998-12-17 17:20:37-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * diff --git a/conserver/client.c b/conserver/client.c index 0fa92c6..2c8ce59 100644 --- a/conserver/client.c +++ b/conserver/client.c @@ -1,6 +1,12 @@ /* - * $Id: client.c,v 5.18 1998-11-19 14:32:20-08 bryan Exp $ + * $Id: client.c,v 5.20 1999-01-13 11:48:11-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * @@ -47,6 +53,7 @@ static char copyright[] = #include #include "cons.h" +#include "port.h" #include "consent.h" #include "client.h" diff --git a/conserver/client.h b/conserver/client.h index 2908367..2c1fadf 100644 --- a/conserver/client.h +++ b/conserver/client.h @@ -1,6 +1,12 @@ /* - * $Id: client.h,v 5.10 1998-11-18 00:17:12-08 bryan Exp $ + * $Id: client.h,v 5.11 1998-12-17 17:20:37-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * diff --git a/conserver/cons-gnac.h b/conserver/cons-gnac.h index 2ae9e65..03c4597 100644 --- a/conserver/cons-gnac.h +++ b/conserver/cons-gnac.h @@ -1,350 +1,9 @@ /* - * $Id: cons-gnac.h,v 5.38 1998-11-17 18:43:39-08 bryan Exp $ + * $Id: cons-gnac.h,v 5.41 1999-01-13 11:50:33-08 bryan Exp $ * - * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana - * 47907. All rights reserved. + * GNAC, Inc., 1998 * - * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb - * - * This software is not subject to any license of the American Telephone - * and Telegraph Company or the Regents of the University of California. - * - * Permission is granted to anyone to use this software for any purpose on - * any computer system, and to alter it and redistribute it freely, subject - * to the following restrictions: - * - * 1. Neither the authors nor Purdue University are responsible for any - * consequences of the use of this software. - * - * 2. The origin of this software must not be misrepresented, either by - * explicit claim or by omission. Credit to the authors and Purdue - * University must appear in documentation and sources. - * - * 3. Altered versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 4. This notice may not be removed or altered. + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) */ -/* - * this is the configuration file for the Ohio State/PUCC console - * server. Just define the macros below to somehting that looks good - * and give it a go. It'll complain (under conserver -V) if things - * look really bad. - * - * all PTX, PTX2, and PTX4 code added by gregf@sequent.com (gregf) - */ -/* #define IBMR2 1 /**/ -/* #define HPUX7 1 /**/ -/* #define SUN4 1 /**/ -/* #define SUN5 1 /**/ -/* #define PTX2 1 /* DYNIX/ptx v2.X */ -/* #define PTX4 1 /* DYNIX/ptx v4.0 */ - -#if (defined(PTX2) || defined(PTX4)) -#define PTX -#endif - -/* some machine specific details - */ -#if !defined(USE_OLDSEL) -#if defined(IBMR2) -#include -#endif -#endif -#if !defined(HAVE_UWAIT) -#define HAVE_UWAIT !(defined(IBMR2)||defined(SUN5)||defined(HPUX8)||defined(HPUX9)||defined(PTX)||defined(IRIX5)) -#endif - -#if !defined(HAVE_WAIT3) -#define HAVE_WAIT3 !(defined(SUN5)||defined(PTX)) -#endif - -/* This is the port number used in the connection. It can use either - * /etc/services or a hardcoded port (SERVICE name has precedence). - * (You can -D one in the Makefile to override these.) - */ -/* #define PORT 782 /* only if you cannot put in /etc/services */ -#if !defined(SERVICE) -#if !defined(PORT) -#define SERVICE "conserver" -#endif -#endif - -/* Wait for a part of a second before slapping console server. - * Good for CISCO terminal servers that get upset when you - * attack with intense socket connections - */ -#if !defined(USLEEP_FOR_SLOW_PORTS) -#define USLEEP_FOR_SLOW_PORTS 100000 -#endif - -/* The name of the host which will act as the console server - */ -#if !defined(HOST) -#define HOST "console" -#endif - -/* the default escape sequence used to give meta commands - */ -#define DEFATTN '\005' -#define DEFESC 'c' - -/* Location of the configuration file - */ -#if !defined(CONFIG) -#define CONFIG "/etc/conserver.cf" -#endif - -/* Location of ANL designed passwd file */ -#if !defined(PASSWD_FILE) -#define PASSWD_FILE "/etc/conserver.passwd" -#endif - -/* The maximum number of serial lines that can be handled by a child process - */ -#if !defined(MAXMEMB) -#define MAXMEMB 8 -#endif - - -/* The maximum number of child processes spawned. - */ -#if !defined(MAXGRP) -#define MAXGRP 32 -#endif - -/* the max number of characters conserver will replay for you (the r command) - */ -#if !defined(MAXREPLAY) -#define MAXREPLAY (80*25) -#endif - -/* if the encrypted passwd is in a shadow file, define HAVE_SHADOW (gregf) - */ -#if !defined(HAVE_SHADOW) -#define HAVE_SHADOW (defined(PTX)||defined(SUN5)) -#endif - -/* we'd like to line buffer our output, if we know how - */ -#if !defined(USE_SETLINEBUF) -#define USE_SETLINEBUF (!(defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(PTX))) -#endif - -/* we'd like to line buffer our output, if we know how; PTX uses setvbuf (gregf) - */ -#if !defined(USE_SETVBUF) -#define USE_SETVBUF (defined(PTX)) -#endif - -/* hpux doesn't have getdtablesize() and they don't provide a macro - * in non-KERNEL cpp mode - */ -#if defined(HPUX7)||defined(HPUX8)||defined(HPUX9) -#define getdtablesize() 64 -#endif - -/* the console server will provide a pseudo-device console which - * allows operators to run backups and such without a hard wired - * line (this is also good for testing the server to see if you - * might wanna use it). Turn this on only if you (might) need it. - */ -#if !defined(DO_VIRTUAL) -#define DO_VIRTUAL 1 -#endif - -#if DO_VIRTUAL -/* if the virtual console option is on we need a source to ptys, - * the PUCC ptyd daemon is the best source be know, else fall back - * on some emulation code?? (XXX) - */ -#if !defined(HAVE_PTYD) -#define HAVE_PTYD (defined(S81)||defined(VAX8800)) -#endif - -#if !defined(HAVE_GETPSEUDO) -#define HAVE_GETPSEUDO (defined(PTX2)) -#endif - -#if !defined(HAVE_PTSNAME) -#define HAVE_PTSNAME (defined(PTX4)) -#endif - -#if !defined(HAVE_LDTERM) -#define HAVE_LDTERM (defined(SUN5)) -#endif - -#if !defined(HAVE_STTY_LD) -#define HAVE_STTY_LD (defined(IRIX5)) -#endif - -#endif /* virtual (process on a pseudo-tty) console support */ - -#if !defined(HAVE_SETSID) -#define HAVE_SETSID (defined(IBMR2)||defined(SUN5)||defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(PTX)||defined(IRIX5)) -#endif - -/* should we use flock to keep multiple conservers from hurting each other? - * PTX has lockf... should probably port code to work with this (gregf) - */ -#if !defined(USE_FLOCK) -#define USE_FLOCK (!(defined(IBMR2)||defined(SUN5)||defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(PTX))) -#endif - -/* should we try to pop streams modules off? - */ -#if !defined(USE_STREAMS) -#define USE_STREAMS (defined(SUN4)||defined(SUN5)||defined(PTX)||defined(IRIX5)) -#endif - -/* if we do not have old style tty emulation use termios.h - */ -#if !defined(USE_TERMIO) -#define USE_TERMIO (defined(ETA10)||defined(V386)) -#endif -#if !defined(USE_TERMIOS) -#define USE_TERMIOS (defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(SUN5)||defined(PTX)||defined(IRIX5)) -#endif -#if !defined(USE_TCBREAK) -#define USE_TCBREAK (defined(SUN4)||defined(PTX)) -#endif - -/* if we have define this to 1, else define to 0 - */ -#if !defined(USE_STRINGS) -#define USE_STRINGS (defined(SUN4)||defined(DYNIX)||defined(EPIX)||defined(IRIX5)) -#endif - -#if !defined(NEED_UNISTD_H) -#define NEED_UNISTD_H (defined(SUN5)||defined(PTX)) -#endif - -#if !defined(USE_SYS_TIME_H) -#define USE_SYS_TIME_H (!defined(PTX)) -#endif - -#if USE_STRINGS -#define strchr index -#define strrchr rindex -#endif - -/* used to force the server process to clear parity, which is for farmers - */ -#define CPARITY 1 - - -/* if you do not have fd_set's here is a possible emulation - */ -#if USE_OLDSEL -typedef long fd_set; - -#define FD_ZERO(a) {*(a)=0;} -#define FD_SET(d,a) {*(a) |= (1 << (d));} -#define FD_CLR(d,a) {*(a) &= ~(1 << (d));} -#define FD_ISSET(d,a) (*(a) & (1 << (d))) -#endif - -#if USE_TERMIOS -#if defined(HPUX7)||defined(HPUX8)||defined(HPUX9) -#define TCGETS _IOR('T', 16, struct termios) -#define TCSETS _IOW('T', 17, struct termios) -#endif -#if defined(PTX2) -#define TCGETS TCGETP -#define TCSETS TCSETP -#endif -#endif - -/* which type does wait(2) take for status location - */ -#if HAVE_UWAIT -#define WAIT_T union wait -#if ! defined WEXITSTATUS -#define WEXITSTATUS(x) ((x).w_retcode) -#endif -#else -#define WAIT_T int -#endif - -/* which type signal handlers return on this machine - */ -#if defined(sun) || defined(NEXT2) || defined(SUN5) || defined(PTX) || defined(IRIX5) -#define SIGRETS void -#else -#define SIGRETS int -#endif - -/* do we have a (working) setsockopt call - */ -#if !defined(HAVE_SETSOCKOPT) -#define HAVE_SETSOCKOPT (defined(sun)||defined(PTX)) -#endif - -/* does this system have the ANSI strerror() function? - */ -#if !defined(HAVE_STRERROR) -#define HAVE_STRERROR (defined(IBMR2)||defined(ETA10)||defined(V386)||defined(SUN5)||defined(NEXT2)||defined(HPUX8)||defined(HPUX9)||defined(PTX)||defined(IRIX5)) -#endif -#if ! HAVE_STRERROR -extern int errno; -extern char *sys_errlist[]; -#define strerror(Me) (sys_errlist[Me]) -#endif - -#if !defined(HAVE_H_ERRLIST) -#define HAVE_H_ERRLIST (defined(SUN4)||defined(SUN3)||defined(FREEBSD)|defined(NETBSD)||defined(PTX)||defined(IRIX5)) -#endif -#if HAVE_H_ERRLIST -extern int h_errno; -extern char *h_errlist[]; -#define hstrerror(Me) (h_errlist[Me]) -#else -#define hstrerror(Me) "host lookup error" -#endif - -#if !defined(HAVE_RLIMIT) -#if (defined(SUN5)||defined(PTX4)) -#define HAVE_RLIMIT 1 -#else -#define HAVE_RLIMIT 0 -#endif -#endif - -/* that's all. just run - * make - * ./conserver -V - */ - -/* communication constants - */ -#define OB_SUSP 'Z' /* suspended by server */ -#define OB_DROP '.' /* dropped by server */ - -/* Due to C's poor man's macros the macro below would break if statements, - * What we want - * macro() { stuff } - * but the syntax gives us - * macro() { stuff }; - * - * the extra semicolon breaks if statements! - * Of course, the one we use makes lint scream: - * macro() do { stuff } while (0) - * - * which is a statement and makes if statements safe - */ -#if defined(lint) -extern int shut_up_lint; -#else -#define shut_up_lint 0 -#endif - -/* this macro efficently outputs a constant string to a fd - * of course it doesn't check the write :-( - */ -#define CSTROUT(Mfd, Mstr) do { \ - static char _ac[] = Mstr; \ - write(Mfd, _ac, sizeof(_ac)-1); \ - } while (shut_up_lint) - -extern char *calloc(), *malloc(), *realloc(); +#define SUN5 1 diff --git a/conserver/cons-test.h b/conserver/cons-test.h index 2d9d893..1dc3373 100644 --- a/conserver/cons-test.h +++ b/conserver/cons-test.h @@ -1,351 +1,13 @@ /* - * $Id: cons-gnac.h,v 5.35 1997-02-23 18:32:38-08 bryan Exp $ + * $Id: cons-test.h,v 1.3 1999-01-13 11:57:17-08 bryan Exp $ * - * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana - * 47907. All rights reserved. + * GNAC, Inc., 1998 * - * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb - * - * This software is not subject to any license of the American Telephone - * and Telegraph Company or the Regents of the University of California. - * - * Permission is granted to anyone to use this software for any purpose on - * any computer system, and to alter it and redistribute it freely, subject - * to the following restrictions: - * - * 1. Neither the authors nor Purdue University are responsible for any - * consequences of the use of this software. - * - * 2. The origin of this software must not be misrepresented, either by - * explicit claim or by omission. Credit to the authors and Purdue - * University must appear in documentation and sources. - * - * 3. Altered versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 4. This notice may not be removed or altered. + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) */ -/* - * this is the configuration file for the Ohio State/PUCC console - * server. Just define the macros below to somehting that looks good - * and give it a go. It'll complain (under conserver -V) if things - * look really bad. - * - * all PTX, PTX2, and PTX4 code added by gregf@sequent.com (gregf) - */ -/* #define IBMR2 1 /**/ -/* #define HPUX7 1 /**/ -/* #define SUN4 1 /**/ -/* #define SUN5 1 /**/ -/* #define PTX2 1 /* DYNIX/ptx v2.X */ -/* #define PTX4 1 /* DYNIX/ptx v4.0 */ - -#if (defined(PTX2) || defined(PTX4)) -#define PTX -#endif - -/* some machine specific details - */ -#if !defined(USE_OLDSEL) -#if defined(IBMR2) -#include -#endif -#endif -#if !defined(HAVE_UWAIT) -#define HAVE_UWAIT !(defined(IBMR2)||defined(SUN5)||defined(HPUX8)||defined(HPUX9)||defined(PTX)||defined(IRIX5)) -#endif - -#if !defined(HAVE_WAIT3) -#define HAVE_WAIT3 !(defined(SUN5)||defined(PTX)) -#endif - -/* This is the port number used in the connection. It can use either - * /etc/services or a hardcoded port (SERVICE name has precedence). - * (You can -D one in the Makefile to override these.) - */ -/* #define PORT 782 /* only if you cannot put in /etc/services */ +#define SUN5 1 #define PORT 7777 -#if !defined(SERVICE) -#if !defined(PORT) -#define SERVICE "conserver" -#endif -#endif - -/* Wait for a part of a second before slapping console server. - * Good for CISCO terminal servers that get upset when you - * attack with intense socket connections - */ -#if !defined(USLEEP_FOR_SLOW_PORTS) -#define USLEEP_FOR_SLOW_PORTS 100000 -#endif - -/* The name of the host which will act as the console server - */ -#if !defined(HOST) #define HOST "localhost" -#endif - -/* the default escape sequence used to give meta commands - */ -#define DEFATTN '\005' -#define DEFESC 'c' - -/* Location of the configuration file - */ -#if !defined(CONFIG) #define CONFIG "../conserver.cf/test.cf" -#endif - -/* Location of ANL designed passwd file */ -#if !defined(PASSWD_FILE) #define PASSWD_FILE "./conserver.passwd" -#endif - -/* The maximum number of serial lines that can be handled by a child process - */ -#if !defined(MAXMEMB) -#define MAXMEMB 8 -#endif - - -/* The maximum number of child processes spawned. - */ -#if !defined(MAXGRP) -#define MAXGRP 32 -#endif - -/* the max number of characters conserver will replay for you (the r command) - */ -#if !defined(MAXREPLAY) -#define MAXREPLAY (80*25) -#endif - -/* if the encrypted passwd is in a shadow file, define HAVE_SHADOW (gregf) - */ -#if !defined(HAVE_SHADOW) -#define HAVE_SHADOW (defined(PTX)||defined(SUN5)) -#endif - -/* we'd like to line buffer our output, if we know how - */ -#if !defined(USE_SETLINEBUF) -#define USE_SETLINEBUF (!(defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(PTX))) -#endif - -/* we'd like to line buffer our output, if we know how; PTX uses setvbuf (gregf) - */ -#if !defined(USE_SETVBUF) -#define USE_SETVBUF (defined(PTX)) -#endif - -/* hpux doesn't have getdtablesize() and they don't provide a macro - * in non-KERNEL cpp mode - */ -#if defined(HPUX7)||defined(HPUX8)||defined(HPUX9) -#define getdtablesize() 64 -#endif - -/* the console server will provide a pseudo-device console which - * allows operators to run backups and such without a hard wired - * line (this is also good for testing the server to see if you - * might wanna use it). Turn this on only if you (might) need it. - */ -#if !defined(DO_VIRTUAL) -#define DO_VIRTUAL 1 -#endif - -#if DO_VIRTUAL -/* if the virtual console option is on we need a source to ptys, - * the PUCC ptyd daemon is the best source be know, else fall back - * on some emulation code?? (XXX) - */ -#if !defined(HAVE_PTYD) -#define HAVE_PTYD (defined(S81)||defined(VAX8800)) -#endif - -#if !defined(HAVE_GETPSEUDO) -#define HAVE_GETPSEUDO (defined(PTX2)) -#endif - -#if !defined(HAVE_PTSNAME) -#define HAVE_PTSNAME (defined(PTX4)) -#endif - -#if !defined(HAVE_LDTERM) -#define HAVE_LDTERM (defined(SUN5)) -#endif - -#if !defined(HAVE_STTY_LD) -#define HAVE_STTY_LD (defined(IRIX5)) -#endif - -#endif /* virtual (process on a pseudo-tty) console support */ - -#if !defined(HAVE_SETSID) -#define HAVE_SETSID (defined(IBMR2)||defined(SUN5)||defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(PTX)||defined(IRIX5)) -#endif - -/* should we use flock to keep multiple conservers from hurting each other? - * PTX has lockf... should probably port code to work with this (gregf) - */ -#if !defined(USE_FLOCK) -#define USE_FLOCK (!(defined(IBMR2)||defined(SUN5)||defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(PTX))) -#endif - -/* should we try to pop streams modules off? - */ -#if !defined(USE_STREAMS) -#define USE_STREAMS (defined(SUN4)||defined(SUN5)||defined(PTX)||defined(IRIX5)) -#endif - -/* if we do not have old style tty emulation use termios.h - */ -#if !defined(USE_TERMIO) -#define USE_TERMIO (defined(ETA10)||defined(V386)) -#endif -#if !defined(USE_TERMIOS) -#define USE_TERMIOS (defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(SUN5)||defined(PTX)||defined(IRIX5)) -#endif -#if !defined(USE_TCBREAK) -#define USE_TCBREAK (defined(SUN4)||defined(PTX)) -#endif - -/* if we have define this to 1, else define to 0 - */ -#if !defined(USE_STRINGS) -#define USE_STRINGS (defined(SUN4)||defined(DYNIX)||defined(EPIX)||defined(IRIX5)) -#endif - -#if !defined(NEED_UNISTD_H) -#define NEED_UNISTD_H (defined(SUN5)||defined(PTX)) -#endif - -#if !defined(USE_SYS_TIME_H) -#define USE_SYS_TIME_H (!defined(PTX)) -#endif - -#if USE_STRINGS -#define strchr index -#define strrchr rindex -#endif - -/* used to force the server process to clear parity, which is for farmers - */ -#define CPARITY 1 - - -/* if you do not have fd_set's here is a possible emulation - */ -#if USE_OLDSEL -typedef long fd_set; - -#define FD_ZERO(a) {*(a)=0;} -#define FD_SET(d,a) {*(a) |= (1 << (d));} -#define FD_CLR(d,a) {*(a) &= ~(1 << (d));} -#define FD_ISSET(d,a) (*(a) & (1 << (d))) -#endif - -#if USE_TERMIOS -#if defined(HPUX7)||defined(HPUX8)||defined(HPUX9) -#define TCGETS _IOR('T', 16, struct termios) -#define TCSETS _IOW('T', 17, struct termios) -#endif -#if defined(PTX2) -#define TCGETS TCGETP -#define TCSETS TCSETP -#endif -#endif - -/* which type does wait(2) take for status location - */ -#if HAVE_UWAIT -#define WAIT_T union wait -#if ! defined WEXITSTATUS -#define WEXITSTATUS(x) ((x).w_retcode) -#endif -#else -#define WAIT_T int -#endif - -/* which type signal handlers return on this machine - */ -#if defined(sun) || defined(NEXT2) || defined(SUN5) || defined(PTX) || defined(IRIX5) -#define SIGRETS void -#else -#define SIGRETS int -#endif - -/* do we have a (working) setsockopt call - */ -#if !defined(HAVE_SETSOCKOPT) -#define HAVE_SETSOCKOPT (defined(sun)||defined(PTX)) -#endif - -/* does this system have the ANSI strerror() function? - */ -#if !defined(HAVE_STRERROR) -#define HAVE_STRERROR (defined(IBMR2)||defined(ETA10)||defined(V386)||defined(SUN5)||defined(NEXT2)||defined(HPUX8)||defined(HPUX9)||defined(PTX)||defined(IRIX5)) -#endif -#if ! HAVE_STRERROR -extern int errno; -extern char *sys_errlist[]; -#define strerror(Me) (sys_errlist[Me]) -#endif - -#if !defined(HAVE_H_ERRLIST) -#define HAVE_H_ERRLIST (defined(SUN4)||defined(SUN3)||defined(FREEBSD)|defined(NETBSD)||defined(PTX)||defined(IRIX5)) -#endif -#if HAVE_H_ERRLIST -extern int h_errno; -extern char *h_errlist[]; -#define hstrerror(Me) (h_errlist[Me]) -#else -#define hstrerror(Me) "host lookup error" -#endif - -#if !defined(HAVE_RLIMIT) -#if (defined(SUN5)||defined(PTX4)) -#define HAVE_RLIMIT 1 -#else -#define HAVE_RLIMIT 0 -#endif -#endif - -/* that's all. just run - * make - * ./conserver -V - */ - -/* communication constants - */ -#define OB_SUSP 'Z' /* suspended by server */ -#define OB_DROP '.' /* dropped by server */ - -/* Due to C's poor man's macros the macro below would break if statements, - * What we want - * macro() { stuff } - * but the syntax gives us - * macro() { stuff }; - * - * the extra semicolon breaks if statements! - * Of course, the one we use makes lint scream: - * macro() do { stuff } while (0) - * - * which is a statement and makes if statements safe - */ -#if defined(lint) -extern int shut_up_lint; -#else -#define shut_up_lint 0 -#endif - -/* this macro efficently outputs a constant string to a fd - * of course it doesn't check the write :-( - */ -#define CSTROUT(Mfd, Mstr) do { \ - static char _ac[] = Mstr; \ - write(Mfd, _ac, sizeof(_ac)-1); \ - } while (shut_up_lint) - -extern char *calloc(), *malloc(), *realloc(); diff --git a/conserver/cons.h b/conserver/cons.h index a914e64..8cd46eb 120000 --- a/conserver/cons.h +++ b/conserver/cons.h @@ -1 +1 @@ -cons-test.h \ No newline at end of file +cons-gnac.h \ No newline at end of file diff --git a/conserver/consent.c b/conserver/consent.c index 2b0d4ac..69a96cb 100644 --- a/conserver/consent.c +++ b/conserver/consent.c @@ -1,6 +1,12 @@ /* - * $Id: consent.c,v 5.30 1998-11-20 17:30:45-08 bryan Exp $ + * $Id: consent.c,v 5.33 1999-01-13 11:52:21-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * @@ -52,6 +58,7 @@ static char copyright[] = #include #include "cons.h" +#include "port.h" #include "consent.h" #include "client.h" #include "main.h" @@ -628,7 +635,7 @@ fd_set *pfdSet; struct hostent *hp; int one = 1; -#ifdef USLEEP_FOR_SLOW_PORTS +#if USLEEP_FOR_SLOW_PORTS usleep( USLEEP_FOR_SLOW_PORTS ); /* Sleep for slow network ports */ #endif diff --git a/conserver/consent.h b/conserver/consent.h index 61e4003..3fb7e31 100644 --- a/conserver/consent.h +++ b/conserver/consent.h @@ -1,6 +1,12 @@ /* - * $Id: consent.h,v 5.11 1998-12-14 11:20:15-08 bryan Exp $ + * $Id: consent.h,v 5.12 1998-12-17 17:21:24-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * diff --git a/conserver/fallback.c b/conserver/fallback.c index 2eb33dc..8d8f803 100644 --- a/conserver/fallback.c +++ b/conserver/fallback.c @@ -1,6 +1,12 @@ /* - * $Id: fallback.c,v 5.18 1994-07-19 08:25:54-07 ksb Exp $ + * $Id: fallback.c,v 5.20 1999-01-13 11:48:11-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * This is a fake library interface to ptyd (mtr&ksb) * * Mike Rowan (mtr@mace.cc.purdue.edu) @@ -22,6 +28,7 @@ #include #include "cons.h" +#include "port.h" #if HAVE_PTSNAME /* for grantpt() and unlockpt() (gregf) diff --git a/conserver/group.c b/conserver/group.c index aa4349a..3ced246 100644 --- a/conserver/group.c +++ b/conserver/group.c @@ -1,6 +1,12 @@ /* - * $Id: group.c,v 5.48 1998-12-14 11:20:15-08 bryan Exp $ + * $Id: group.c,v 5.51 1999-01-13 11:48:11-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright (c) 1990 The Ohio State University. * All rights reserved. * @@ -65,6 +71,7 @@ All rights reserved.\n"; #include #include "cons.h" +#include "port.h" #include "consent.h" #include "client.h" #include "access.h" @@ -176,7 +183,28 @@ ReOpen(arg) } } -void +static fd_set *rinitUsr1; +static SIGRETS +ReUp(arg) + int arg; +{ + register int i; + register CONSENT *pCE; + + if ((GRPENT *)0 == pGEHup) { + return; + } + + for (i = 0, pCE = pGEHup->pCElist; i < pGEHup->imembers; ++i, ++pCE) { + if (pCE->fup) { + continue; + } + ConsInit(pCE, rinitUsr1); + } + (void)signal(SIGUSR1, ReUp); +} + +static SIGRETS Mark(arg) int arg; { @@ -562,10 +590,14 @@ int sfd; /* on a SIGHUP we should close and reopen our log files */ pGEHup = pGE; - signal(SIGHUP, ReOpen); + (void)signal(SIGHUP, ReOpen); + + /* on a SIGUSR1 we try to bring up all downed consoles */ + rinitUsr1 = &rinit; + (void)signal(SIGUSR1, ReUp); /* on a SIGALRM we should mark log files */ - signal(SIGALRM, Mark); + (void)signal(SIGALRM, Mark); alarm(ALARMTIME); /* the MAIN loop a group server diff --git a/conserver/group.h b/conserver/group.h index a75f235..3297439 100644 --- a/conserver/group.h +++ b/conserver/group.h @@ -1,6 +1,12 @@ /* - * $Id: group.h,v 5.8 1994-07-19 09:40:23-07 ksb Exp $ + * $Id: group.h,v 5.9 1998-12-17 17:21:24-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * diff --git a/conserver/identd.c b/conserver/identd.c deleted file mode 100644 index 01e055e..0000000 --- a/conserver/identd.c +++ /dev/null @@ -1,179 +0,0 @@ -/*@Header@*/ -/* - * ident_client.c - * - * Identifies the remote user of a given connection. - * - * Written 940112 by Luke Mewburn - * - * Copyright (C) 1994 by Luke Mewburn. - * This code may be used freely by anyone as long as this copyright remains. - * - * $Compile(*): ${cc-cc} ${cc_debug--g} -DTEST %f -o %F -lsocket -lnls - */ -#include -#include -#include -#include -#include -#include - -#include "identd.h" - -#define IDENT_PORT 113 - - -/*@Explode cli@*/ -/* (lm) - * ident_client - * - user interface to identd - * - * Args: - * peeraddr sockaddr_in struct of peer end, from getpeername(...) - * ouraddr sockaddr_in struct of local end, from getsockname(...) - * - * Returns: - * NULL on failure to identify (for whatever reason), or pointer to - * static character string with the identity. - */ -char * -ident_client(peeraddr, ouraddr, identifier) - struct sockaddr_in peeraddr, ouraddr; - char *identifier/*[1024]*/; -{ - struct sockaddr_in authcon; - int authfd, authlen; - struct servent *identserv; - int identport; - - FILE *authfpin, *authfpout; - char buffer[8192]; /* XXX: argh! magic numbers */ - char reply_type[81]; - char opsys_or_err[81]; - int rport, lport; - - - authfd = socket(AF_INET, SOCK_STREAM, 0); - if (authfd == -1) - return NULL; - - identserv = getservbyname("ident", "tcp"); - if (identserv) - identport = identserv->s_port; - else - identport = ntohs(IDENT_PORT); - - memset(&authcon, 0, sizeof(authcon)); - authcon.sin_family = AF_INET; - authcon.sin_addr.s_addr = peeraddr.sin_addr.s_addr; - authcon.sin_port = identport; - - authlen = sizeof(authcon); - if (connect(authfd, (struct sockaddr *)&authcon, authlen) < 0) - return NULL; - - authfpin = fdopen(authfd, "r"); - authfpout = fdopen(authfd, "w"); - if (!authfpin || !authfpout) - return NULL; - - fprintf(authfpout, "%d , %d\n", peeraddr.sin_port, ouraddr.sin_port); - fflush(authfpout); - - if (fgets(buffer, sizeof(buffer)-1, authfpin) == NULL) - return NULL; - - shutdown(authfd, 1); - - authlen = sscanf(buffer, "%d , %d : %[^ \t\n\r:] : %[^ \t\n\r:] : %[^\n\r]", - &lport, &rport, reply_type, opsys_or_err, identifier); - if (authlen < 3) - return NULL; - - if (0 == strcasecmp(reply_type, "ERROR")) { - printf("error %s\n", buffer); - return NULL; - } - if (0 != strcasecmp(reply_type, "USERID")) { - printf("no-user %s\n", buffer); - return NULL; - } - - return identifier; -} /* ident_client */ - -/*@Remove@*/ -#if defined(TEST) - -/*@Explode main@*/ -extern int errno; -extern char *sys_errlist[]; -#define strerror(Me) (sys_errlist[Me]) - -static struct sockaddr_in master_port, response_port; - -char *progname = "identd-test"; - -/* test driver for the identd client module (ksb) - * bind to a port, wait for telnets and tell them who they are - */ -int -main(argc, argv, envp) -int argc; -char **argv, **envp; -{ - auto struct sockaddr_in hisaddr, ouraddr; - register int mfd, cfd; - auto int true = 1, length, so; - auto char them[1024]; - - (void)memset((void *)&master_port, 0, sizeof(master_port)); - master_port.sin_family = AF_INET; - *(u_long *)&master_port.sin_addr = INADDR_ANY; - master_port.sin_port = htons(7098); - - if (-1 == (mfd = socket(AF_INET, SOCK_STREAM, 0))) { - fprintf(stderr, "%s: socket: %s\n", progname, strerror(errno)); - exit(1); - } -#if defined(SO_REUSEADDR) && defined(SOL_SOCKET) - if (setsockopt(mfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true, sizeof(true)) < 0) { - fprintf(stderr, "%s: setsockopt: %s\n", progname, strerror(errno)); - exit(1); - } -#endif - if (bind(mfd, (struct sockaddr *)&master_port, sizeof(master_port))<0) { - fprintf(stderr, "%s: bind: %s\n", progname, strerror(errno)); - exit(1); - } - - if (listen(mfd, SOMAXCONN) < 0) { - fprintf(stderr, "%s: listen: %s\n", progname, strerror(errno)); - exit(1); - } - - length = sizeof(ouraddr); - if (getsockname(mfd, (struct sockaddr *)&ouraddr, &length) < 0) { - fprintf(stderr, "%s: getsockname: %d: %s\n", progname, mfd, strerror(errno)); - - } - - while (so = sizeof(response_port), -1 != (cfd = accept(mfd, (struct sockaddr *)&response_port, &so))) { - printf("%d\n", cfd); - length = sizeof(hisaddr); - if (getpeername(cfd, (struct sockaddr *)&hisaddr, &length) < 0) { - write(cfd, "can't get your addrees?\n", 24); - } else if ((char *)0 != ident_client(hisaddr, ouraddr, them)) { - write(cfd, them, strlen(them)); - write(cfd, "\n", 1); - } else { - write(cfd, "no identd?\n", 11); - } - close(cfd); - printf("closed\n"); - } - - exit(0); -} -/*@Remove@*/ -#endif /* test driver */ diff --git a/conserver/main.c b/conserver/main.c index 58d8ce4..f481983 100644 --- a/conserver/main.c +++ b/conserver/main.c @@ -1,3 +1,11 @@ +/* + * $Id: main.c,v 5.29 1999-01-13 11:48:11-08 bryan Exp $ + * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + /* * Copyright (c) 1990 The Ohio State University. * All rights reserved. @@ -35,6 +43,7 @@ #include #include "cons.h" +#include "port.h" #include "consent.h" #include "client.h" #include "group.h" @@ -49,7 +58,7 @@ #endif char rcsid[] = - "$Id: main.c,v 5.27 1998-11-19 14:32:45-08 bryan Exp $"; + "$Id: main.c,v 5.29 1999-01-13 11:48:11-08 bryan Exp $"; char *progname = rcsid; int fAll = 1, fVerbose = 0, fSoftcar = 0; diff --git a/conserver/main.h b/conserver/main.h index 56e7490..c86e989 100644 --- a/conserver/main.h +++ b/conserver/main.h @@ -1,6 +1,12 @@ /* - * $Id: main.h,v 5.8 1998-11-17 18:42:27-08 bryan Exp $ + * $Id: main.h,v 5.9 1998-12-17 17:21:24-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * diff --git a/conserver/master.c b/conserver/master.c index 3d996f5..2c56b56 100644 --- a/conserver/master.c +++ b/conserver/master.c @@ -1,6 +1,12 @@ /* - * $Id: master.c,v 5.19 1998-11-17 23:14:51-08 bryan Exp $ + * $Id: master.c,v 5.22 1999-01-13 11:48:11-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright (c) 1990 The Ohio State University. * All rights reserved. * @@ -35,6 +41,7 @@ #include #include "cons.h" +#include "port.h" #include "consent.h" #include "client.h" #include "group.h" @@ -113,6 +120,23 @@ QuitIt(arg) ++fSawQuit; } +/* Signal all the kids... + */ +static SIGRETS +SignalKids(arg) + int arg; +{ + int i; + for (i = 0; i < MAXGRP; ++i) { + if (0 == aGroups[i].imembers) + continue; + if (-1 == kill(aGroups[i].pid, arg)) { + fprintf(stderr, "%s: kill: %s\n", progname, strerror(errno)); + } + } + (void)signal(SIGUSR1, SignalKids); +} + /* this routine is used by the master console server process (ksb) */ @@ -136,6 +160,8 @@ REMOTE /* set up signal handler */ (void)signal(SIGCHLD, FixKids); (void)signal(SIGTERM, QuitIt); + (void)signal(SIGUSR1, SignalKids); + (void)signal(SIGHUP, SignalKids); /* set up port for master to listen on */ @@ -187,7 +213,9 @@ REMOTE rmask = rmaster; if (-1 == select(msfd+1, &rmask, (fd_set *)0, (fd_set *)0, (struct timeval *)0)) { - fprintf(stderr, "%s: select: %s\n", progname, strerror(errno)); + if ( errno != EINTR ) { + fprintf(stderr, "%s: select: %s\n", progname, strerror(errno)); + } continue; } if (!FD_ISSET(msfd, &rmask)) { diff --git a/conserver/master.h b/conserver/master.h index 0a74836..f554b41 100644 --- a/conserver/master.h +++ b/conserver/master.h @@ -1,6 +1,12 @@ /* - * $Id: master.h,v 5.6 1993-02-09 04:01:31-08 ldv Exp $ + * $Id: master.h,v 5.7 1998-12-17 17:21:24-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * diff --git a/conserver/port.h b/conserver/port.h new file mode 100644 index 0000000..38b7206 --- /dev/null +++ b/conserver/port.h @@ -0,0 +1,357 @@ +/* + * $Id: port.h,v 1.2 1999-01-13 13:47:32-08 bryan Exp $ + * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* + * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana + * 47907. All rights reserved. + * + * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb + * + * This software is not subject to any license of the American Telephone + * and Telegraph Company or the Regents of the University of California. + * + * Permission is granted to anyone to use this software for any purpose on + * any computer system, and to alter it and redistribute it freely, subject + * to the following restrictions: + * + * 1. Neither the authors nor Purdue University are responsible for any + * consequences of the use of this software. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Credit to the authors and Purdue + * University must appear in documentation and sources. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 4. This notice may not be removed or altered. + */ + +/* + * this is the configuration file for the Ohio State/PUCC console + * server. Just define the macros below to somehting that looks good + * and give it a go. It'll complain (under conserver -V) if things + * look really bad. + * + * all PTX, PTX2, and PTX4 code added by gregf@sequent.com (gregf) + */ +#if !( defined(IBMR2) || defined(HPUX7) || defined(SUN4) || defined(SUN5) || defined(PTX2) || defined(PTX4) ) +#error "Platform needs to be defined. See port.h" +#endif + +#if (defined(PTX2) || defined(PTX4)) +#define PTX +#endif + +/* some machine specific details + */ +#if !defined(USE_OLDSEL) +#if defined(IBMR2) +#include +#endif +#endif +#if !defined(HAVE_UWAIT) +#define HAVE_UWAIT !(defined(IBMR2)||defined(SUN5)||defined(HPUX8)||defined(HPUX9)||defined(PTX)||defined(IRIX5)) +#endif + +#if !defined(HAVE_WAIT3) +#define HAVE_WAIT3 !(defined(SUN5)||defined(PTX)) +#endif + +/* This is the port number used in the connection. It can use either + * /etc/services or a hardcoded port (SERVICE name has precedence). + * (You can -D one in the Makefile to override these.) + */ +/* #define PORT 782 /* only if you cannot put in /etc/services */ +#if !defined(SERVICE) +#if !defined(PORT) +#define SERVICE "conserver" +#endif +#endif + +/* Wait for a part of a second before slapping console server. + * Good for CISCO terminal servers that get upset when you + * attack with intense socket connections + */ +#if !defined(USLEEP_FOR_SLOW_PORTS) +#define USLEEP_FOR_SLOW_PORTS 100000 +#endif + +/* The name of the host which will act as the console server + */ +#if !defined(HOST) +#define HOST "console" +#endif + +/* the default escape sequence used to give meta commands + */ +#if !defined(DEFATTN) +#define DEFATTN '\005' +#endif +#if !defined(DEFESC) +#define DEFESC 'c' +#endif + +/* Location of the configuration file + */ +#if !defined(CONFIG) +#define CONFIG "/etc/conserver.cf" +#endif + +/* Location of ANL designed passwd file */ +#if !defined(PASSWD_FILE) +#define PASSWD_FILE "/etc/conserver.passwd" +#endif + +/* The maximum number of serial lines that can be handled by a child process + */ +#if !defined(MAXMEMB) +#define MAXMEMB 8 +#endif + + +/* The maximum number of child processes spawned. + */ +#if !defined(MAXGRP) +#define MAXGRP 32 +#endif + +/* the max number of characters conserver will replay for you (the r command) + */ +#if !defined(MAXREPLAY) +#define MAXREPLAY (80*25) +#endif + +/* if the encrypted passwd is in a shadow file, define HAVE_SHADOW (gregf) + */ +#if !defined(HAVE_SHADOW) +#define HAVE_SHADOW (defined(PTX)||defined(SUN5)) +#endif + +/* we'd like to line buffer our output, if we know how + */ +#if !defined(USE_SETLINEBUF) +#define USE_SETLINEBUF (!(defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(PTX))) +#endif + +/* we'd like to line buffer our output, if we know how; PTX uses setvbuf (gregf) + */ +#if !defined(USE_SETVBUF) +#define USE_SETVBUF (defined(PTX)) +#endif + +/* hpux doesn't have getdtablesize() and they don't provide a macro + * in non-KERNEL cpp mode + */ +#if defined(HPUX7)||defined(HPUX8)||defined(HPUX9) +#define getdtablesize() 64 +#endif + +/* the console server will provide a pseudo-device console which + * allows operators to run backups and such without a hard wired + * line (this is also good for testing the server to see if you + * might wanna use it). Turn this on only if you (might) need it. + */ +#if !defined(DO_VIRTUAL) +#define DO_VIRTUAL 1 +#endif + +#if DO_VIRTUAL +/* if the virtual console option is on we need a source to ptys, + * the PUCC ptyd daemon is the best source be know, else fall back + * on some emulation code?? (XXX) + */ +#if !defined(HAVE_PTYD) +#define HAVE_PTYD (defined(S81)||defined(VAX8800)) +#endif + +#if !defined(HAVE_GETPSEUDO) +#define HAVE_GETPSEUDO (defined(PTX2)) +#endif + +#if !defined(HAVE_PTSNAME) +#define HAVE_PTSNAME (defined(PTX4)) +#endif + +#if !defined(HAVE_LDTERM) +#define HAVE_LDTERM (defined(SUN5)) +#endif + +#if !defined(HAVE_STTY_LD) +#define HAVE_STTY_LD (defined(IRIX5)) +#endif + +#endif /* virtual (process on a pseudo-tty) console support */ + +#if !defined(HAVE_SETSID) +#define HAVE_SETSID (defined(IBMR2)||defined(SUN5)||defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(PTX)||defined(IRIX5)) +#endif + +/* should we use flock to keep multiple conservers from hurting each other? + * PTX has lockf... should probably port code to work with this (gregf) + */ +#if !defined(USE_FLOCK) +#define USE_FLOCK (!(defined(IBMR2)||defined(SUN5)||defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(PTX))) +#endif + +/* should we try to pop streams modules off? + */ +#if !defined(USE_STREAMS) +#define USE_STREAMS (defined(SUN4)||defined(SUN5)||defined(PTX)||defined(IRIX5)) +#endif + +/* if we do not have old style tty emulation use termios.h + */ +#if !defined(USE_TERMIO) +#define USE_TERMIO (defined(ETA10)||defined(V386)) +#endif +#if !defined(USE_TERMIOS) +#define USE_TERMIOS (defined(HPUX7)||defined(HPUX8)||defined(HPUX9)||defined(SUN5)||defined(PTX)||defined(IRIX5)) +#endif +#if !defined(USE_TCBREAK) +#define USE_TCBREAK (defined(SUN4)||defined(PTX)) +#endif + +/* if we have define this to 1, else define to 0 + */ +#if !defined(USE_STRINGS) +#define USE_STRINGS (defined(SUN4)||defined(DYNIX)||defined(EPIX)||defined(IRIX5)) +#endif + +#if !defined(NEED_UNISTD_H) +#define NEED_UNISTD_H (defined(SUN5)||defined(PTX)) +#endif + +#if !defined(USE_SYS_TIME_H) +#define USE_SYS_TIME_H (!defined(PTX)) +#endif + +#if USE_STRINGS +#define strchr index +#define strrchr rindex +#endif + +/* used to force the server process to clear parity, which is for farmers + */ +#define CPARITY 1 + + +/* if you do not have fd_set's here is a possible emulation + */ +#if USE_OLDSEL +typedef long fd_set; + +#define FD_ZERO(a) {*(a)=0;} +#define FD_SET(d,a) {*(a) |= (1 << (d));} +#define FD_CLR(d,a) {*(a) &= ~(1 << (d));} +#define FD_ISSET(d,a) (*(a) & (1 << (d))) +#endif + +#if USE_TERMIOS +#if defined(HPUX7)||defined(HPUX8)||defined(HPUX9) +#define TCGETS _IOR('T', 16, struct termios) +#define TCSETS _IOW('T', 17, struct termios) +#endif +#if defined(PTX2) +#define TCGETS TCGETP +#define TCSETS TCSETP +#endif +#endif + +/* which type does wait(2) take for status location + */ +#if HAVE_UWAIT +#define WAIT_T union wait +#if ! defined WEXITSTATUS +#define WEXITSTATUS(x) ((x).w_retcode) +#endif +#else +#define WAIT_T int +#endif + +/* which type signal handlers return on this machine + */ +#if defined(sun) || defined(NEXT2) || defined(SUN5) || defined(PTX) || defined(IRIX5) +#define SIGRETS void +#else +#define SIGRETS int +#endif + +/* do we have a (working) setsockopt call + */ +#if !defined(HAVE_SETSOCKOPT) +#define HAVE_SETSOCKOPT (defined(sun)||defined(PTX)) +#endif + +/* does this system have the ANSI strerror() function? + */ +#if !defined(HAVE_STRERROR) +#define HAVE_STRERROR (defined(IBMR2)||defined(ETA10)||defined(V386)||defined(SUN5)||defined(NEXT2)||defined(HPUX8)||defined(HPUX9)||defined(PTX)||defined(IRIX5)) +#endif +#if ! HAVE_STRERROR +extern int errno; +extern char *sys_errlist[]; +#define strerror(Me) (sys_errlist[Me]) +#endif + +#if !defined(HAVE_H_ERRLIST) +#define HAVE_H_ERRLIST (defined(SUN4)||defined(SUN3)||defined(FREEBSD)|defined(NETBSD)||defined(PTX)||defined(IRIX5)) +#endif +#if HAVE_H_ERRLIST +extern int h_errno; +extern char *h_errlist[]; +#define hstrerror(Me) (h_errlist[Me]) +#else +#define hstrerror(Me) "host lookup error" +#endif + +#if !defined(HAVE_RLIMIT) +#if (defined(SUN5)||defined(PTX4)) +#define HAVE_RLIMIT 1 +#else +#define HAVE_RLIMIT 0 +#endif +#endif + +/* that's all. just run + * make + * ./conserver -V + */ + +/* communication constants + */ +#define OB_SUSP 'Z' /* suspended by server */ +#define OB_DROP '.' /* dropped by server */ + +/* Due to C's poor man's macros the macro below would break if statements, + * What we want + * macro() { stuff } + * but the syntax gives us + * macro() { stuff }; + * + * the extra semicolon breaks if statements! + * Of course, the one we use makes lint scream: + * macro() do { stuff } while (0) + * + * which is a statement and makes if statements safe + */ +#if defined(lint) +extern int shut_up_lint; +#else +#define shut_up_lint 0 +#endif + +/* this macro efficently outputs a constant string to a fd + * of course it doesn't check the write :-( + */ +#define CSTROUT(Mfd, Mstr) do { \ + static char _ac[] = Mstr; \ + write(Mfd, _ac, sizeof(_ac)-1); \ + } while (shut_up_lint) + +extern char *calloc(), *malloc(), *realloc(); diff --git a/conserver/readcfg.c b/conserver/readcfg.c index 5ec1436..101da47 100644 --- a/conserver/readcfg.c +++ b/conserver/readcfg.c @@ -1,6 +1,12 @@ /* - * $Id: readcfg.c,v 5.21 1998-12-14 11:20:15-08 bryan Exp $ + * $Id: readcfg.c,v 5.23 1999-01-13 11:48:11-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright (c) 1990 The Ohio State University. * All rights reserved. * @@ -39,6 +45,7 @@ #include #include "cons.h" +#include "port.h" #include "consent.h" #include "client.h" #include "group.h" diff --git a/conserver/readcfg.h b/conserver/readcfg.h index 96ff0c9..855e21d 100644 --- a/conserver/readcfg.h +++ b/conserver/readcfg.h @@ -1,6 +1,12 @@ /* - * $Id: readcfg.h,v 5.6 1993-02-09 03:59:25-08 ldv Exp $ + * $Id: readcfg.h,v 5.7 1998-12-17 17:21:24-08 bryan Exp $ * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +/* * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana * 47907. All rights reserved. * diff --git a/conserver/version.h b/conserver/version.h index a0ef628..41f0881 100644 --- a/conserver/version.h +++ b/conserver/version.h @@ -1 +1,9 @@ -#define GNAC_VERSION "GNAC version 6.05" +/* + * $Id: version.h,v 1.7 1999-01-07 11:17:20-08 bryan Exp $ + * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + +#define GNAC_VERSION "GNAC version 6.06" diff --git a/console/Makefile b/console/Makefile index 68d6a90..324fac6 100644 --- a/console/Makefile +++ b/console/Makefile @@ -1,81 +1,61 @@ -# $Id: Make.host,v 5.10 94/07/26 11:06:26 ksb Exp $ +# $Id: Makefile,v 1.7 1999-01-13 14:19:02-08 bryan Exp $ # # Makefile for console client progran # -# edit the ETC directory below to change where the console client -# is installed. PROG= console -ETC= ${DESTDIR}/usr/local/etc -DOC= ${DESTDIR}/usr/local/man +PREFIX=/usr/local +BIN=${PREFIX}/bin +ETC=${PREFIX}/etc +MAN=${PREFIX}/man +MANSECT=8 +INSTALL=/usr/ucb/install -I=/usr/include -S=/usr/include/sys -L=/usr/local/include C=../conserver -P= INCLUDE= -I$C DEBUG=-O -CDEFS= -DSUN5 +CDEFS= CFLAGS= ${DEBUG} ${CDEFS} ${INCLUDE} +LIBS=-lsocket -lnsl HDR= -ONEC= console.c -MAN= console.man -OTHER= README -SOURCE= Makefile ${OTHER} ${MAN} ${HDR} ${ONEC} +SRC= console.c +OBJ= console.o all: ${PROG} -${PROG}: - ${CC} -o $@ ${CFLAGS} ${ONEC} -lsocket -lnsl +${PROG}: ${OBJ} + ${CC} -o $@ ${CFLAGS} ${OBJ} ${LIBS} clean: FRC rm -f Makefile.bak ${PROG} a.out *.o core errs lint.out tags -deinstall: ${MAN} ${DOC} FRC - install -R ${ETC}/${PROG} - mkcat -r${DOC} -D ${MAN} +depend: ${HDR} ${SRC} FRC + makedepend ${CDEFS} ${INCLUDE} ${SRC} -depend: ${HDR} ${ONEC} FRC - maketd -b ${CDEFS} ${INCLUDE} ${ONEC} - -dirs: ${ETC} - -distrib: FRC - distrib -c ${ETC}/${PROG} +dirs: ${BIN} install: all dirs FRC - install -cs ${PROG} ${ETC}/${PROG} + ${INSTALL} -cs ${PROG} ${BIN}/${PROG} -lint: ${HDR} ${ONEC} FRC - lint -h ${CDEFS} ${INCLUDE} ${ONEC} +${MAN}/man${MANSECT}: + ${INSTALL} -d $@ -mkcat: ${MAN} ${DOC} FRC - mkcat -r${DOC} ${MAN} +install.man: ${MAN}/man${MANSECT} + ${INSTALL} -c console.man ${MAN}/man${MANSECT}/console.${MANSECT} -print: source FRC - lpr -J"${PROG} source" ${SOURCE} +lint: ${HDR} ${SRC} FRC + lint -h ${CDEFS} ${INCLUDE} ${SRC} -source: ${SOURCE} +tags: ${HDR} ${SRC} + ctags -t ${HDR} ${SRC} -spotless: clean - rcsclean ${SOURCE} - -tags: ${HDR} ${ONEC} - ctags -t ${HDR} ${ONEC} - -/ ${ETC}: - install -dr $@ - -${SOURCE}: - co -q $@ +/ ${BIN}: + ${INSTALL} -d $@ FRC: -# DO NOT DELETE THIS LINE - maketd DEPENDS ON IT +# DO NOT DELETE THIS LINE -- make depend depends on it. -console: $C/cons.h console.c - -# *** Do not add anything here - It will go away. *** +console.o: ../conserver/cons.h ../conserver/port.h ../conserver/version.h diff --git a/console/console.c b/console/console.c index 2afb73b..da64de5 100644 --- a/console/console.c +++ b/console/console.c @@ -1,3 +1,11 @@ +/* + * $Id: console.c,v 5.22 1999-01-13 11:48:38-08 bryan Exp $ + * + * GNAC, Inc., 1998 + * + * Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com) + */ + /* * Copyright (c) 1990 The Ohio State University. * All rights reserved. @@ -31,6 +39,7 @@ #include #include "cons.h" +#include "port.h" #include "version.h" #if USE_STRINGS @@ -68,7 +77,7 @@ extern char *sys_errlist[]; #endif static char rcsid[] = - "$Id: console.c,v 5.20 1998-11-20 16:53:02-08 bryan Exp $"; + "$Id: console.c,v 5.22 1999-01-13 11:48:38-08 bryan Exp $"; static char *progname = rcsid; int fVerbose = 0, fReplay = 0, fRaw = 0;