Imported from conserver-GNAC-6.12.tar.gz

This commit is contained in:
Bryan Stansell 1999-08-24 14:52:59 -07:00
parent e3d53eb106
commit 7e200f7578
15 changed files with 347 additions and 57 deletions

14
CHANGES

@ -1,6 +1,18 @@
CHANGES
=======
version 6.12:
- Blank line bug after '%%' in .cf file (found by Miss
Himali Patel <cpate03@dcs.bbk.ac.uk>)
Special thanks to Michael Sullivan <mike@trdlnk.com> for
the following improvements and fixes...
- Read result bug in group.c caused lock up
- Signal handling fixes and cleanup
- Several minor spelling errors in strings and comments
- Solaris package creation scripts
- Extended syntax of the access restrictions to understand
network numbers with optional netmasks
version 6.11:
- Added broadcast capability in client (-b option)
- Protected certain escape sequences from end-user use
@ -39,5 +51,5 @@ before version 6.05:
and enhancements of various types were applied.
#
# $Id: CHANGES,v 1.7 1999-05-14 10:18:20-07 bryan Exp $
# $Id: CHANGES,v 1.8 1999-08-24 14:37:09-07 bryan Exp $
#

@ -9,11 +9,11 @@ contains three fields seperated by colons: <username>:<passwd>:<hosts>.
The <passwd> field should either be an encrypted password or the special
string '*passwd*', which will cause the console server to do a getpwnam()
call. The <hosts> field can be a comma seperated list of console names
(from conserver.cf) or the special string 'all'. Access for the user
is only granted to the hosts listed here (or all if 'all' is used).
(from conserver.cf) or the special string 'any'. Access for the user
is only granted to the hosts listed here (or all if 'any' is used).
That's about it. Good luck.
#
# $Id: INSTALL,v 1.1 1999-01-25 15:36:52-08 bryan Exp $
# $Id: INSTALL,v 1.2 1999-08-24 13:45:00-07 bryan Exp $
#

@ -1,4 +1,4 @@
.\" $Id: conserver.cf.man,v 1.4 1999-04-12 22:40:55-07 bryan Exp $
.\" $Id: conserver.cf.man,v 1.5 1999-08-24 14:50:54-07 bryan Exp $
.\" @(#)constab.5 01/06/91 OSU CIS; Thomas A. Fine
.TH CONSERVER.CF 4 "Local"
.SH NAME
@ -15,7 +15,7 @@ LOGDIR=\fIlogdirectory\fP
.br
\fB%%\fP
.br
\fIaccess hosts\fP
\fIaccess\fP: \fIhosts\fP
.SH DESCRIPTION
.B Conserver.cf
is the configuration file for
@ -65,6 +65,9 @@ Any complete suffix of a host name my be used to allow access for all hosts
in that subdomain.
For example `cc.purdue.edu' will allow `mentor.cc.purdue.edu'
and `mace.cc.purdue.edu', but not `pucc.purdue.edu' or `hack.purdue.edu'.
For IP addresses, optional netmasks may be specified. For example `192.168.1.0'
will allow the class C space of 192.168.1.0. `192.168.1.0/25' will only allow
only the lower half of that same address space (192.168.1.0 thru 192.168.1.127).
.SH EXAMPLE
# server:path:baud:/usr/adm/logfile:mark
.br

