*BSD News Article 74511


Return to BSD News archive

Newsgroups: comp.bugs.2bsd
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.hawaii.edu!news.uoregon.edu!news-res.gsl.net!news.gsl.net!news.mathworks.com!zombie.ncsc.mil!newsgate.duke.edu!newshost.convex.com!bcm.tmc.edu!news.uth.tmc.edu!europa.chnt.gtegsc.com!wlbr!moe!sms
From: sms@moe.2bsd.com (Steven M. Schultz)
Subject: #327 changes for kermit5.188 (#328)
Archive-Name: comp.bugs.2bsd
Organization: 2BSD, Simi Valley CA USA
Message-ID: <Duz917.B1C@moe.2bsd.com>
Date: Tue, 23 Jul 1996 03:43:55 GMT
Lines: 1116

Subject: #327 changes for kermit5.188 (#328)
Index:	new/kermit5.188/makefile,ckustr.c,ckustr.sed,cku2tm.c 2.11BSD

Description:
	Update #327 introduced a new ctimed as well as a new library
	containing ctime(3) and getpwnam(3) stubs (-lstubs).  At that
	time the integration of those new modules into the version of
	kermit (5A-188) present in 2.11BSD was deferred until a later time.

Repeat-By:
	Observation.  The 'makefile' in /usr/src/new/kermit5.188 makes no
	mention of '-lstubs'.  Also the 'makefile' explicitly extracts two
	modules from libc.a for inclusion in the overlay scheme.  With the
	new 'ctimed' and stubs library these steps in the 'makefile' are no
	longer needed.

Fix:
	This update has several benefits:

	   1) several hundred bytes of data space is made available (since
	      kermit is on the verge of not running due to data space limits
	      more space is always welcome).

	   2) the overlay scheme is simplified.  It is not good practice to
	      explicitly extract modules from the C library (the filenames
	      may change causing the 'makefile' to break).

	   3) the 'sed' script (ckustr.sed) which frontends the compiler has
	      been enhanced to place additional strings into the strings file.

	These changes have been contributed to the kermit developers and are
	being used in an attempt to get kermit version 6 built for 2.11BSD.

	The kit below includes a shell script to rename aside the existing
	files.  If  you prefer you may simply remove these 4 files from the
	directory /usr/src/new/kermit5.188 instead of running the script:  
	
		makefile, ckustr.c, ckustr.sed, cku2tm.c

	NOTE:  cku2tm.c is *not* used by 2.11BSD.  This file is for 2.10BSD
	       compatibility only. 

		2.11 systems *must* have #327 installed since the preprocessor
		builtin symbol 'BSD2_10' is tested for in ckustr.c.

	To install this update cut where indicated saving to a file (/tmp/328)
	and then:

		cd /tmp
		sh 328
		sh 328.sh
		sh 328.shar
		patch -p0 < 328.patch
		cd /usr/src/new/kermit5.188
		make bsd211

	At this point the mode and ownership of the installed image may vary.
	If you are using kermit to dial out then kermit needs to be setuid
	to the owner of the tty devices used for dialing (typically uucp).

	For now simply install the image without special permissions.

		install -m 755 kermit /usr/new
		install -m 644 kermit5.sr /usr/local/lib/kermit5.sr
		make clean

	This and previous updates are available via anonymous FTP to either
	FTP.2BSD.COM or FTP.IIPO.GTEGSC.COM in the directory /pub/2.11BSD.

==========================cut here========================
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	328.patch
#	328.sh
#	328.shar
# This archive created: Mon Jul 22 20:32:50 1996
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f '328.patch'
then
	echo shar: "will not over-write existing file '328.patch'"
else
sed 's/^X//' << \SHAR_EOF > '328.patch'
X*** /VERSION.old	Wed Jul 10 20:41:34 1996
X--- /VERSION	Mon Jul 22 19:48:37 1996
X***************
X*** 1,4 ****
X! Current Patch Level: 327
X  
X  2.11 BSD
X  ============
X--- 1,4 ----
X! Current Patch Level: 328
X  
X  2.11 BSD
X  ============
SHAR_EOF
fi
if test -f '328.sh'
then
	echo shar: "will not over-write existing file '328.sh'"
else
sed 's/^X//' << \SHAR_EOF > '328.sh'
X#!/bin/sh
X
Xif [ -d /usr/src/new/kermit5.188 ]; then
X	cd /usr/src/new/kermit5.188
X	mv -f cku2tm.c cku2tm.c.old
X	mv -f ckustr.c ckustr.c.old
X	mv -f ckustr.sed ckustr.sed.old
X	mv -f makefile makefile.old
Xfi
SHAR_EOF
chmod +x '328.sh'
fi
if test -f '328.shar'
then
	echo shar: "will not over-write existing file '328.shar'"
else
sed 's/^X//' << \SHAR_EOF > '328.shar'
X#! /bin/sh
X# This is a shell archive, meaning:
X# 1. Remove everything above the #! /bin/sh line.
X# 2. Save the resulting text in a file.
X# 3. Execute the file with /bin/sh (not csh) to create:
X#	/usr/src/new/kermit5.188/cku2tm.c
X#	/usr/src/new/kermit5.188/ckustr.c
X#	/usr/src/new/kermit5.188/ckustr.sed
X#	/usr/src/new/kermit5.188/makefile
X# This archive created: Mon Jul 22 20:20:08 1996
Xexport PATH; PATH=/bin:/usr/bin:$PATH
Xif test -f '/usr/src/new/kermit5.188/cku2tm.c'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/new/kermit5.188/cku2tm.c'"
Xelse
Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/new/kermit5.188/cku2tm.c'
XZ/*
XZ * Steven Schultz - sms@moe.2bsd.com
XZ *
XZ *	@(#)ctimed.c	1.0 (2.11BSD) 1996/6/25
XZ *
XZ * ctimed - the daemon that supports the ctime() and getpw*() stubs
XZ * 	    in 'libcstubs.a'.
XZ*/
XZ
XZ#include	<signal.h>
XZ#include	<stdio.h>
XZ#include	<setjmp.h>
XZ#include	<sys/ioctl.h>
XZ#include	<sys/types.h>
XZ#include	<sys/time.h>
XZ#include	<pwd.h>
XZ#include	<utmp.h>
XZ
XZ/*
XZ * These should probably be placed in an include file.  If you add anything
XZ * here then you will also have to modify /usr/src/usr.lib/libstubs/stubs.c
XZ * (if for no other reason than to add the stub code).
XZ*/
XZ
XZ#define	CTIME	1
XZ#define	ASCTIME	2
XZ#define	TZSET	3
XZ#define	LOCALTIME 4
XZ#define	GMTIME	5
XZ#define	OFFTIME	6
XZ
XZ#define	GETPWENT	7
XZ#define	GETPWNAM	8
XZ#define	GETPWUID	9
XZ#define	SETPASSENT	10
XZ#define	ENDPWENT	11
XZ
XZextern	struct	tm	*offtime();
XZ
XZ	jmp_buf	env;
XZ	char	*cp;
XZ	char	junk[256 + sizeof (struct passwd) + 4];
XZ	long	off;
XZ	time_t	l;
XZ	void	timeout(), checkppid();
XZ	struct	tm	tmtmp, *tp;
XZ
XZmain()
XZ	{
XZ	register int i;
XZ	register struct passwd *pw;
XZ	struct	itimerval it;
XZ	u_char	c, xxx;
XZ	int	len, tosslen;
XZ	uid_t	uid;
XZ
XZ	signal(SIGPIPE, SIG_DFL);
XZ	for	(i = getdtablesize(); --i > 2; )
XZ		close(i);
XZ/*
XZ * Need a timer running while we disassociate from the control terminal
XZ * in case of a modem line which has lost carrier.
XZ*/
XZ	timerclear(&it.it_interval);
XZ	it.it_value.tv_sec = 5;
XZ	it.it_value.tv_usec = 0;
XZ	signal(SIGALRM, timeout);
XZ	setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL);
XZ	if	(setjmp(env) == 0)
XZ		{
XZ		i = open("/dev/tty", 0);
XZ		if	(i >= 0)
XZ			{
XZ			ioctl(i, TIOCNOTTY, NULL);
XZ			close(i);
XZ			}
XZ		}
XZ/*
XZ * Now start a timer with one minute refresh.  In the signal service
XZ * routine, check the parent process id to see if this process has
XZ * been orphaned and if so exit.  This is primarily aimed at removing
XZ * the 'ctimed' process left behind by 'sendmail's multi-fork startup
XZ * but may prove useful in preventing accumulation of 'ctimed' processes
XZ * in other circumstances as well.  Normally this process is short
XZ * lived.
XZ*/
XZ	it.it_interval.tv_sec = 60;
XZ	it.it_interval.tv_usec = 0;
XZ	it.it_value.tv_sec = 60;
XZ	it.it_value.tv_usec = 0;
XZ	signal(SIGALRM, checkppid);
XZ	setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL);
XZ
XZ	while	(read(fileno(stdin), &c, 1) == 1)
XZ		{
XZ		switch	(c)
XZ			{
XZ			case	CTIME:
XZ				l = 0L;
XZ				getb(fileno(stdin), &l, sizeof l);
XZ				cp = ctime(&l);
XZ				write(fileno(stdout), cp, 26);
XZ				break;
XZ			case	ASCTIME:
XZ				getb(fileno(stdin), &tmtmp, sizeof tmtmp);
XZ				cp = asctime(&tmtmp);
XZ				write(fileno(stdout), cp, 26);
XZ				break;
XZ			case	TZSET:
XZ				(void) tzset();
XZ				break;
XZ			case	LOCALTIME:
XZ				l = 0L;
XZ				getb(fileno(stdin), &l, sizeof l);
XZ				tp = localtime(&l);
XZ				write(fileno(stdout), tp, sizeof (*tp));
XZ				strcpy(junk, tp->tm_zone);
XZ				junk[24] = '\0';
XZ				write(fileno(stdout), junk, 24);
XZ				break;
XZ			case	GMTIME:
XZ				l = 0L;
XZ				getb(fileno(stdin), &l, sizeof l);
XZ				tp = gmtime(&l);
XZ				write(fileno(stdout), tp, sizeof (*tp));
XZ				strcpy(junk, tp->tm_zone);
XZ				junk[24] = '\0';
XZ				write(fileno(stdout), junk, 24);
XZ				break;
XZ			case	OFFTIME:
XZ				getb(fileno(stdin), &l, sizeof l);
XZ				getb(fileno(stdin), &off, sizeof off);
XZ#ifdef	__bsdi__
XZ				l += off;
XZ				tp = localtime(&l);
XZ#else
XZ				tp = offtime(&l, off);
XZ#endif
XZ				write(fileno(stdout), tp, sizeof (*tp));
XZ				break;
XZ			case	GETPWENT:
XZ				pw = getpwent();
XZ				do_pw(pw);
XZ				break;
XZ			case	GETPWNAM:
XZ				getb(fileno(stdin), &len, sizeof (int));
XZ				if	(len > UT_NAMESIZE)
XZ					{
XZ					tosslen = len - UT_NAMESIZE;
XZ					len = UT_NAMESIZE;
XZ					}
XZ				else
XZ					tosslen = 0;
XZ				getb(fileno(stdin), junk, len);
XZ				for	(;tosslen; tosslen--)
XZ					getb(fileno(stdin), &xxx, 1);
XZ				junk[len] = '\0';
XZ				pw = getpwnam(junk);
XZ				do_pw(pw);
XZ				break;
XZ			case	GETPWUID:
XZ				getb(fileno(stdin), &uid, sizeof (uid_t));
XZ				pw = getpwuid(uid);
XZ				do_pw(pw);
XZ				break;
XZ			case	SETPASSENT:
XZ				getb(fileno(stdin), &len, sizeof (int));
XZ				if	(setpassent(len))
XZ					len = 1;
XZ				else
XZ					len = 0;
XZ				write(fileno(stdout), &len, sizeof (int));
XZ				break;
XZ			case	ENDPWENT:
XZ				endpwent();
XZ				break;
XZ			default:
XZ				abort("switch");
XZ			}
XZ		}
XZ	}
XZ
XZgetb(f, p, n)
XZ	int	f;
XZ	register char	*p;
XZ	register int	n;
XZ	{
XZ	register int	i;
XZ
XZ	while	(n)
XZ		{
XZ		i = read(f, p, n);
XZ		if	(i <= 0)
XZ			return;
XZ		p += i;
XZ		n -= i;
XZ		}
XZ	}
XZ
XZvoid
XZtimeout()
XZ	{
XZ
XZ	longjmp(env, 1);
XZ	}
XZ
XZvoid
XZcheckppid()
XZ	{
XZ
XZ	if	(getppid() == 1)
XZ		exit(0);
XZ	}
XZ
XZdo_pw(pw)
XZ	struct passwd *pw;
XZ	{
XZ	int	len;
XZ
XZ	if	(!pw)
XZ		{
XZ		len = 0;
XZ		write(fileno(stdout), &len, sizeof (int));
XZ		return;
XZ		}
XZ	len = packpwtobuf(pw, junk);
XZ	write(fileno(stdout), &len, sizeof (int));
XZ	write(fileno(stdout), pw, sizeof (*pw));
XZ	write(fileno(stdout), junk, len);
XZ	return;
XZ	}
XZ
XZpackpwtobuf(pw, buf)
XZ	register struct passwd *pw;
XZ	char	*buf;
XZ	{
XZ	register char *cp = buf;
XZ	register char *dp;
XZ
XZ	dp = pw->pw_name;
XZ	pw->pw_name = (char*) 0;
XZ	while	(*cp++ = *dp++)
XZ		;
XZ	dp = pw->pw_passwd;
XZ	pw->pw_passwd = (char*) (cp - buf);
XZ	while	(*cp++ = *dp++)
XZ		;
XZ	dp = pw->pw_class;
XZ	pw->pw_class = (char*) (cp - buf);
XZ	while	(*cp++ = *dp++)
XZ		;
XZ	dp = pw->pw_gecos;
XZ	pw->pw_gecos = (char*) (cp - buf);
XZ	while	(*cp++ = *dp++)
XZ		;
XZ	dp = pw->pw_dir;
XZ	pw->pw_dir = (char*) (cp - buf);
XZ	while	(*cp++ = *dp++)
XZ		;
XZ	dp = pw->pw_shell;
XZ	pw->pw_shell = (char*) (cp - buf);
XZ	while	(*cp++ = *dp++)
XZ		;
XZ	return(cp - buf);
XZ	}
XSHAR_EOF
Xchmod 640 '/usr/src/new/kermit5.188/cku2tm.c'
Xfi
Xif test -f '/usr/src/new/kermit5.188/ckustr.c'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/new/kermit5.188/ckustr.c'"
Xelse
Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/new/kermit5.188/ckustr.c'
XZ/*
XZ  Copyright (C) 1985, 1996, Trustees of Columbia University in the City of New
XZ  York.  The C-Kermit software may not be, in whole or in part, licensed or
XZ  sold for profit as a software product itself, nor may it be included in or
XZ  distributed with commercial products or otherwise distributed by commercial
XZ  concerns to their clients or customers without written permission of the
XZ  Office of Kermit Development and Distribution, Columbia University.  This
XZ  copyright notice must not be removed, altered, or obscured.
XZ*/
XZ
XZ/*
XZ * ckustr.c - string extraction/restoration routines
XZ*/
XZ
XZ#include <stdio.h>
XZ#include <sysexits.h>
XZ#include <varargs.h>
XZ#include <paths.h>
XZ
XZ/*
XZ  STR_FILE must be defined as a quoted string on the cc command line,
XZ  for example:
XZ
XZ  	-DSTR_FILE=\\\"/usr/local/lib/kermit5.sr\\\"
XZ
XZ  This is the file where the strings go, and where C-Kermit looks for them
XZ  at runtime.
XZ*/
XZ
XZ#ifdef STR_FILE
XZchar	*StringFile = STR_FILE;
XZ#else
XZchar	*StringFile = "/usr/local/lib/kermit5.sr";
XZ#endif /* STR_FILE */
XZ
XZ/*
XZ * If _PATH_CTIMED is defined (in <paths.h>) then use that definition.  2.11BSD
XZ * has this defined but 2.10BSD and other systems do not.
XZ*/
XZ
XZ#ifndef _PATH_CTIMED
XZ#define	_PATH_CTIMED STR_CTIMED
XZ#endif
XZ
XZextern int errno;
XZstatic int strfile = -1, ourpid = 0;
XZ
XZ#define BUFLEN 256
XZ
XZerrprep(offset, buf)
XZunsigned short offset;
XZchar *buf;
XZ{
XZregister int pid = getpid();
XZ
XZ	if (pid != ourpid) {
XZ		ourpid = pid;
XZ		if (strfile >= 0) {
XZ			close(strfile);
XZ			strfile = -1;
XZ		}
XZ	}
XZ	if (strfile < 0) {
XZ	        char *p, *getenv();
XZ		if (p = getenv("KSTR"))
XZ		  if (strlen(p))
XZ		    StringFile = p;
XZ		strfile = open(StringFile, 0);
XZ		if (strfile < 0) {
XZoops:
XZ			fprintf(stderr, "Cannot find %s\r\n", StringFile);
XZ			exit(EX_OSFILE);
XZ		}
XZ	}
XZ	if (lseek(strfile, (long) offset, 0) < 0
XZ			|| read(strfile, buf, BUFLEN) <= 0)
XZ		goto oops;
XZ}
XZ
XZ/* extracted string front end for printf() */
XZ/*VARARGS1*/
XZstrprerror(fmt, va_alist)
XZ	int fmt;
XZ	va_dcl
XZ{
XZ	va_list	ap;
XZ	char buf[BUFLEN];
XZ
XZ	errprep(fmt, buf);
XZ	va_start(ap);
XZ	vprintf(buf, ap);
XZ	va_end(ap);
XZ}
XZ
XZ/* extracted string front end for sprintf() */
XZ/*VARARGS1*/
XZstrsrerror(fmt, obuf, va_alist)
XZ	int fmt;
XZ	char *obuf;
XZ	va_dcl
XZ{
XZ	char buf[BUFLEN];
XZ	va_list	ap;
XZ
XZ	errprep(fmt, buf);
XZ	va_start(ap);
XZ	vsprintf(obuf, buf, ap);
XZ	va_end(ap);
XZ}
XZ
XZ/* extracted string front end for fprintf() */
XZ/*VARARGS1*/
XZstrfrerror(fmt, fd, va_alist)
XZ	int fmt;
XZ	FILE *fd;
XZ	va_dcl
XZ{
XZ	va_list	ap;
XZ	char buf[BUFLEN];
XZ
XZ	errprep(fmt, buf);
XZ	va_start(ap);
XZ	vfprintf(fd, buf, ap);
XZ	va_end(ap);
XZ}
XZ
XZ/* extracted string front end for perror() */
XZstrperror(fmt)
XZ	int fmt;
XZ{
XZ	char buf[BUFLEN];
XZ	register int saverr = errno;
XZ
XZ	errprep(fmt, buf);
XZ	errno = saverr;
XZ	perror(buf);
XZ}
XZ
XZperror(str)
XZ	char	*str;
XZ	{
XZ
XZ	printf("%s: errno %d\n", str, errno);
XZ	}
XZ
XZ/*
XZ * The following is needed _only_ on systems which do not have the C library
XZ * stubs for the ctime() and getpw*() functions.  In 2.11BSD these are
XZ * present in the libstubs.a library and accessed via "-lstubs" at link time.
XZ *
XZ * 2.10BSD's cpp has the BSD2_10 symbol builtin.  Other systems without 
XZ * libstubs.a will need to define (via a -D option in CFLAGS) 'BSD2_10'.
XZ*/
XZ
XZ#ifdef	BSD2_10
XZ
XZ#include <sys/types.h>
XZ#include <sys/time.h>
XZ#include <pwd.h>
XZ#include <utmp.h>
XZ
XZ#define	SEND_FD	W[1]
XZ#define	RECV_FD	R[0]
XZ
XZ#define	CTIME	1
XZ#define	ASCTIME	2
XZ#define	TZSET	3
XZ#define	LOCALTIME 4
XZ#define	GMTIME	5
XZ#define	OFFTIME	6
XZ
XZ#define GETPWENT        7
XZ#define GETPWNAM        8
XZ#define GETPWUID        9
XZ#define SETPASSENT      10
XZ#define ENDPWENT        11
XZ
XZ	static	int	R[2], W[2], inited;
XZ	static	char	result[256 + 4];
XZ	static	struct	tm	tmtmp;
XZ	static	struct	passwd	_pw, *getandfixpw();
XZ
XZchar	*
XZctime(t)
XZ	time_t	*t;
XZ	{
XZ	u_char	fnc = CTIME;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	write(SEND_FD, t, sizeof (*t));
XZ	getb(RECV_FD, result, 26);
XZ	return(result);
XZ	}
XZ
XZchar	*
XZasctime(tp)
XZ	struct	tm	*tp;
XZ	{
XZ	u_char	fnc = ASCTIME;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	write(SEND_FD, tp, sizeof (*tp));
XZ	getb(RECV_FD, result, 26);
XZ	return(result);
XZ	}
XZ
XZvoid
XZtzset()
XZ	{
XZ	u_char	fnc = TZSET;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	}
XZ
XZstruct	tm *
XZlocaltime(tp)
XZ	time_t	*tp;
XZ	{
XZ	u_char	fnc = LOCALTIME;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	write(SEND_FD, tp, sizeof (*tp));
XZ	getb(RECV_FD, &tmtmp, sizeof tmtmp);
XZ	getb(RECV_FD, result, 24);
XZ	tmtmp.tm_zone = result;
XZ	return(&tmtmp);
XZ	}
XZ
XZstruct	tm *
XZgmtime(tp)
XZ	time_t	*tp;
XZ	{
XZ	u_char	fnc = GMTIME;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	write(SEND_FD, tp, sizeof (*tp));
XZ	getb(RECV_FD, &tmtmp, sizeof tmtmp);
XZ	getb(RECV_FD, result, 24);
XZ	tmtmp.tm_zone = result;
XZ	return(&tmtmp);
XZ	}
XZ
XZstruct	tm *
XZofftime(clock, offset)
XZ	time_t	*clock;
XZ	long	offset;
XZ	{
XZ	u_char	fnc = OFFTIME;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	write(SEND_FD, clock, sizeof (*clock));
XZ	write(SEND_FD, &offset, sizeof offset);
XZ	getb(RECV_FD, &tmtmp, sizeof tmtmp);
XZ	tmtmp.tm_zone = "";
XZ	return(&tmtmp);
XZ	}
XZ
XZstruct passwd *
XZgetpwent()
XZ	{
XZ	u_char	fnc = GETPWENT;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	return(getandfixpw());
XZ	}
XZ
XZstruct	passwd *
XZgetpwnam(nam)
XZ	char	*nam;
XZ	{
XZ	u_char	fnc = GETPWNAM;
XZ	char	lnam[UT_NAMESIZE + 1];
XZ	int	len;
XZ
XZ	len = strlen(nam);
XZ	if	(len > UT_NAMESIZE)
XZ		len = UT_NAMESIZE;
XZ	bcopy(nam, lnam, len);
XZ	lnam[len] = '\0';
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, 1);
XZ	write(SEND_FD, &len, sizeof (int));
XZ	write(SEND_FD, lnam, len);
XZ	return(getandfixpw());
XZ	}
XZ
XZstruct	passwd	*
XZgetpwuid(uid)
XZ	uid_t	uid;
XZ	{
XZ	u_char	fnc = GETPWUID;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	write(SEND_FD, &uid, sizeof (uid_t));
XZ	return(getandfixpw());
XZ	}
XZ
XZsetpwent()
XZ	{
XZ	return(setpassent(0));
XZ	}
XZ
XZsetpassent(stayopen)
XZ	int	stayopen;
XZ	{
XZ	u_char	fnc = SETPASSENT;
XZ	int	sts;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	write(SEND_FD, &stayopen, sizeof (int));
XZ	getb(RECV_FD, &sts, sizeof (int));
XZ	return(sts);
XZ	}
XZ
XZvoid
XZendpwent()
XZ	{
XZ	u_char	fnc = ENDPWENT;
XZ
XZ	sewer();
XZ	write(SEND_FD, &fnc, sizeof fnc);
XZ	return;
XZ	}
XZ
XZ/* setpwfile() is deprecated */
XZvoid
XZsetpwfile(file)
XZ	char	*file;
XZ	{
XZ	return;
XZ	}
XZ
XZstruct passwd *
XZgetandfixpw()
XZ	{
XZ	short	sz;
XZ
XZ	getb(RECV_FD, &sz, sizeof (int));
XZ	if	(sz == 0)
XZ		return(NULL);
XZ	getb(RECV_FD, &_pw, sizeof (_pw));
XZ	getb(RECV_FD, result, sz);
XZ	_pw.pw_name += (int)result;
XZ	_pw.pw_passwd += (int)result;
XZ	_pw.pw_class += (int)result;
XZ	_pw.pw_gecos += (int)result;
XZ	_pw.pw_dir += (int)result;
XZ	_pw.pw_shell += (int)result;
XZ	return(&_pw);
XZ	}
XZ
XZgetb(f, p, n)
XZ	register int f, n;
XZ	register char *p;
XZ	{
XZ	int	i;
XZ
XZ	while	(n)
XZ		{
XZ		i = read(f, p, n);
XZ		if	(i <= 0)
XZ			return;
XZ		p += i;
XZ		n -= i;
XZ		}
XZ	}
XZ
XZsewer()
XZ	{
XZ	register int	pid, ourpid = getpid();
XZ
XZ	if	(inited == ourpid)
XZ		return;
XZ	if	(inited)
XZ		{
XZ		close(SEND_FD);
XZ		close(RECV_FD);
XZ		}
XZ	pipe(W);
XZ	pipe(R);
XZ	pid = vfork();
XZ	if	(pid == 0)
XZ		{			/* child */
XZ		alarm(0);		/* cancel alarms */
XZ		dup2(W[0], 0);		/* parent write side to our stdin */
XZ		dup2(R[1], 1);		/* parent read side to our stdout */
XZ		close(SEND_FD);		/* copies made, close the... */
XZ		close(RECV_FD);		/* originals now */
XZ		execl(_PATH_CTIMED, "ctimed", 0);
XZ		_exit(EX_OSFILE);
XZ		}
XZ	if	(pid == -1)
XZ		abort();		/* nothing else really to do */
XZ	close(W[0]);			/* close read side of SEND channel */
XZ	close(R[1]);			/* close write side of RECV channel */
XZ	inited = ourpid;		/* don't do this again in this proc */
XZ	}
XZ
XZXXctime()
XZ	{
XZ
XZ	if	(SEND_FD)
XZ		close(SEND_FD);
XZ	if	(RECV_FD)
XZ		close(RECV_FD);
XZ	SEND_FD = RECV_FD = 0;
XZ	inited = 0;
XZ	}
XZ#endif	/* BSD2_10 */
XSHAR_EOF
Xchmod 644 '/usr/src/new/kermit5.188/ckustr.c'
Xfi
Xif test -f '/usr/src/new/kermit5.188/ckustr.sed'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/new/kermit5.188/ckustr.sed'"
Xelse
Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/new/kermit5.188/ckustr.sed'
XZ#! /bin/sh
XZ# Special cc preprocessor for using mkstr(1) to extract strings from the
XZ# kermit5 source.  Change the "CC=cc" line to "CC=./ckustr.sed" to use
XZ# string extraction.  NOTE: the file ckustr.c might need the StringFile
XZ# declaration modified to suit local system requirements.  When installing
XZ# the kermit executable be sure to install kermit.sr and make it readable
XZ# by the public (mode 444).
XZ
XZSTRINGS=kermit5.sr
XZ
XZ# Get filename and arguments.
XZinitargs=$@
XZwhile [ -n "$1" ]
XZdo
XZ	if [ $1 = -o ]
XZ	then
XZ		exec cc $initargs
XZ		exit 1
XZ	fi
XZ	if [ `expr substr $1 1 1` = - ]
XZ	then
XZ		if [ $1 != -c ]
XZ		then
XZ			args="$args $1"
XZ		fi
XZ	else
XZ		csrc=$1
XZ	fi
XZ	shift
XZdone
XZ
XZ# Only process compilations, and then only for certain files.
XZif [ $csrc = ckustr.c -o $csrc = ckwart.c ]
XZthen
XZ	exec cc $initargs
XZ	exit 1
XZfi
XZ
XZ# String extractions
XZecho Extracting strings from ${csrc}...
XZcc -E $args $csrc > xxmk.c
XZsed -e 's/ferror(/strferrorf(/'				\
XZ    -e 's/perror("/strperror("/'			\
XZ    -e 's/experror(/strexperrorf(/'			\
XZ    -e 's/sprintf(\([^,][^,]*\),[ ]*\("[^"]*"\)\([,)]\)/strsrerror(\2, \1\3/' \
XZ    -e '/sprintf(\([^,][^,]*\),/{N
XZs/sprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strsrerror(\2, \1\3/
XZ}'							\
XZ    -e 's/fprintf(\([^,][^,]*\),[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/' \
XZ    -e '/fprintf(\([^,][^,]*\),/{N
XZs/fprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/
XZ}'							\
XZ    -e 's/printf[ ]*("/strprerror("/'		\
XZ    -e '/printf[ ]*(/{N
XZs/printf[ ]*(\n"/strprerror("/
XZ}' xxmk.c > mk.c
XZmkstr - $STRINGS xx mk.c
XZsed -e 's/^# \([0-9]\)/#line \1/' xxmk.c | xstr -c -
XZecho Compiling...
XZcc -Dstrferrorf=ferror -Dstrexperrorf=experror $args -c x.c
XZmv x.o `basename $csrc .c`.o
XZrm -f x.c mk.c xxmk.c
XSHAR_EOF
Xchmod 751 '/usr/src/new/kermit5.188/ckustr.sed'
Xfi
Xif test -f '/usr/src/new/kermit5.188/makefile'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/new/kermit5.188/makefile'"
Xelse
Xsed 's/^Z//' << \SHAR_EOF > '/usr/src/new/kermit5.188/makefile'
XZ# CKUBS2.MAK, Wed Jul  17 22:10:40 1996
XZ#
XZ# Abbreviated version for 2.10 / 2.11 BSD, which chokes on full-size makefile
XZ# because "Make: out of memory".
XZ#
XZ# Instructions:
XZ#   1. Make sure there are no other files called "makefile" or "Makefile"
XZ#      in the same directory.
XZ#   2. Change the name of this file to "makefile".
XZ#   3. Read below about the strings file.
XZ#   4. "make bsd211"
XZ#   5. If you are not on a system with /usr/lib/ctimed (2.10BSD for example),
XZ#      type "make bsd210" (which will compile cku2tm.c into 'ctimed')
XZ#      and then install 'ctimed' in the right place (default is /usr/lib).
XZ#
XZ# Author: Frank da Cruz, Columbia University Center for Computing Activities
XZ# 612 West 115th Street, New York, NY 10025, USA.  Phone (212) 854-5126.
XZ# e-mail: fdc@watsun.cc.columbia.edu, fdc@columbia.edu, or FDCCU@CUVMA.BITNET.
XZ# BSD 2.10/2.11 specifics by Steven M Schultz, sms@wlv.iipo.gtegsc.com.
XZ#
XZ# Modified 17 July 1996 to make use of '-lstubs' and _PATH_CTIMED in 2.11BSD.
XZ#    Also revised the sed script (ckustr.sed). sms.
XZ# Modified 4 July 1992 to reshuffle overlays (because the first one got too
XZ#   big) and to improve the method of defining the string file.  fdc.
XZ# And again 23 Aug 1992.  fdc.
XZ# And again 06 Sep 1992 to work around ckudia.c blowing up optimizers.  sms.
XZ# And again 09 Sep 1992 to incorporate cku2tm.c and new ckustr.c.  sms.
XZ# & again 19 Sep 92 to add -DMINIDIAL to reduce size of DIAL module.  fdc.
XZ# & again 7 Nov 92 because two of the segments got too big.  fdc.
XZ#
XZ###########################################################################
XZ#
XZ# 2.10BSD and 2.11BSD (the latter to a larger extent) are the same as 4.3BSD
XZ# but without a large address space.
XZ#
XZ# A string extraction method is used to put approx. 10kb of strings into
XZ# a file. The module ckustr.c needs to find this file when C-Kermit runs.  
XZ# The pathname where this file will reside is defined below (change it if
XZ# necessary).  After make is finished, the file kermit5.sr must be moved
XZ# to where ckustr.c has been told to look for it.
XZ#
XZ# For testing purposes, you can define an environment variable KSTR to
XZ# override the built-in pathname, for example:
XZ#
XZ#  setenv KSTR `pwd`/kermit5.sr
XZ#
XZ# If the resulting wermit program sprews garbage all over your screen, it's
XZ# because it is reading the wrong strings file.
XZ#
XZ# If the resulting wermit program doesn't run at all because UNIX says it
XZ# is out of memory, it's most likely because one of the overlays is too big.
XZ# The maximum size is 48K (49152 bytes) for the base segment and 15K (16384
XZ# bytes) for each overlay.  For example:
XZ#
XZ#  % size wermit
XZ#  48000 + 23702 + 31064
XZ#  16512,15936,15488,11072
XZ#
XZ# This shows that the first overlay is too large.  The cure is move the
XZ# smallest module from the first overlay into the last (smallest) overlay.
XZ# Try hard not to mess with the selection of modules in the root segment.
XZ#
XZ###########################################################################
XZ#
XZ# Compile and Link variables:
XZ#
XZ# EXT is the extension (file type) for object files, normally o.
XZ# EFLAGS is the set of options and flags _EXCLUDING_ the optimize flag.
XZ#
XZEXT=o
XZOPT= -O
XZEFLAGS=-DBSD43 -DLCKDIR -DNODEBUG -DNOTLOG -DMINIDIAL \
XZ	-DNOCSETS -DNOHELP -DNOSCRIPT -DNOSPL -DNOXMIT -DNOSETBUF $(KFLAGS) \
XZ	-DSTR_FILE=\\\"/usr/local/lib/kermit5.sr\\\"
XZLNKFLAGS= -i
XZCC=./ckustr.sed
XZCC2=cc
XZ#
XZ###########################################################################
XZ#
XZ# Dependencies Section, including wermit overlay structure.
XZ
XZwermit: ckcmai.$(EXT) ckucmd.$(EXT) ckuusr.$(EXT) ckuus2.$(EXT) \
XZ	ckuus3.$(EXT) ckuus4.$(EXT) ckuus5.$(EXT) ckcpro.$(EXT) \
XZ	ckcfns.$(EXT) ckcfn2.$(EXT) ckcfn3.$(EXT) ckuxla.$(EXT) \
XZ	ckucon.$(EXT) ckutio.$(EXT) ckufio.$(EXT) ckudia.$(EXT) \
XZ	ckuscr.$(EXT) ckcnet.$(EXT) ckuus6.$(EXT) ckuus7.$(EXT) ckuusx.$(EXT) \
XZ	ckuusy.$(EXT) ckustr.o strings.o
XZ	$(CC2) $(LNKFLAGS) -o wermit \
XZ		ckutio.$(EXT) ckufio.$(EXT) ckcfns.$(EXT) ckcfn2.$(EXT) \
XZ		ckcfn3.$(EXT) \
XZ		 -Z ckcmai.$(EXT) ckuusr.$(EXT) ckucmd.$(EXT) \
XZ		 -Z ckuus4.$(EXT) ckuus5.$(EXT) ckcpro.$(EXT) ckuus6.$(EXT) \
XZ		 -Z ckuus7.$(EXT) ckudia.$(EXT) ckuscr.$(EXT) ckcnet.$(EXT) \
XZ		    ckuusy.$(EXT) \
XZ		 -Z ckuus2.$(EXT) ckuusx.$(EXT) ckucon.$(EXT) \
XZ		    ckuus3.$(EXT) \
XZ		 -Y ckustr.o strings.o $(LIBS)
XZ
XZstrings.o: strings
XZ	xstr
XZ	cc -c xs.c
XZ	mv -f xs.o strings.o
XZ	rm -f xs.c
XZ
XZ###########################################################################
XZ# Dependencies for each module...
XZ#
XZckcmai.$(EXT): ckcmai.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcnet.h
XZ
XZckcpro.$(EXT): ckcpro.c ckcker.h ckcdeb.h ckcasc.h
XZ
XZckcpro.c: ckcpro.w wart ckcdeb.h ckcasc.h ckcker.h
XZ	./wart ckcpro.w ckcpro.c
XZ
XZckcfns.$(EXT): ckcfns.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcxla.h \
XZ		ckuxla.h
XZ
XZckcfn2.$(EXT): ckcfn2.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcxla.h ckuxla.h
XZ
XZckcfn3.$(EXT): ckcfn3.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcxla.h \
XZ		ckuxla.h
XZ
XZckuxla.$(EXT): ckuxla.c ckcker.h ckcdeb.h ckcxla.h ckuxla.h
XZ
XZckuusr.$(EXT): ckuusr.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \
XZ		ckcasc.h ckcnet.h
XZ
XZckuus2.$(EXT): ckuus2.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \
XZ		ckcasc.h
XZ
XZckuus3.$(EXT): ckuus3.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \
XZ		ckcasc.h ckcnet.h
XZ
XZckuus4.$(EXT): ckuus4.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \
XZ		ckcasc.h ckcnet.h
XZ
XZckuus5.$(EXT): ckuus5.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcasc.h
XZ
XZckuus6.$(EXT): ckuus6.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcasc.h
XZ
XZckuus7.$(EXT): ckuus7.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \
XZ		ckcasc.h ckcnet.h
XZ
XZckuusx.$(EXT): ckuusx.c  ckcker.h ckuusr.h ckcdeb.h ckcasc.h
XZ
XZckuusy.$(EXT): ckuusy.c  ckcker.h ckcdeb.h ckcasc.h
XZ
XZckucmd.$(EXT): ckucmd.c ckcasc.h ckucmd.h ckcdeb.h
XZ
XZckufio.$(EXT): ckufio.c ckcdeb.h ckuver.h
XZ
XZckutio.$(EXT): ckutio.c ckcdeb.h ckcnet.h ckuver.h
XZ
XZckucon.$(EXT): ckucon.c ckcker.h ckcdeb.h ckcasc.h ckcnet.h
XZ
XZckcnet.$(EXT): ckcnet.c ckcdeb.h ckcker.h ckcnet.h
XZ
XZwart: ckwart.$(EXT)
XZ	$(CC) $(LNKFLAGS) -o wart ckwart.$(EXT)
XZ
XZckcmdb.$(EXT): ckcmdb.c ckcdeb.h
XZ
XZckwart.$(EXT): ckwart.c
XZ
XZckudia.$(EXT): ckudia.c ckcker.h ckcdeb.h ckucmd.h ckcasc.h
XZ	$(CC) CFLAGS=${EFLAGS} -c ckudia.c
XZ
XZckuscr.$(EXT): ckuscr.c ckcker.h ckcdeb.h ckcasc.h
XZ
XZ#2.11BSD
XZ#
XZbsd211:
XZ	@echo "Making C-Kermit 5A for 2BSD with overlays..."
XZ	@echo -n "Be sure to install kermit5.sr with the same pathname"
XZ	@echo " specified in ckustr.c!"
XZ	chmod +x ckustr.sed
XZ	make wermit CFLAGS="${OPT} ${EFLAGS}" LIBS=-lstubs
XZ
XZ#2.10BSD
XZ#
XZbsd210:
XZ	@echo -n "Be sure to install ctimed with the same pathname"
XZ	@echo " specified in ckustr.c for STR_CTIMED!"
XZ	@echo "Making C-Kermit 5A for 2BSD with overlays..."
XZ	@echo -n "Be sure to install kermit5.sr with the same pathname"
XZ	@echo " specified in ckustr.c!"
XZ	chmod +x ckustr.sed
XZ	make wermit ctimed CFLAGS="${OPT} ${EFLAGS} \
XZ			-DSTR_CTIMED=\\\"/usr/lib/ctimed\\\""
XZ
XZctimed:
XZ	$(CC2) $(CFLAGS) $(LNKFLAGS) -o ctimed cku2tm.c
XZ
XZ#Clean up intermediate and object files
XZclean:
XZ	@echo 'Removing intermediate files...'
XZ	-rm -f *.$(EXT) ckcpro.c wart strings kermit5.sr ctimed wermit xs.c
XZ	-rm -f xxmk.c mk.c x.c
XSHAR_EOF
Xchmod 644 '/usr/src/new/kermit5.188/makefile'
Xfi
Xexit 0
X#	End of shell archive
SHAR_EOF
fi
exit 0
#	End of shell archive