@ -1,5 +1,5 @@
/*
* $Id: access.c,v 5.12 1999-01-26 20:35:17-08 bryan Exp $
* $Id: access.c,v 5.13 1999-08-24 14:39:26-07 bryan Exp $
*
* Copyright GNAC, Inc., 1998
*
@ -81,6 +81,67 @@ OutOfMem()
exit(45);
}
/* Compare an Internet address (IPv4 expected), with an address pattern
* passed as a character string representing an address in the Internet
* standard `.' notation, optionally followed by a slash and an integer
* specifying the number of bits in the network portion of the address
* (the netmask size). If not specified explicitly, the netmask size used
* is that implied by the address class. If either the netmask is specified
* explicitly, or the local network address part of the pattern is zero,
* then only the network number parts of the addresses are compared;
* otherwise the entire addresses are compared.
*
* Returns 0 if the addresses match, else returns 1.
*/
int
AddrCmp(hp, pattern)
struct hostent *hp;
char *pattern;
{
unsigned long int hostaddr, pattern_addr, netmask;
char buf[200], *p, *slash_posn;
if (hp->h_addrtype != AF_INET || hp->h_length != 4)
return 1; /* unsupported address type */
slash_posn = strchr(pattern, '/');
if (slash_posn != NULL) {
if (strlen(pattern) >= sizeof(buf))
return 1; /* too long to handle */
strncpy(buf, pattern, sizeof(buf));
buf[slash_posn-pattern] = '\0'; /* isolate the address */
p = buf;
}
else
p = pattern;
pattern_addr = inet_addr(p);
if (pattern_addr == -1)
return 1; /* malformed address */
if (slash_posn) {
/* convert explicit netmask */
int mask_bits = atoi(slash_posn+1);
for (netmask = 0; mask_bits > 0; --mask_bits)
netmask = 0x80000000 | (netmask >> 1);
} else {
/* netmask implied by address class */
unsigned long int ia = ntohl(pattern_addr);
if (IN_CLASSA(ia))
netmask = IN_CLASSA_NET;
else if (IN_CLASSB(ia))
netmask = IN_CLASSB_NET;
else if (IN_CLASSC(ia))
netmask = IN_CLASSC_NET;
else
return 1; /* unsupported address class */
}
netmask = htonl(netmask);
if (~netmask & pattern_addr)
netmask = 0xffffffff; /* compare entire addresses */
hostaddr = *(unsigned long int*)hp->h_addr;
return (hostaddr & netmask) != (pattern_addr & netmask);
}
/* return the access type for a given host entry (ksb)
*/
@ -89,21 +150,33 @@ AccType(hp)
struct hostent *hp;
{
register int i;
#if ORIGINAL_CODE
register unsigned char *puc;
#endif
register char *pcName;
#if ORIGINAL_CODE
auto char acAddr[4*3+2];
#endif
register int len;
#if ORIGINAL_CODE
puc = (unsigned char *)hp->h_addr;
sprintf(acAddr, "%d.%d.%d.%d", puc[0], puc[1], puc[2], puc[3]);
#endif
for (i = 0; i < iAccess; ++i) {
if (isdigit(pACList[i].pcwho[0])) {
#if ORIGINAL_CODE
/* we could allow 128.210.7 to match all on that subnet
* here...
*/
if (0 == strcmp(acAddr, pACList[i].pcwho)) {
return pACList[i].ctrust;
}
#else
if (0 == AddrCmp(hp, pACList[i].pcwho)) {
return pACList[i].ctrust;
}
#endif
continue;
}
pcName = hp->h_name;

@ -1,5 +1,5 @@
/*
* $Id: group.c,v 5.55 1999-05-14 10:16:48-07 bryan Exp $
* $Id: group.c,v 5.56 1999-08-24 14:39:12-07 bryan Exp $
*
* Copyright GNAC, Inc., 1998
*
@ -127,6 +127,8 @@ extern int FallBack();
extern char *crypt(), *calloc();
extern time_t time();
/* flags that a signal has occurred */
static SIGFLAG fSawReOpen, fSawReUp, fSawMark, fSawGoAway;
/* Is this passwd a match for this user's passwd? (gregf/ksb)
* look up passwd in shadow file if we have to, if we are
@ -159,10 +161,19 @@ char *pcEPass, *pcWord;
/* on an HUP close and re-open log files so lop can trim them (ksb)
* lucky for us: log file fd's can change async from the group driver!
*/
static GRPENT *pGEHup;
static SIGRETS
ReOpen(arg)
int arg;
FlagReOpen(sig)
int sig;
{
fSawReOpen = 1;
#if !USE_SIGACTION
(void)signal(SIGHUP, FlagReOpen);
#endif
}
static GRPENT *pGEHup;
static void
ReOpen()
{
register int i;
register CONSENT *pCE;
@ -183,10 +194,19 @@ ReOpen(arg)
}
}
static fd_set *rinitUsr1;
static SIGRETS
ReUp(arg)
int arg;
FlagReUp(sig)
int sig;
{
fSawReUp = 1;
#if !USE_SIGACTION
(void)signal(SIGUSR1, FlagReUp);
#endif
}
static fd_set *rinitUsr1;
static void
ReUp()
{
register int i;
register CONSENT *pCE;
@ -201,12 +221,20 @@ ReUp(arg)
}
ConsInit(pCE, rinitUsr1);
}
(void)signal(SIGUSR1, ReUp);
}
static SIGRETS
Mark(arg)
int arg;
FlagMark(sig)
int sig;
{
fSawMark = 1;
#if !USE_SIGACTION
signal(SIGALRM, FlagMark);
#endif
}
static void
Mark()
{
long tyme;
char acOut[BUFSIZ];
@ -233,7 +261,6 @@ Mark(arg)
pCE->nextMark = tyme + pCE->mark;
}
}
signal(SIGALRM, Mark);
alarm(ALARMTIME);
}
@ -263,8 +290,14 @@ GRPENT *pGE;
}
static SIGRETS
GoAway(sig)
FlagGoAway(sig)
int sig;
{
fSawGoAway = 1;
}
static void
GoAway()
{
SendShutdownMsg(pGEHup);
@ -276,9 +309,8 @@ int sig;
#if DO_VIRTUAL
/* on a TERM we have to cleanup utmp entries (ask ptyd to do it) (ksb)
*/
static SIGRETS
DeUtmp(sig)
int sig;
static void
DeUtmp()
{
register int i;
register CONSENT *pCE;
@ -325,7 +357,7 @@ int sig;
if (0 == pid) {
break;
}
/* stopped child is just continuted
/* stopped child is just continued
*/
if (WIFSTOPPED(UWbuf) && 0 == kill(pid, SIGCONT)) {
continue;
@ -543,20 +575,18 @@ int sfd;
#endif
#endif
/* turn off signals that master() might turned on
/* turn off signals that master() might have turned on
* (only matters if respawned)
*/
(void)signal(SIGURG, SIG_DFL);
Set_signal(SIGTERM, FlagGoAway);
#if DO_VIRTUAL
(void)signal(SIGTERM, DeUtmp);
(void)signal(SIGCHLD, ReapVirt);
Set_signal(SIGCHLD, ReapVirt);
#else
(void)signal(SIGTERM, GoAway);
(void)signal(SIGCHLD, SIG_DFL);
#endif
/* setup our local data structures and fields, and contol line
/* setup our local data structures and fields, and control line
*/
pCE = pGE->pCElist;
for (iConsole = 0; iConsole < pGE->imembers; ++iConsole) {
@ -628,20 +658,41 @@ int sfd;
/* on a SIGHUP we should close and reopen our log files
*/
pGEHup = pGE;
(void)signal(SIGHUP, ReOpen);
Set_signal(SIGHUP, FlagReOpen);
/* on a SIGUSR1 we try to bring up all downed consoles */
rinitUsr1 = &rinit;
(void)signal(SIGUSR1, ReUp);
Set_signal(SIGUSR1, FlagReUp);
/* on a SIGALRM we should mark log files */
(void)signal(SIGALRM, Mark);
Set_signal(SIGALRM, FlagMark);
alarm(ALARMTIME);
/* the MAIN loop a group server
*/
pGE->pCLall = (CLIENT *)0;
while (1) {
/* check signal flags */
if (fSawGoAway) {
#if DO_VIRTUAL
DeUtmp();
#else
GoAway();
#endif
}
if (fSawReOpen) {
fSawReOpen = 0;
ReOpen();
}
if (fSawReUp) {
fSawReUp = 0;
ReUp();
}
if (fSawMark) {
fSawMark = 0;
Mark();
}
rmask = rinit;
if (-1 == select(maxfd, &rmask, (fd_set *)0, (fd_set *)0, (struct timeval *)0)) {
@ -659,7 +710,7 @@ int sfd;
continue;
}
/* read terminal line */
if ((nr = read(pCEServing->fdtty, acIn, sizeof(acIn))) < 0) {
if ((nr = read(pCEServing->fdtty, acIn, sizeof(acIn))) <= 0) {
/* carrier lost */
fprintf(stderr, "%s: lost carrier on %s (%s)!\n", progname, pCEServing->server, pCEServing->dfile);
#if DO_VIRTUAL
@ -1751,3 +1802,16 @@ GRPENT *pGE;
/*NOTREACHED*/
}
#if USE_SIGACTION
void Set_signal(sig, disp)
int sig;
SIGRETS (*disp)(int);
{
struct sigaction sa;
sa.sa_handler = disp;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaction(sig, &sa, NULL);
}
#endif

@ -1,5 +1,5 @@
/*
* $Id: master.c,v 5.23 1999-01-26 20:35:17-08 bryan Exp $
* $Id: master.c,v 5.24 1999-08-24 14:38:26-07 bryan Exp $
*
* Copyright GNAC, Inc., 1998
*
@ -67,13 +67,24 @@
extern char *crypt();
extern time_t time();
static SIGFLAG fSawQuit, fSawHUP, fSawUSR1, fSawCHLD;
static SIGRETS
FlagSawCHLD(sig)
int sig;
{
fSawCHLD = 1;
#if !USE_SIGACTION
(void)signal(SIGCHLD, FlagSawCHLD);
#endif
}
/* check all the kids and respawn as needed. (fine)
* Called when master process receives SIGCHLD
*/
static SIGRETS
FixKids(arg)
int arg;
static void
FixKids()
{
register int i, pid;
auto long tyme;
@ -108,8 +119,6 @@ FixKids(arg)
}
}
static int fSawQuit;
/* kill all the kids and exit.
* Called when master process receives SIGTERM
*/
@ -117,12 +126,32 @@ static SIGRETS
QuitIt(arg)
int arg;
{
++fSawQuit;
fSawQuit = 1;
}
static SIGRETS
FlagSawHUP(arg)
int arg;
{
fSawHUP = 1;
#if !USE_SIGACTION
(void)signal(SIGHUP, FlagSawHUP);
#endif
}
static SIGRETS
FlagSawUSR1(arg)
int arg;
{
fSawUSR1 = 1;
#if !USE_SIGACTION
(void)signal(SIGUSR1, FlagSawUSR1);
#endif
}
/* Signal all the kids...
*/
static SIGRETS
void
SignalKids(arg)
int arg;
{
@ -134,7 +163,6 @@ SignalKids(arg)
fprintf(stderr, "%s: kill: %s\n", progname, strerror(errno));
}
}
(void)signal(SIGUSR1, SignalKids);
}
@ -158,10 +186,10 @@ REMOTE
int true = 1;
/* set up signal handler */
(void)signal(SIGCHLD, FixKids);
(void)signal(SIGTERM, QuitIt);
(void)signal(SIGUSR1, SignalKids);
(void)signal(SIGHUP, SignalKids);
Set_signal(SIGCHLD, FlagSawCHLD);
Set_signal(SIGTERM, QuitIt);
Set_signal(SIGUSR1, FlagSawUSR1);
Set_signal(SIGHUP, FlagSawHUP);
/* set up port for master to listen on
*/
@ -210,6 +238,19 @@ REMOTE
FD_ZERO(&rmaster);
FD_SET(msfd, &rmaster);
for (fSawQuit = 0; !fSawQuit; /* can't close here :-( */) {
if (fSawCHLD) {
fSawCHLD = 0;
FixKids();
}
if (fSawHUP) {
fSawHUP = 0;
SignalKids(SIGHUP);
}
if (fSawUSR1) {
fSawUSR1 = 0;
SignalKids(SIGUSR1);
}
rmask = rmaster;
if (-1 == select(msfd+1, &rmask, (fd_set *)0, (fd_set *)0, (struct timeval *)0)) {
@ -469,7 +510,7 @@ REMOTE
}
break;
default:
sprintf(acOut, "ambigous server abbreviation, %s\r\n", pcArgs);
sprintf(acOut, "ambiguous server abbreviation, %s\r\n", pcArgs);
break;
}
(void)write(cfd, acOut, strlen(acOut));

@ -1,5 +1,5 @@
/*
* $Id: port.h,v 1.7 1999-05-14 10:17:14-07 bryan Exp $
* $Id: port.h,v 1.8 1999-08-24 14:37:29-07 bryan Exp $
*
* Copyright GNAC, Inc., 1998
*
@ -285,6 +285,23 @@ typedef long fd_set;
#define SIGRETS int
#endif
/* which type to use for global flags set by signal handlers */
#if defined(SUN5)
#define SIGFLAG volatile sig_atomic_t
#else
#define SIGFLAG int
#endif
#if !defined(USE_SIGACTION)
#define USE_SIGACTION (defined(SUN4)||defined(SUN5)||defined(LINUX2))
#endif
#if USE_SIGACTION
extern void Set_signal(int isg, SIGRETS (*disp)(int));
#else
#define Set_signal(sig, disp) (void)signal((sig), (disp))
#endif
/* do we have a (working) setsockopt call
*/
#if !defined(HAVE_SETSOCKOPT)

@ -1,5 +1,5 @@
/*
* $Id: readcfg.c,v 5.24 1999-01-26 20:35:17-08 bryan Exp $
* $Id: readcfg.c,v 5.26 1999-08-24 14:37:55-07 bryan Exp $
*
* Copyright GNAC, Inc., 1998
*
@ -317,7 +317,7 @@ register FILE *fp;
auto int iLen;
++iLine;
for (pcRem = acIn+strlen(acIn); pcRem >= acIn; --pcRem) {
for (pcRem = acIn+strlen(acIn)-1; pcRem >= acIn; --pcRem) {
if (!isspace(*pcRem))
break;
*pcRem = '\000';
@ -355,7 +355,7 @@ register FILE *fp;
exit(3);
}
while ('\000' != *(pcMach = pcNext)) {
while (!isspace(*pcNext)) {
while ('\000' != *pcNext && !isspace(*pcNext)) {
++pcNext;
}
while ('\000' != *pcNext && isspace(*pcNext)) {

@ -1,9 +1,9 @@
/*
* $Id: version.h,v 1.11 1999-05-14 10:17:49-07 bryan Exp $
* $Id: version.h,v 1.12 1999-08-24 14:37:24-07 bryan Exp $
*
* Copyright GNAC, Inc., 1998
*
* Maintainer/Enhancer: Bryan Stansell (bryan@gnac.com)
*/
#define GNAC_VERSION "GNAC version 6.11"
#define GNAC_VERSION "GNAC version 6.12"

@ -1,5 +1,5 @@
/*
* $Id: console.c,v 5.26 1999-02-02 11:36:26-08 bryan Exp $
* $Id: console.c,v 5.27 1999-08-23 17:32:35-07 bryan Exp $
*
* Copyright GNAC, Inc., 1998
*
@ -77,7 +77,7 @@ extern char *sys_errlist[];
#endif
static char rcsid[] =
"$Id: console.c,v 5.26 1999-02-02 11:36:26-08 bryan Exp $";
"$Id: console.c,v 5.27 1999-08-23 17:32:35-07 bryan Exp $";
static char *progname =
rcsid;
int fVerbose = 0, fReplay = 0, fRaw = 0;
@ -153,7 +153,7 @@ FILE *fp;
}
static char *apcLong[] = {
"a(A) attach politelty (and replay last 20 lines)",
"a(A) attach politely (and replay last 20 lines)",
"b broadcast message",
"d(D) display (local) daemon version",
"e esc set the initial escape characters",
@ -936,7 +936,7 @@ char *pcMaster, *pcMach, *pcCmd, *pcWho;
#define BUF_MIN 80
#define BUF_CHUNK (2*132)
/* Cmd is implemented seperately from above because of the need buffer (ksb)
/* Cmd is implemented separately from above because of the need buffer (ksb)
* the ports' output. It's about the same as what's above otherwise.
* We trick lint because we have to be call compatible (prototype'd)
* the same as all the other Gather functions.

14
contrib/README Normal file

@ -0,0 +1,14 @@
Various contributions by folks....
solaris-package
Author: Michael Sullivan <mike@trdlnk.com>
Synopsis: Creates a solaris package
I can't verify that these scripts will work for everyone. Hopefully they
will be helpful.
Bryan Stansell
#
# $Id: README,v 1.1 1999-08-24 14:24:41-07 bryan Exp $
#

@ -0,0 +1,42 @@
# Makefile for System V package
PKGNAME = conserver
# where to put package
PKGSPOOLDIR = /var/spool/pkg
# where package's files ultimately go (when package is installed)
PKGROOT = /opt
# temporary directory used while building package
INSTALLROOT = /tmp/conserverinstallroot
BUILDDIR = ../..
# temporary install directories
BINDIR = $(INSTALLROOT)/bin
LIBDIR = $(INSTALLROOT)/lib
MAN1MDIR = $(INSTALLROOT)/share/man/man1m
MAN4DIR = $(INSTALLROOT)/share/man/man4
MAN1MEXT = 1m
MAN4EXT = 4
# command to correct section numbers and file names in manual pages
FIXMANCMD = sed -e '/^\.TH/s/8/1m/' -e 's/([18]L)/(1m)/g' -e 's/(5L)/(4)/g' -e 's|/etc/|/etc/opt/conserver/|' -e 's|/usr/local/lib/|/etc/opt/conserver/|'
# command to change program location in script
FIXSCRIPTCMD = sed -e 's!/usr/local!$(PKGROOT)!'
package: pkginfo prototype fakeinstall
test -d $(PKGSPOOLDIR) || mkdir $(PKGSPOOLDIR)
pkgmk -d $(PKGSPOOLDIR) -o -a `uname -p` -r $(INSTALLROOT)
$(RM) -r $(INSTALLROOT)
fakeinstall:
mkdir -p $(BINDIR) $(LIBDIR) $(MAN1MDIR) $(MAN4DIR)
/usr/ucb/install -cs $(BUILDDIR)/conserver/conserver $(BINDIR)/conserver
/usr/ucb/install -cs $(BUILDDIR)/console/console $(BINDIR)/console
$(FIXMANCMD) man_tbl_header $(BUILDDIR)/conserver/conserver.man > $(MAN1MDIR)/conserver.$(MAN1MEXT)
$(FIXMANCMD) man_tbl_header $(BUILDDIR)/console/console.man > $(MAN1MDIR)/console.$(MAN1MEXT)
$(FIXMANCMD) $(BUILDDIR)/conserver.cf/conserver.cf.man > $(MAN4DIR)/conserver.cf.$(MAN4EXT)
$(FIXSCRIPTCMD) $(BUILDDIR)/conserver/conserver.rc > $(LIBDIR)/conserver.rc

@ -0,0 +1 @@
'\" t

@ -0,0 +1,9 @@
PKG="conserver"
NAME="Console server and client"
CATEGORY="system"
VERSION="GNAC-6.12"
DESC="Console server and client"
CLASSES=none
ARCH=sparc
VENDOR="GNAC"
BASEDIR=/opt

@ -0,0 +1,14 @@
!search .
i pkginfo
d none bin 0755 root bin
f none bin/conserver 0755 bin bin
f none bin/console 0755 bin bin
d none lib 0755 root bin
f none lib/conserver.rc 0644 root root
d none share 0755 root bin
d none share/man 0755 bin bin
d none share/man/man1m 0755 bin bin
f none share/man/man1m/conserver.1m 0644 bin bin
f none share/man/man1m/console.1m 0644 bin bin
d none share/man/man4 0755 bin bin
f none share/man/man4/conserver.cf.4 0644 bin bin