#!/bin/sh
#
#    This is a SHAR archive.  To extract, remove everything
#    above the #!/bin/sh line and type "sh filename"
#
if `test ! -d ./ppp-sparc4.1`
then
    mkdir ./ppp-sparc4.1
    echo "mkdir ./ppp-sparc4.1"
fi
if `test ! -s ./ppp-sparc4.1/README`
then
    echo "Writing ./ppp-sparc4.1/README"
    sed 's/^X//' > ./ppp-sparc4.1/README << '\End\of\File\ ./ppp-sparc4.1/README'
XI run PPP between crappie.morningstar.com (137.175.6.3, my home
Xmachine) and remora.morningstar.com (137.175.2.7, my workstation at
Xthe office).  This document describes how I use it.  The installation
Xof PPP itself is covered in the PPP distribution.
X
XI put a line like this in remora's /etc/passwd:
X
X Pkarl:2y4613BDaQD3x:51:10:Karl's PPP login:/tmp:/usr/local/etc/pppstart-karl
X
XI created a login shell script on remora called
X/usr/local/etc/pppstart-karl:
X
X #!/bin/sh
X /usr/bin/mesg n
X stty -tostop
X exec /usr/local/etc/ppp 137.175.6.2:
X
XI have this line in my ~/.xinitrc file:
X
X ppp-on &
X
XThis shell script, plus the ppp-off, unlock and fix-cua scripts and
Xthe source to the chat program are included.  You will need to heavily
Xmodify these to suit your own situation, including Internet addresses,
Xmachine names, telephone numbers, modem dialing commands, baud rates,
Xlogin names and passwords.  Make the "ppp..." command in the ppp-on
Xscript look something like this:
X
X ppp -v 137.175.6.3: /dev/cua &
X
XThe "137.175.6.3:" is of the format "local-addr:remote-addr" with the
Xremote address null (it will be negotiated by PPP).  Look at the login
Xshell script above; it can be common to all dial-in PPP users on your
Xmachine because it only specifies the address of the remora
X(receiving) end of the link.
X
XIf you use the enclosed chat and unlock programs, be sure they are
Xsuid uucp, and fix-cua should be suid root.  The ppp-on script should
Xbe chmod 700, owner yourself, to keep the password (semi-) secure.
X
XI use the following eeprom settings and /dev and /etc/ttytab entries
Xin order to support dial-in and dial-out on a single phone line:
X
X crappie 12% eeprom | grep ttya
X ttya-mode=19200,8,1,n,h
X ttya-rts-dtr-off=false
X ttya-ignore-cd=false
X crappie 13% ls -lg /dev/cua /dev/ttya
X crw-rw-rw-  1 root     staff     12, 128 Nov 20 09:14 /dev/cua
X crw--w--w-  1 root     wheel     12,   0 Nov 20 08:25 /dev/ttya
X crappie 14% grep ttya /etc/ttytab
X ttya    "/usr/etc/getty std.19200"      unknown         on secure
X crappie 15%
X
XI have a Telebit Trailblazer+ attached to /dev/ttya with the following
Xregister settings:
X
X aaatz
X OK
X aat&n
X E1 F1 M1 Q6 P V1 X0     Version BA4.00
X S00=001 S01=000 S02=043 S03=013 S04=010 S05=008 S06=002 S07=060 S08=002 S09=006
X S10=007 S11=070 S12=050 
X S45=000 S47=004 S48=000 S49=000
X S50=000 S51=005 S52=002 S53=003 S54=001 S55=000 S56=017 S57=019 S58=002 S59=000
X S60=000 S61=000 S62=003 S63=001 S64=000 S65=000 S66=001 S67=000 S68=255 
X S90=000 S91=000 S92=001 S95=000 
X S100=000 S101=000 S102=000 S104=000 
X S110=001 S111=030 S112=001 
X S121=000 
X N0:
X N1:
X N2:
X N3:
X N4:
X N5:
X N6:
X N7:
X N8:
X N9:
X OK
X
XAnd, the following entry is in /etc/gettytab:
X
X #
X # 19200/2400 dialin for Telebit Trailblazer+ modem
X #
X T|T19200:dial-19200:\
X         :nx=T2400:sp#19200:
X T2400|dial-2400:\
X         :nx=T19200:sp#2400:
X
XMy chat script dialing command looks like "ATs50=255s111=0DT4515678"
Xinstead of just "ATDT4515678" in order to force a PEP mode connection
Xand to disable the UUCP spoofing (otherwise, the modem swallows or
Xdelays ^P characters).
X
XI run /usr/etc/in.routed on crappie (the calling end) and have this in
Xmy /etc/gateways file:
X
X net 0.0.0.0 gateway remora metric 1 passive
X host crappie gateway crappie metric 0 passive
X
XRouted is started in /etc/rc.local.  This way, I don't have to
Xmanually add or delete routes when links come up.  I ifconfig the ppp0
Xinterface on crappie at boot time like this (in /etc/rc.local with the
Xother ifconfig's):
X
X ifconfig ppp0 crappie remora netmask 0xffffff00 down
X
XI put "init ppp_attach" in my /sys/sun4c/conf/CRAPPIE file so that the
Xabove ifconfig down will work:
X
X pseudo-device   ppp1 init ppp_attach # Point-to-Point Protocol, 1 line
X
XThat's it.  Routed now keeps my routes sane.
X
XMy ethernet (le0) and PPP (ppp0) interfaces are configured with the
Xsame address and netmask.  IP is smart enough to figure out (via the
Xroutes in /etc/gateways) that everything useful needs to go out ppp0.
XAlso, the remora end of my PPP link is configured the same way -- the
Xppp0 interface there is configured with the same address and netmask
Xas remora's le0 ethernet.  This means that separate interface names
Xlike "remora-ppp" are not needed; point-to-point links (whether PPP,
XXerox Synchronous Point-to-Point Protocol, SLIP, IGP or whatever) have
X(apparently) been used this (seemingly bizarre) way for some time.  I
Xfound all this out by reading the "Sunlink Internetwork Router System
XAdministration Guide".
X
XHere's what netstat shows for me:
X
X crappie 109% netstat -r
X Routing tables
X Destination          Gateway              Flags    Refcnt Use        Interface
X localhost            localhost            UH       0      0          lo0
X crappie              crappie              UH       1      11339      le0
X default              remora               UG       0      1266       ppp0
X mstar-net-ppp-remora crappie              U        0      0          le0
X crappie 110% netstat -rn
X Routing tables
X Destination          Gateway              Flags    Refcnt Use        Interface
X 127.0.0.1            127.0.0.1            UH       0      0          lo0
X 137.175.6.3          137.175.6.3          UH       1      11339      le0
X default              137.175.2.7          UG       0      1266       ppp0
X 137.175.6.0          137.175.6.3          U        0      0          le0
X crappie 111% 
X
XThe default route to remora is a result of the first line in the
X/etc/gateways file ("default" can't be used there; you have to say
X"0.0.0.0").
X
XSend me mail if you have any questions.
X
XKarl Fox <karl@MorningStar.Com>
\End\of\File\ ./ppp-sparc4.1/README
else
    echo "Not overwriting ./ppp-sparc4.1/README"
fi
if `test ! -s ./ppp-sparc4.1/chat.c`
then
    echo "Writing ./ppp-sparc4.1/chat.c"
    sed 's/^X//' > ./ppp-sparc4.1/chat.c << '\End\of\File\ ./ppp-sparc4.1/chat.c'
X/*
X *	Chat -- a program for automatic session establishment (i.e. dial
X *		the phone and log in).
X *
X *	This software is in the public domain.
X *
X *	Please send all bug reports, requests for information, etc. to:
X *
X *		Karl Fox <karl@MorningStar.Com>
X *		Morning Star Technologies, Inc.
X *		1760 Zollinger Road
X *		Columbus, OH  43221
X *		(614)451-1883
X */
X
Xstatic char sccs_id[] = "@(#)chat.c	1.1";
X
X# include	<stdio.h>
X# include	<termio.h>
X# include	<fcntl.h>
X# include	<signal.h>
X# include	<errno.h>
X# include	<sys/types.h>
X# include	<sys/stat.h>
X# include	<ctype.h>
X
X# define	STR_LEN		1024
X
X# define	OPTION(c,v)	(_O&2&&**v?*(*v)++:!c||_O&4?0:(!(_O&1)&& \
X				(--c,++v),_O=4,c&&**v=='-'&&v[0][1]?*++*v=='-'\
X				&&!v[0][1]?(--c,++v,0):(_O=2,*(*v)++):0))
X# define	OPTARG(c,v)	(_O&2?**v||(++v,--c)?(_O=1,--c,*v++): \
X				(_O=4,(char*)0):(char*)0)
X# define	OPTONLYARG(c,v)	(_O&2&&**v?(_O=1,--c,*v++):(char*)0)
X# define	ARG(c,v)	(c?(--c,*v++):(char*)0)
X
Xstatic int _O = 0;		/* Internal state */
Xchar *program_name;
X
Xextern char *strcpy(), *strcat(), *malloc();
Xextern int strlen();
X# define	copyof(s)	((s) ? strcpy(malloc(strlen(s) + 1), s) : (s))
X
X# ifndef LOCK_DIR
X#  ifdef HDB
X#   define	LOCK_DIR	"/usr/spool/locks"
X#  else /* HDB */
X#   define	LOCK_DIR	"/usr/spool/uucp"
X#  endif /* HDB */
X# endif /* LOCK_DIR */
X
Xint verbose = 0;
Xint quiet = 0;
Xchar *lock_file = (char *)0;
Xint timeout = 30;
X
X/*
X *	chat [ -v ] [ -l lock-file ] [...[[expect[-say[-expect...]] say \
X *			expect[-say[-expect]] ...]]]
X *
X *	Perform a UUCP-dialer-like chat script on stdin and stdout.
X */
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X    {
X    int option, n;
X    char *arg;
X
X    program_name = *argv;
X
X    while (option = OPTION(argc, argv))
X	switch (option)
X	    {
X	    case 'v':
X		++verbose;
X		break;
X
X	    case 'l':
X		if (arg = OPTARG(argc, argv))
X		    lock_file = copyof(arg);
X		else
X		    usage();
X
X		break;
X
X	    case 't':
X		if (arg = OPTARG(argc, argv))
X		    timeout = atoi(arg);
X		else
X		    usage();
X
X		break;
X
X	    default:
X		usage();
X	    }
X
X    init();
X    
X    while (arg = ARG(argc, argv))
X	{
X	expect(arg);
X
X	if (arg = ARG(argc, argv))
X	    send(arg);
X	}
X
X    exit(0);
X    }
X
X/*
X *	We got an error parsing the command line.
X */
Xusage()
X    {
X    fprintf(stderr, "Usage: %s [ -v ] [ -l lock-file ] [-t timeout ]\n", program_name);
X    exit(1);
X    }
X
X/*
X *	Print a warning message.
X */
X/*VARARGS1*/
Xwarning(format, arg1, arg2, arg3, arg4)
Xchar *format;
Xint arg1, arg2, arg3, arg4;
X    {
X    fprintf(stderr, "%s: Warning: ", program_name);
X    fprintf(stderr, format, arg1, arg2, arg3, arg4);
X    fprintf(stderr, "\n");
X    }
X
X/*
X *	Print an error message and terminate.
X */
X/*VARARGS1*/
Xfatal(format, arg1, arg2, arg3, arg4)
Xchar *format;
Xint arg1, arg2, arg3, arg4;
X    {
X    fprintf(stderr, "%s: ", program_name);
X    fprintf(stderr, format, arg1, arg2, arg3, arg4);
X    fprintf(stderr, "\n");
X    unlock();
X    exit(1);
X    }
X
X/*
X *	Print an error message along with the system error message and
X *	terminate.
X */
X/*VARARGS1*/
Xsysfatal(format, arg1, arg2, arg3, arg4)
Xchar *format;
Xint arg1, arg2, arg3, arg4;
X    {
X    char message[STR_LEN];
X
X    sprintf(message, "%s: ", program_name);
X    sprintf(message + strlen(message), format, arg1, arg2, arg3, arg4);
X    perror(message);
X    unlock();
X    exit(1);
X    }
X
Xint alarmed = 0;
X
Xsigalrm()
X    {
X    int flags;
X
X    alarm(1); alarmed = 1;		/* Reset alarm to avoid race window */
X    signal(SIGALRM, sigalrm);		/* that can cause hanging in read() */
X
X    if ((flags = fcntl(0, F_GETFL, 0)) == -1)
X	sysfatal("Can't get file mode flags on stdin");
X    else
X	if (fcntl(0, F_SETFL, flags | FNDELAY) == -1)
X	    sysfatal("Can't set file mode flags on stdin");
X
X    if (verbose)
X	{
X	fprintf(stderr, "alarm\n");
X	fflush(stderr);
X	}
X    }
X
Xunalarm()
X    {
X    int flags;
X
X    if ((flags = fcntl(0, F_GETFL, 0)) == -1)
X	sysfatal("Can't get file mode flags on stdin");
X    else
X	if (fcntl(0, F_SETFL, flags & ~FNDELAY) == -1)
X	    sysfatal("Can't set file mode flags on stdin");
X    }
X
Xinit()
X    {
X    if (lock_file)
X	lock();
X
X    set_tty_parameters();
X    signal(SIGALRM, sigalrm);
X    alarm(0); alarmed = 0;
X    }
X
Xset_tty_parameters()
X    {
X    struct termio t;
X
X    if (ioctl(0, TCGETA, &t) < 0)
X	sysfatal("Can't get terminal parameters");
X
X    t.c_iflag = IXOFF | IXON | ISTRIP | IGNPAR | IGNBRK;
X    t.c_cflag = CLOCAL | CREAD | CS8 | (t.c_cflag & CBAUD) | HUPCL;
X    t.c_lflag = 0;
X    t.c_cc[VERASE] = 0;
X    t.c_cc[VKILL] = 0;
X    t.c_cc[VMIN] = 1;
X    t.c_cc[VTIME] = 0;
X
X    if (ioctl(0, TCSETA, &t) < 0)
X	sysfatal("Can't set terminal parameters");
X    }
X
X/*
X *	Create a lock file for the named lock device
X */
Xlock()
X    {
X    char hdb_lock_buffer[12];
X    int fd, pid;
X
X    lock_file = strcat(strcat(strcpy(malloc(strlen(LOCK_DIR)
X				       + 1 + strlen(lock_file) + 1),
X				LOCK_DIR), "/"), lock_file);
X
X    if ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0)
X	sysfatal("Can't get lock file '%s'", lock_file);
X
X# ifdef HDB
X    sprintf(hdb_lock_buffer, "%10d\n", getpid());
X    write(fd, hdb_lock_buffer, 11);
X# else /* HDB */
X    pid = getpid();
X    write(fd, &pid, sizeof pid);
X# endif /* HDB */
X
X    close(fd);
X    }
X
X/*
X *	Remove our lockfile
X */
Xunlock()
X    {
X    if (lock_file)
X	{
X	unlink(lock_file);
X	lock_file = (char *)0;
X	}
X    }
X
X/*
X *	'Clean up' this string.
X */
Xchar *clean(s, add_newline)
Xregister char *s;
Xint add_newline;
X    {
X    char temp[STR_LEN];
X    register char *s1;
X
X    for (s1 = temp; *s; ++s)
X	 switch (*s)
X	     {
X	     case '\\':
X		 switch (*++s)
X		     {
X		     case 'q':	quiet = ! quiet; break;
X		     case 'r':	*s1++ = '\r'; break;
X		     case 'n':	*s1++ = '\n'; break;
X		     case 's':	*s1++ = ' '; break;
X		     case 'c':	add_newline = 0; break;
X		     default:	*s1++ = *s;
X		     }
X
X		 break;
X
X	     case '^':
X		 *s1++ = (int)(*++s) & 0x1F;
X		 break;
X
X	     default:
X		 *s1++ = *s;
X	     }
X    
X    if (add_newline)
X	*s1++ = '\n';
X
X    *s1 = '\0';
X    return (copyof(temp));
X    }
X
X/*
X *
X */
Xexpect(s)
Xchar *s;
X    {
X    if ( ! get_string(clean(s, 0)))
X	{
X	fprintf(stderr, "Failed\n");
X	fflush(stderr);
X	unlock();
X	exit(1);
X	}
X    }
X
X/*
X *
X */
Xsend(s)
Xchar *s;
X    {
X    if ( ! put_string(clean(s, 1)))
X	{
X	fprintf(stderr, "Failed\n");
X	fflush(stderr);
X	unlock();
X	exit(1);
X	}
X    }
X
Xchar *character(c)
Xchar c;
X    {
X    static char string[10];
X
X    if (isgraph(c) || c == ' ')
X	sprintf(string, "%c", c);
X    else
X	if (c < 32)
X	    sprintf(string, "^%c", (int)c + 'A' - 1);
X	else
X	    sprintf(string, "\\%03o", (int)c & 0xFF);
X
X    return (string);
X    }
X
Xint get_char()
X    {
X    int status;
X    char c;
X
X    status = read(0, &c, 1);
X
X    switch (status)
X	{
X	case 1:
X	    return ((int)c & 0x7F);
X
X	default:
X	    warning("read() on stdin returned %d", status);
X
X	case -1:
X	    if ((status = fcntl(0, F_GETFL, 0)) == -1)
X		sysfatal("Can't get file mode flags on stdin");
X	    else
X		if (fcntl(0, F_SETFL, status & ~FNDELAY) == -1)
X		    sysfatal("Can't set file mode flags on stdin");
X
X	    return (-1);
X	}
X    }
X
Xint put_char(c)
Xchar c;
X    {
X    int status;
X
X    delay();
X
X    status = write(1, &c, 1);
X
X    switch (status)
X	{
X	case 1:
X	    return (0);
X
X	default:
X	    warning("write() on stdout returned %d", status);
X
X	case -1:
X	    if ((status = fcntl(0, F_GETFL, 0)) == -1)
X		sysfatal("Can't get file mode flags on stdin");
X	    else
X		if (fcntl(0, F_SETFL, status & ~FNDELAY) == -1)
X		    sysfatal("Can't set file mode flags on stdin");
X
X	    return (-1);
X	}
X    }
X
Xint put_string(s)
Xregister char *s;
X    {
X    register char *orig_s = s;
X
X    if (verbose)
X	{
X	fprintf(stderr, "send (");
X
X	if (quiet)
X	    fprintf(stderr, "??????");
X	else
X	    for (orig_s = s; *orig_s; ++orig_s)
X		fprintf(stderr, "%s", character(*orig_s));
X
X	fprintf(stderr, ")\n");
X	fflush(stderr);
X	}
X
X    alarm(timeout); alarmed = 0;
X
X    for ( ; *s; ++s)
X	if (alarmed || put_char(*s) < 0)
X	    {
X	    extern int errno;
X
X	    alarm(0); alarmed = 0;
X
X	    if (verbose)
X		{
X		if (errno == EINTR || errno == EWOULDBLOCK)
X		    fprintf(stderr, " -- write timed out\n");
X		else
X		    perror(" -- write failed");
X
X		fflush(stderr);
X		}
X
X	    return (0);
X	    }
X
X    alarm(0); alarmed = 0;
X    return (1);
X    }
X
X/*
X *	'Wait for' this string to appear on this file descriptor.
X */
Xint get_string(string)
Xregister char *string;
X    {
X    int c, printed = 0;
X    register char *orig_s, *s = string;
X
X    if (verbose)
X	{
X	fprintf(stderr, "expect (");
X
X	for (orig_s = s; *orig_s; ++orig_s)
X	    fprintf(stderr, "%s", character(*orig_s));
X
X	fprintf(stderr, ")\n");
X	fflush(stderr);
X	}
X
X    if (*s == '\0')
X	{
X	if (verbose)
X	    {
X	    fprintf(stderr, "got it\n");
X	    fflush(stderr);
X	    }
X
X	return (1);
X	}
X
X    alarm(timeout); alarmed = 0;
X
X    while ( ! alarmed && (c = get_char()) >= 0)
X	{
X	if (verbose)
X	    {
X	    if (c == '\n')
X		fprintf(stderr, "\n");
X	    else
X		fprintf(stderr, "%s", character(c));
X
X	    fflush(stderr);
X	    }
X
X	if (c == *s)
X	    ++s;
X	else
X	    s = string;
X
X	if (*s == '\0')
X	    {
X	    if (verbose)
X		{
X		fprintf(stderr, "got it\n");
X		fflush(stderr);
X		}
X
X	    alarm(0); alarmed = 0;
X	    return (1);
X	    }
X
X	if (alarmed && verbose)
X	    warning("Warning: get_string() has 'alarmed' on before read");
X	}
X
X    alarm(0);
X    
X    if (verbose && printed)
X	{
X	extern int errno;
X
X	if (alarmed)
X	    fprintf(stderr, " -- read timed out\n");
X	else
X	    perror(" -- read failed");
X
X	fflush(stderr);
X	}
X
X    alarmed = 0;
X    return (0);
X    }
X
X/*
X *	Delay an amount appropriate for between typed characters.
X */
Xdelay()
X    {
X    register int i;
X
X# ifdef NO_USLEEP
X    for (i = 0; i < 30000; ++i)		/* ... did we just say appropriate? */
X	;
X# else /* NO_USLEEP */
X    usleep(100);
X# endif /* NO_USLEEP */
X    }
\End\of\File\ ./ppp-sparc4.1/chat.c
else
    echo "Not overwriting ./ppp-sparc4.1/chat.c"
fi
if `test ! -s ./ppp-sparc4.1/fix-cua`
then
    echo "Writing ./ppp-sparc4.1/fix-cua"
    sed 's/^X//' > ./ppp-sparc4.1/fix-cua << '\End\of\File\ ./ppp-sparc4.1/fix-cua'
X#!/bin/sh
X
Xif [ -f /usr/spool/uucp/LCK..cua ]
Xthen
X    echo "/dev/cua is locked" 2>&1
X    exit 1
Xfi
X
Xchown root /dev/cua
Xchmod 666 /dev/cua
\End\of\File\ ./ppp-sparc4.1/fix-cua
else
    echo "Not overwriting ./ppp-sparc4.1/fix-cua"
fi
if `test ! -s ./ppp-sparc4.1/ppp-off`
then
    echo "Writing ./ppp-sparc4.1/ppp-off"
    sed 's/^X//' > ./ppp-sparc4.1/ppp-off << '\End\of\File\ ./ppp-sparc4.1/ppp-off'
X#!/bin/sh
X
Xkill -INT `ps -ax | egrep " ppp " | egrep -v "egrep" | sed 's/^\([ 0-9]*\) .*/\1'/`
X
Xexit 0
\End\of\File\ ./ppp-sparc4.1/ppp-off
else
    echo "Not overwriting ./ppp-sparc4.1/ppp-off"
fi
if `test ! -s ./ppp-sparc4.1/ppp-on`
then
    echo "Writing ./ppp-sparc4.1/ppp-on"
    sed 's/^X//' > ./ppp-sparc4.1/ppp-on << '\End\of\File\ ./ppp-sparc4.1/ppp-on'
X#!/bin/sh
X
X#
X#	ppp-on
X#
X#	Put up a button to set up or shut down a PPP link
X#
X
Xfont="-fn lucidasans-italic-10"
X
Xwhile :
Xdo
X    if [ -f /usr/spool/uucp/LCK..cua ]
X    then
X	if xlogout $* $font -label "(PPP device is locked)"
X	then
X	    continue
X	else
X	    exit 1
X	fi
X    fi
X
X    if xlogout $* $font -label "Bring PPP Up"
X    then
X	:
X    else
X	exit 1
X    fi
X
X    if [ -f /usr/spool/uucp/LCK..cua ]
X    then
X	continue
X    fi
X
X    reason=
X
X    fix-cua
X
X    (
X	stty 19200 -tostop
X
X	if chat -l LCK..cua "" AT OK ATDT4511234 CONNECT "" ogin: Pkarl ssword: \\q<password on remora for Pkarl>
X	then
X	    ppp 137.175.6.3: /dev/cua &
X	    sleep 10
X	    (
X	    if xlogout $* $font -label "Shut PPP Down"
X	    then
X		:
X	    else
X		exit 1
X	    fi
X
X	    ppp-off
X	    wait
X	    #sleep 5
X	    unlock LCK..cua
X	    ) 0>&2 1>&2
X	else
X	    if xlogout $* $font -label "(PPP call failed)"
X	    then
X		:
X	    else
X		exit 1
X	    fi
X	fi
X    ) < /dev/cua > /dev/cua
Xdone
\End\of\File\ ./ppp-sparc4.1/ppp-on
else
    echo "Not overwriting ./ppp-sparc4.1/ppp-on"
fi
if `test ! -s ./ppp-sparc4.1/ppp.how-to-use`
then
    echo "Writing ./ppp-sparc4.1/ppp.how-to-use"
    sed 's/^X//' > ./ppp-sparc4.1/ppp.how-to-use << '\End\of\File\ ./ppp-sparc4.1/ppp.how-to-use'
X#!/bin/sh
X#
X#    This is a SHAR archive.  To extract, remove everything
X#    above the #!/bin/sh line and type "sh filename"
X#
Xif `test ! -s ./README`
Xthen
X    echo "Writing ./README"
X    sed 's/^X//' > ./README << '\End\of\File\ ./README'
XXI run PPP between crappie.morningstar.com (137.175.6.3, my home
XXmachine) and remora.morningstar.com (137.175.2.7, my workstation at
XXthe office).  This document describes how I use it.  The installation
XXof PPP itself is covered in the PPP distribution.
XX
XXI put a line like this in remora's /etc/passwd:
XX
XX Pkarl:2y4613BDaQD3x:51:10:Karl's PPP login:/tmp:/usr/local/etc/pppstart-karl
XX
XXI created a login shell script on remora called
XX/usr/local/etc/pppstart-karl:
XX
XX #!/bin/sh
XX /usr/bin/mesg n
XX stty -tostop
XX exec /usr/local/etc/ppp 137.175.6.2:
XX
XXI have this line in my ~/.xinitrc file:
XX
XX ppp-on &
XX
XXThis shell script, plus the ppp-off, unlock and fix-cua scripts and
XXthe source to the chat program are included.  You will need to heavily
XXmodify these to suit your own situation, including Internet addresses,
XXmachine names, telephone numbers, modem dialing commands, baud rates,
XXlogin names and passwords.  Make the "ppp..." command in the ppp-on
XXscript look something like this:
XX
XX ppp -v 137.175.6.3: /dev/cua &
XX
XXThe "137.175.6.3:" is of the format "local-addr:remote-addr" with the
XXremote address null (it will be negotiated by PPP).  Look at the login
XXshell script above; it can be common to all dial-in PPP users on your
XXmachine because it only specifies the address of the remora
XX(receiving) end of the link.
XX
XXIf you use the enclosed chat and unlock programs, be sure they are
XXsuid uucp, and fix-cua should be suid root.  The ppp-on script should
XXbe chmod 700, owner yourself, to keep the password (semi-) secure.
XX
XXI use the following eeprom settings and /dev and /etc/ttytab entries
XXin order to support dial-in and dial-out on a single phone line:
XX
XX crappie 12% eeprom | grep ttya
XX ttya-mode=19200,8,1,n,h
XX ttya-rts-dtr-off=false
XX ttya-ignore-cd=false
XX crappie 13% ls -lg /dev/cua /dev/ttya
XX crw-rw-rw-  1 root     staff     12, 128 Nov 20 09:14 /dev/cua
XX crw--w--w-  1 root     wheel     12,   0 Nov 20 08:25 /dev/ttya
XX crappie 14% grep ttya /etc/ttytab
XX ttya    "/usr/etc/getty std.19200"      unknown         on secure
XX crappie 15%
XX
XXI have a Telebit Trailblazer+ attached to /dev/ttya with the following
XXregister settings:
XX
XX aaatz
XX OK
XX aat&n
XX E1 F1 M1 Q6 P V1 X0     Version BA4.00
XX S00=001 S01=000 S02=043 S03=013 S04=010 S05=008 S06=002 S07=060 S08=002 S09=006
XX S10=007 S11=070 S12=050 
XX S45=000 S47=004 S48=000 S49=000
XX S50=000 S51=005 S52=002 S53=003 S54=001 S55=000 S56=017 S57=019 S58=002 S59=000
XX S60=000 S61=000 S62=003 S63=001 S64=000 S65=000 S66=001 S67=000 S68=255 
XX S90=000 S91=000 S92=001 S95=000 
XX S100=000 S101=000 S102=000 S104=000 
XX S110=001 S111=030 S112=001 
XX S121=000 
XX N0:
XX N1:
XX N2:
XX N3:
XX N4:
XX N5:
XX N6:
XX N7:
XX N8:
XX N9:
XX OK
XX
XXAnd, the following entry is in /etc/gettytab:
XX
XX #
XX # 19200/2400 dialin for Telebit Trailblazer+ modem
XX #
XX T|T19200:dial-19200:\
XX         :nx=T2400:sp#19200:
XX T2400|dial-2400:\
XX         :nx=T19200:sp#2400:
XX
XXMy chat script dialing command looks like "ATs50=255s111=0DT4515678"
XXinstead of just "ATDT4515678" in order to force a PEP mode connection
XXand to disable the UUCP spoofing (otherwise, the modem swallows or
XXdelays ^P characters).
XX
XXI run /usr/etc/in.routed on crappie (the calling end) and have this in
XXmy /etc/gateways file:
XX
XX net 0.0.0.0 gateway remora metric 1 passive
XX host crappie gateway crappie metric 0 passive
XX
XXRouted is started in /etc/rc.local.  This way, I don't have to
XXmanually add or delete routes when links come up.  I ifconfig the ppp0
XXinterface on crappie at boot time like this (in /etc/rc.local with the
XXother ifconfig's):
XX
XX ifconfig ppp0 crappie remora netmask 0xffffff00 down
XX
XXI put "init ppp_attach" in my /sys/sun4c/conf/CRAPPIE file so that the
XXabove ifconfig down will work:
XX
XX pseudo-device   ppp1 init ppp_attach # Point-to-Point Protocol, 1 line
XX
XXThat's it.  Routed now keeps my routes sane.
XX
XXMy ethernet (le0) and PPP (ppp0) interfaces are configured with the
XXsame address and netmask.  IP is smart enough to figure out (via the
XXroutes in /etc/gateways) that everything useful needs to go out ppp0.
XXAlso, the remora end of my PPP link is configured the same way -- the
XXppp0 interface there is configured with the same address and netmask
XXas remora's le0 ethernet.  This means that separate interface names
XXlike "remora-ppp" are not needed; point-to-point links (whether PPP,
XXXerox Synchronous Point-to-Point Protocol, SLIP, IGP or whatever) have
XX(apparently) been used this (seemingly bizarre) way for some time.  I
XXfound all this out by reading the "Sunlink Internetwork Router System
XXAdministration Guide".
XX
XXHere's what netstat shows for me:
XX
XX crappie 109% netstat -r
XX Routing tables
XX Destination          Gateway              Flags    Refcnt Use        Interface
XX localhost            localhost            UH       0      0          lo0
XX crappie              crappie              UH       1      11339      le0
XX default              remora               UG       0      1266       ppp0
XX mstar-net-ppp-remora crappie              U        0      0          le0
XX crappie 110% netstat -rn
XX Routing tables
XX Destination          Gateway              Flags    Refcnt Use        Interface
XX 127.0.0.1            127.0.0.1            UH       0      0          lo0
XX 137.175.6.3          137.175.6.3          UH       1      11339      le0
XX default              137.175.2.7          UG       0      1266       ppp0
XX 137.175.6.0          137.175.6.3          U        0      0          le0
XX crappie 111% 
XX
XXThe default route to remora is a result of the first line in the
XX/etc/gateways file ("default" can't be used there; you have to say
XX"0.0.0.0").
XX
XXSend me mail if you have any questions.
XX
XXKarl Fox <karl@MorningStar.Com>
X\End\of\File\ ./README
Xelse
X    echo "Not overwriting ./README"
Xfi
Xif `test ! -s ./chat.c`
Xthen
X    echo "Writing ./chat.c"
X    sed 's/^X//' > ./chat.c << '\End\of\File\ ./chat.c'
XX/*
XX *	Chat -- a program for automatic session establishment (i.e. dial
XX *		the phone and log in).
XX *
XX *	This software is in the public domain.
XX *
XX *	Please send all bug reports, requests for information, etc. to:
XX *
XX *		Karl Fox <karl@MorningStar.Com>
XX *		Morning Star Technologies, Inc.
XX *		1760 Zollinger Road
XX *		Columbus, OH  43221
XX *		(614)451-1883
XX */
XX
XXstatic char sccs_id[] = "@(#)chat.c	1.1";
XX
XX# include	<stdio.h>
XX# include	<termio.h>
XX# include	<fcntl.h>
XX# include	<signal.h>
XX# include	<errno.h>
XX# include	<sys/types.h>
XX# include	<sys/stat.h>
XX# include	<ctype.h>
XX
XX# define	STR_LEN		1024
XX
XX# define	OPTION(c,v)	(_O&2&&**v?*(*v)++:!c||_O&4?0:(!(_O&1)&& \
XX				(--c,++v),_O=4,c&&**v=='-'&&v[0][1]?*++*v=='-'\
XX				&&!v[0][1]?(--c,++v,0):(_O=2,*(*v)++):0))
XX# define	OPTARG(c,v)	(_O&2?**v||(++v,--c)?(_O=1,--c,*v++): \
XX				(_O=4,(char*)0):(char*)0)
XX# define	OPTONLYARG(c,v)	(_O&2&&**v?(_O=1,--c,*v++):(char*)0)
XX# define	ARG(c,v)	(c?(--c,*v++):(char*)0)
XX
XXstatic int _O = 0;		/* Internal state */
XXchar *program_name;
XX
XXextern char *strcpy(), *strcat(), *malloc();
XXextern int strlen();
XX# define	copyof(s)	((s) ? strcpy(malloc(strlen(s) + 1), s) : (s))
XX
XX# ifndef LOCK_DIR
XX#  ifdef HDB
XX#   define	LOCK_DIR	"/usr/spool/locks"
XX#  else /* HDB */
XX#   define	LOCK_DIR	"/usr/spool/uucp"
XX#  endif /* HDB */
XX# endif /* LOCK_DIR */
XX
XXint verbose = 0;
XXint quiet = 0;
XXchar *lock_file = (char *)0;
XXint timeout = 30;
XX
XX/*
XX *	chat [ -v ] [ -l lock-file ] [...[[expect[-say[-expect...]] say \
XX *			expect[-say[-expect]] ...]]]
XX *
XX *	Perform a UUCP-dialer-like chat script on stdin and stdout.
XX */
XXmain(argc, argv)
XXint argc;
XXchar **argv;
XX    {
XX    int option, n;
XX    char *arg;
XX
XX    program_name = *argv;
XX
XX    while (option = OPTION(argc, argv))
XX	switch (option)
XX	    {
XX	    case 'v':
XX		++verbose;
XX		break;
XX
XX	    case 'l':
XX		if (arg = OPTARG(argc, argv))
XX		    lock_file = copyof(arg);
XX		else
XX		    usage();
XX
XX		break;
XX
XX	    case 't':
XX		if (arg = OPTARG(argc, argv))
XX		    timeout = atoi(arg);
XX		else
XX		    usage();
XX
XX		break;
XX
XX	    default:
XX		usage();
XX	    }
XX
XX    init();
XX    
XX    while (arg = ARG(argc, argv))
XX	{
XX	expect(arg);
XX
XX	if (arg = ARG(argc, argv))
XX	    send(arg);
XX	}
XX
XX    exit(0);
XX    }
XX
XX/*
XX *	We got an error parsing the command line.
XX */
XXusage()
XX    {
XX    fprintf(stderr, "Usage: %s [ -v ] [ -l lock-file ] [-t timeout ]\n", program_name);
XX    exit(1);
XX    }
XX
XX/*
XX *	Print a warning message.
XX */
XX/*VARARGS1*/
XXwarning(format, arg1, arg2, arg3, arg4)
XXchar *format;
XXint arg1, arg2, arg3, arg4;
XX    {
XX    fprintf(stderr, "%s: Warning: ", program_name);
XX    fprintf(stderr, format, arg1, arg2, arg3, arg4);
XX    fprintf(stderr, "\n");
XX    }
XX
XX/*
XX *	Print an error message and terminate.
XX */
XX/*VARARGS1*/
XXfatal(format, arg1, arg2, arg3, arg4)
XXchar *format;
XXint arg1, arg2, arg3, arg4;
XX    {
XX    fprintf(stderr, "%s: ", program_name);
XX    fprintf(stderr, format, arg1, arg2, arg3, arg4);
XX    fprintf(stderr, "\n");
XX    unlock();
XX    exit(1);
XX    }
XX
XX/*
XX *	Print an error message along with the system error message and
XX *	terminate.
XX */
XX/*VARARGS1*/
XXsysfatal(format, arg1, arg2, arg3, arg4)
XXchar *format;
XXint arg1, arg2, arg3, arg4;
XX    {
XX    char message[STR_LEN];
XX
XX    sprintf(message, "%s: ", program_name);
XX    sprintf(message + strlen(message), format, arg1, arg2, arg3, arg4);
XX    perror(message);
XX    unlock();
XX    exit(1);
XX    }
XX
XXint alarmed = 0;
XX
XXsigalrm()
XX    {
XX    int flags;
XX
XX    alarm(1); alarmed = 1;		/* Reset alarm to avoid race window */
XX    signal(SIGALRM, sigalrm);		/* that can cause hanging in read() */
XX
XX    if ((flags = fcntl(0, F_GETFL, 0)) == -1)
XX	sysfatal("Can't get file mode flags on stdin");
XX    else
XX	if (fcntl(0, F_SETFL, flags | FNDELAY) == -1)
XX	    sysfatal("Can't set file mode flags on stdin");
XX
XX    if (verbose)
XX	{
XX	fprintf(stderr, "alarm\n");
XX	fflush(stderr);
XX	}
XX    }
XX
XXunalarm()
XX    {
XX    int flags;
XX
XX    if ((flags = fcntl(0, F_GETFL, 0)) == -1)
XX	sysfatal("Can't get file mode flags on stdin");
XX    else
XX	if (fcntl(0, F_SETFL, flags & ~FNDELAY) == -1)
XX	    sysfatal("Can't set file mode flags on stdin");
XX    }
XX
XXinit()
XX    {
XX    if (lock_file)
XX	lock();
XX
XX    set_tty_parameters();
XX    signal(SIGALRM, sigalrm);
XX    alarm(0); alarmed = 0;
XX    }
XX
XXset_tty_parameters()
XX    {
XX    struct termio t;
XX
XX    if (ioctl(0, TCGETA, &t) < 0)
XX	sysfatal("Can't get terminal parameters");
XX
XX    t.c_iflag = IXOFF | IXON | ISTRIP | IGNPAR | IGNBRK;
XX    t.c_cflag = CLOCAL | CREAD | CS8 | (t.c_cflag & CBAUD) | HUPCL;
XX    t.c_lflag = 0;
XX    t.c_cc[VERASE] = 0;
XX    t.c_cc[VKILL] = 0;
XX    t.c_cc[VMIN] = 1;
XX    t.c_cc[VTIME] = 0;
XX
XX    if (ioctl(0, TCSETA, &t) < 0)
XX	sysfatal("Can't set terminal parameters");
XX    }
XX
XX/*
XX *	Create a lock file for the named lock device
XX */
XXlock()
XX    {
XX    char hdb_lock_buffer[12];
XX    int fd, pid;
XX
XX    lock_file = strcat(strcat(strcpy(malloc(strlen(LOCK_DIR)
XX				       + 1 + strlen(lock_file) + 1),
XX				LOCK_DIR), "/"), lock_file);
XX
XX    if ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0)
XX	sysfatal("Can't get lock file '%s'", lock_file);
XX
XX# ifdef HDB
XX    sprintf(hdb_lock_buffer, "%10d\n", getpid());
XX    write(fd, hdb_lock_buffer, 11);
XX# else /* HDB */
XX    pid = getpid();
XX    write(fd, &pid, sizeof pid);
XX# endif /* HDB */
XX
XX    close(fd);
XX    }
XX
XX/*
XX *	Remove our lockfile
XX */
XXunlock()
XX    {
XX    if (lock_file)
XX	{
XX	unlink(lock_file);
XX	lock_file = (char *)0;
XX	}
XX    }
XX
XX/*
XX *	'Clean up' this string.
XX */
XXchar *clean(s, add_newline)
XXregister char *s;
XXint add_newline;
XX    {
XX    char temp[STR_LEN];
XX    register char *s1;
XX
XX    for (s1 = temp; *s; ++s)
XX	 switch (*s)
XX	     {
XX	     case '\\':
XX		 switch (*++s)
XX		     {
XX		     case 'q':	quiet = ! quiet; break;
XX		     case 'r':	*s1++ = '\r'; break;
XX		     case 'n':	*s1++ = '\n'; break;
XX		     case 's':	*s1++ = ' '; break;
XX		     case 'c':	add_newline = 0; break;
XX		     default:	*s1++ = *s;
XX		     }
XX
XX		 break;
XX
XX	     case '^':
XX		 *s1++ = (int)(*++s) & 0x1F;
XX		 break;
XX
XX	     default:
XX		 *s1++ = *s;
XX	     }
XX    
XX    if (add_newline)
XX	*s1++ = '\n';
XX
XX    *s1 = '\0';
XX    return (copyof(temp));
XX    }
XX
XX/*
XX *
XX */
XXexpect(s)
XXchar *s;
XX    {
XX    if ( ! get_string(clean(s, 0)))
XX	{
XX	fprintf(stderr, "Failed\n");
XX	fflush(stderr);
XX	unlock();
XX	exit(1);
XX	}
XX    }
XX
XX/*
XX *
XX */
XXsend(s)
XXchar *s;
XX    {
XX    if ( ! put_string(clean(s, 1)))
XX	{
XX	fprintf(stderr, "Failed\n");
XX	fflush(stderr);
XX	unlock();
XX	exit(1);
XX	}
XX    }
XX
XXchar *character(c)
XXchar c;
XX    {
XX    static char string[10];
XX
XX    if (isgraph(c) || c == ' ')
XX	sprintf(string, "%c", c);
XX    else
XX	if (c < 32)
XX	    sprintf(string, "^%c", (int)c + 'A' - 1);
XX	else
XX	    sprintf(string, "\\%03o", (int)c & 0xFF);
XX
XX    return (string);
XX    }
XX
XXint get_char()
XX    {
XX    int status;
XX    char c;
XX
XX    status = read(0, &c, 1);
XX
XX    switch (status)
XX	{
XX	case 1:
XX	    return ((int)c & 0x7F);
XX
XX	default:
XX	    warning("read() on stdin returned %d", status);
XX
XX	case -1:
XX	    if ((status = fcntl(0, F_GETFL, 0)) == -1)
XX		sysfatal("Can't get file mode flags on stdin");
XX	    else
XX		if (fcntl(0, F_SETFL, status & ~FNDELAY) == -1)
XX		    sysfatal("Can't set file mode flags on stdin");
XX
XX	    return (-1);
XX	}
XX    }
XX
XXint put_char(c)
XXchar c;
XX    {
XX    int status;
XX
XX    delay();
XX
XX    status = write(1, &c, 1);
XX
XX    switch (status)
XX	{
XX	case 1:
XX	    return (0);
XX
XX	default:
XX	    warning("write() on stdout returned %d", status);
XX
XX	case -1:
XX	    if ((status = fcntl(0, F_GETFL, 0)) == -1)
XX		sysfatal("Can't get file mode flags on stdin");
XX	    else
XX		if (fcntl(0, F_SETFL, status & ~FNDELAY) == -1)
XX		    sysfatal("Can't set file mode flags on stdin");
XX
XX	    return (-1);
XX	}
XX    }
XX
XXint put_string(s)
XXregister char *s;
XX    {
XX    register char *orig_s = s;
XX
XX    if (verbose)
XX	{
XX	fprintf(stderr, "send (");
XX
XX	if (quiet)
XX	    fprintf(stderr, "??????");
XX	else
XX	    for (orig_s = s; *orig_s; ++orig_s)
XX		fprintf(stderr, "%s", character(*orig_s));
XX
XX	fprintf(stderr, ")\n");
XX	fflush(stderr);
XX	}
XX
XX    alarm(timeout); alarmed = 0;
XX
XX    for ( ; *s; ++s)
XX	if (alarmed || put_char(*s) < 0)
XX	    {
XX	    extern int errno;
XX
XX	    alarm(0); alarmed = 0;
XX
XX	    if (verbose)
XX		{
XX		if (errno == EINTR || errno == EWOULDBLOCK)
XX		    fprintf(stderr, " -- write timed out\n");
XX		else
XX		    perror(" -- write failed");
XX
XX		fflush(stderr);
XX		}
XX
XX	    return (0);
XX	    }
XX
XX    alarm(0); alarmed = 0;
XX    return (1);
XX    }
XX
XX/*
XX *	'Wait for' this string to appear on this file descriptor.
XX */
XXint get_string(string)
XXregister char *string;
XX    {
XX    int c, printed = 0;
XX    register char *orig_s, *s = string;
XX
XX    if (verbose)
XX	{
XX	fprintf(stderr, "expect (");
XX
XX	for (orig_s = s; *orig_s; ++orig_s)
XX	    fprintf(stderr, "%s", character(*orig_s));
XX
XX	fprintf(stderr, ")\n");
XX	fflush(stderr);
XX	}
XX
XX    if (*s == '\0')
XX	{
XX	if (verbose)
XX	    {
XX	    fprintf(stderr, "got it\n");
XX	    fflush(stderr);
XX	    }
XX
XX	return (1);
XX	}
XX
XX    alarm(timeout); alarmed = 0;
XX
XX    while ( ! alarmed && (c = get_char()) >= 0)
XX	{
XX	if (verbose)
XX	    {
XX	    if (c == '\n')
XX		fprintf(stderr, "\n");
XX	    else
XX		fprintf(stderr, "%s", character(c));
XX
XX	    fflush(stderr);
XX	    }
XX
XX	if (c == *s)
XX	    ++s;
XX	else
XX	    s = string;
XX
XX	if (*s == '\0')
XX	    {
XX	    if (verbose)
XX		{
XX		fprintf(stderr, "got it\n");
XX		fflush(stderr);
XX		}
XX
XX	    alarm(0); alarmed = 0;
XX	    return (1);
XX	    }
XX
XX	if (alarmed && verbose)
XX	    warning("Warning: get_string() has 'alarmed' on before read");
XX	}
XX
XX    alarm(0);
XX    
XX    if (verbose && printed)
XX	{
XX	extern int errno;
XX
XX	if (alarmed)
XX	    fprintf(stderr, " -- read timed out\n");
XX	else
XX	    perror(" -- read failed");
XX
XX	fflush(stderr);
XX	}
XX
XX    alarmed = 0;
XX    return (0);
XX    }
XX
XX/*
XX *	Delay an amount appropriate for between typed characters.
XX */
XXdelay()
XX    {
XX    register int i;
XX
XX# ifdef NO_USLEEP
XX    for (i = 0; i < 30000; ++i)		/* ... did we just say appropriate? */
XX	;
XX# else /* NO_USLEEP */
XX    usleep(100);
XX# endif /* NO_USLEEP */
XX    }
X\End\of\File\ ./chat.c
Xelse
X    echo "Not overwriting ./chat.c"
Xfi
Xif `test ! -s ./fix-cua`
Xthen
X    echo "Writing ./fix-cua"
X    sed 's/^X//' > ./fix-cua << '\End\of\File\ ./fix-cua'
XX#!/bin/sh
XX
XXif [ -f /usr/spool/uucp/LCK..cua ]
XXthen
XX    echo "/dev/cua is locked" 2>&1
XX    exit 1
XXfi
XX
XXchown root /dev/cua
XXchmod 666 /dev/cua
X\End\of\File\ ./fix-cua
Xelse
X    echo "Not overwriting ./fix-cua"
Xfi
Xif `test ! -s ./ppp-off`
Xthen
X    echo "Writing ./ppp-off"
X    sed 's/^X//' > ./ppp-off << '\End\of\File\ ./ppp-off'
XX#!/bin/sh
XX
XXkill -INT `ps -ax | egrep " ppp " | egrep -v "egrep" | sed 's/^\([ 0-9]*\) .*/\1'/`
XX
XXexit 0
X\End\of\File\ ./ppp-off
Xelse
X    echo "Not overwriting ./ppp-off"
Xfi
Xif `test ! -s ./ppp-on`
Xthen
X    echo "Writing ./ppp-on"
X    sed 's/^X//' > ./ppp-on << '\End\of\File\ ./ppp-on'
XX#!/bin/sh
XX
XX#
XX#	ppp-on
XX#
XX#	Put up a button to set up or shut down a PPP link
XX#
XX
XXfont="-fn lucidasans-italic-10"
XX
XXwhile :
XXdo
XX    if [ -f /usr/spool/uucp/LCK..cua ]
XX    then
XX	if xlogout $* $font -label "(PPP device is locked)"
XX	then
XX	    continue
XX	else
XX	    exit 1
XX	fi
XX    fi
XX
XX    if xlogout $* $font -label "Bring PPP Up"
XX    then
XX	:
XX    else
XX	exit 1
XX    fi
XX
XX    if [ -f /usr/spool/uucp/LCK..cua ]
XX    then
XX	continue
XX    fi
XX
XX    reason=
XX
XX    fix-cua
XX
XX    (
XX	stty 19200 -tostop
XX
XX	if chat -l LCK..cua "" AT OK ATDT4511234 CONNECT "" ogin: Pkarl ssword: \\q<password on remora for Pkarl>
XX	then
XX	    ppp 137.175.6.3: /dev/cua &
XX	    sleep 10
XX	    (
XX	    if xlogout $* $font -label "Shut PPP Down"
XX	    then
XX		:
XX	    else
XX		exit 1
XX	    fi
XX
XX	    ppp-off
XX	    wait
XX	    #sleep 5
XX	    unlock LCK..cua
XX	    ) 0>&2 1>&2
XX	else
XX	    if xlogout $* $font -label "(PPP call failed)"
XX	    then
XX		:
XX	    else
XX		exit 1
XX	    fi
XX	fi
XX    ) < /dev/cua > /dev/cua
XXdone
X\End\of\File\ ./ppp-on
Xelse
X    echo "Not overwriting ./ppp-on"
Xfi
Xif `test ! -s ./unlock`
Xthen
X    echo "Writing ./unlock"
X    sed 's/^X//' > ./unlock << '\End\of\File\ ./unlock'
XX#!/bin/sh
XX
XXLOCKDIR=/usr/spool/uucp
XX
XXcase "$1" in
XX    "")		echo "Usage: unlock lockfile"; exit 1 ;;
XX    .*)		echo "Usage: unlock lockfile"; exit 1 ;;
XXesac
XX
XXif [ -f $LOCKDIR/$1 -a `wc -c < $LOCKDIR/$1` -eq 4 ]
XXthen
XX    rm -f $LOCKDIR/$1
XX    exit 0
XXelse
XX    echo "Usage: unlock lockfile"
XX    exit 1
XXfi
X\End\of\File\ ./unlock
Xelse
X    echo "Not overwriting ./unlock"
Xfi
Xecho "Finished archive 1 of 1"
Xexit
\End\of\File\ ./ppp-sparc4.1/ppp.how-to-use
else
    echo "Not overwriting ./ppp-sparc4.1/ppp.how-to-use"
fi
if `test ! -s ./ppp-sparc4.1/ppp.patch1`
then
    echo "Writing ./ppp-sparc4.1/ppp.patch1"
    sed 's/^X//' > ./ppp-sparc4.1/ppp.patch1 << '\End\of\File\ ./ppp-sparc4.1/ppp.patch1'
XFrom mstar!root Thu May 24 15:43:23 1990
XReceived: by crappie.MorningStar.Com (4.0/011390)
X	id AA01888; Thu, 24 May 90 15:43:22 EDT
XReceived: by mstar.MorningStar.COM (smail2.5/SMTP)
X	id AA03054; 24 May 90 15:20:34 EDT (Thu)
XReceived: by remora.MorningStar.Com (4.1/MST-011990)
X	id AA01210; Thu, 24 May 90 15:20:30 EDT
XMessage-Id: <9005241920.AA01210@remora.MorningStar.Com>
XIn-Reply-To: <9005202017.AA28732@saqqara.cis.ohio-state.edu>
XReply-To: karl@MorningStar.Com (Karl Fox)
XFrom: karl@MorningStar.Com
XTo: Brad Clements <bkc@omnigate.clarkson.edu>
XCc: karl@MorningStar.Com, bob@MorningStar.Com
XSubject: Re:  PPP drivers/line disciplines for SunOs 4.*
XDate: Thu, 24 May 90 15:20:30 EDT
X
XBrad Clements writes:
X> You can get a beta version of PPP for Sun Os (streams) with VJ compression support
X> via anonymous ftp from
X> 	omnigate.clarkson.edu:/pub/sun/ppp.tar.Z
X> 
X> Let me know if you try it out, thanks.
X
XHere are the changes I made to get it to work under SunOs 4.0.3c on a
XSparcStation 1.  Some notes:
X
X  - SunOs 4.0.3c appears to have a bug that can cause ppp to crash with
X    a "panic: data fault" error.  If "options VDDRV" appears in your
X    kernel's configuration file, doing an I_LOOK on a stream head that
X    has no modules will cause a panic.  I have not yet received any word
X    back yet from Sun on this; I just removed the option (it is on by
X    default in the GENERIC config file that comes with the system).
X
X  - I changed the default baud rate behavior from 9600 bps to whatever
X    was set originally; it seems reasonable to me, especially for
X    dial-up connections.
X
X  - Sigvec's sv_handler struct tag is (void (*)()) on my machine --
X    maybe the 386i is different.  Also, I had to add a bunch of includes
X    to even get it to compile.
X
X  - I don't understand the need for the initial "strcpy(devname,
X    ttyname(fileno(stdin)))", so I left it in, but I did add a check to
X    make sure that strcpy() wasn't called with a null.
X
X  - If getmsg() returns a short message, the free() call returned
X    pointer+4 rather than the malloc'ed pointer.
X
X  - My modem doesn't support CRTSCTS, so I commented it out.  I suggest
X    adding a -rtscts command line option to enable it.
X
X  - I added an I_FLUSH call to purge any old cruft queued onto our
X    stream head -- the ioctl(fd, I_SETSIG, S_INPUT) documentation points
X    out that you will only get SIGPOLL if the queue is empty when a
X    message arrives, and ppp.c didn't do any initial getmsg().
X
X  - There was a bug in the (unused) getuseropt() routine.
X
XThanks for your efforts!  Let me know if I can be of any further help.
X
X					- Karl
X
Xdiff -c -r ../ppp-sunos.ORIG/fsm.c ./fsm.c
X*** ../ppp-sunos.ORIG/fsm.c	Sat Dec 16 20:06:19 1989
X--- ./fsm.c	Mon May 21 09:52:34 1990
X***************
X*** 28,33 ****
X--- 28,38 ----
X  #include <stdio.h>
X  #include <sys/types.h>
X  
X+ #ifdef STREAMS
X+ #include	<sys/stream.h>
X+ #include	<sys/socket.h>
X+ #include	<net/if.h>
X+ #endif
X  #include "ppp.h"
X  #include "fsm.h"
X  
Xdiff -c -r ../ppp-sunos.ORIG/ipcp.c ./ipcp.c
X*** ../ppp-sunos.ORIG/ipcp.c	Fri May 18 21:48:36 1990
X--- ./ipcp.c	Mon May 21 09:54:11 1990
X***************
X*** 35,40 ****
X--- 35,43 ----
X  #include <net/route.h>
X  #include <netinet/in.h>
X  
X+ #ifdef STREAMS
X+ #include <sys/stream.h>
X+ #endif
X  #include "ppp.h"
X  #include "fsm.h"
X  #include "ipcp.h"
Xdiff -c -r ../ppp-sunos.ORIG/lcp.c ./lcp.c
X*** ../ppp-sunos.ORIG/lcp.c	Sun Dec 31 03:10:44 1989
X--- ./lcp.c	Mon May 21 09:53:24 1990
X***************
X*** 37,42 ****
X--- 37,45 ----
X  #include <net/if.h>
X  #include <netinet/in.h>
X  
X+ #ifdef STREAMS
X+ #include <sys/stream.h>
X+ #endif
X  #include "ppp.h"
X  #include "fsm.h"
X  #include "lcp.h"
Xdiff -c -r ../ppp-sunos.ORIG/ppp.c ./ppp.c
X*** ../ppp-sunos.ORIG/ppp.c	Sun May 20 14:50:22 1990
X--- ./ppp.c	Thu May 24 15:14:24 1990
X***************
X*** 108,114 ****
X  char user[80];			/* User name */
X  
X  
X! int hup(), intr(), term(), alrm(), io(), incdebug(), nodebug();
X  int setdebug(), setpassive(), noopt(), novj(), noupap(), requpap();
X  int setspeed(), noaccomp(), noasyncmap(), noipaddr(), nomagicnumber();
X  int setasyncmap();
X--- 108,114 ----
X  char user[80];			/* User name */
X  
X  
X! void hup(), intr(), term(), alrm(), io(), incdebug(), nodebug();
X  int setdebug(), setpassive(), noopt(), novj(), noupap(), requpap();
X  int setspeed(), noaccomp(), noasyncmap(), noipaddr(), nomagicnumber();
X  int setasyncmap();
X***************
X*** 121,127 ****
X  struct	modlist {
X  	char	modname[FMNAMESZ+1];
X  } str_modules[MAXMODULES];
X! int	str_module_count;
X  #endif
X  /*
X   * Valid arguments.
X--- 121,127 ----
X  struct	modlist {
X  	char	modname[FMNAMESZ+1];
X  } str_modules[MAXMODULES];
X! int	str_module_count = 0;
X  #endif
X  /*
X   * Valid arguments.
X***************
X*** 228,237 ****
X  #define LOG_UPTO(x) (x)
X  #define setlogmask(x) (x)
X  #endif
X!     magic_init();
X! #ifdef	STREAMS
X!      strcpy(devname, ttyname(fileno(stdin)));
X  #endif
X      /*
X       * Initialize to the standard option set and then parse the command
X       * line arguments.
X--- 228,239 ----
X  #define LOG_UPTO(x) (x)
X  #define setlogmask(x) (x)
X  #endif
X! #ifdef        STREAMS
X!     if (ttyname(fileno(stdin)))
X! 	strcpy(devname, ttyname(fileno(stdin)));
X  #endif
X+ 
X+     magic_init();
X      /*
X       * Initialize to the standard option set and then parse the command
X       * line arguments.
X***************
X*** 289,295 ****
X  		perror("ppp: ioctl(TCGETS)");
X  		exit(1);
X  	}
X! 	tios.c_cflag  = CRTSCTS |  (inspeed  ? inspeed : B9600);
X  	tios.c_cflag |= CS8|CREAD|HUPCL;
X  	tios.c_iflag = IGNBRK;
X  	if(ioctl(fd, TCSETS, (caddr_t) &tios) < 0) {
X--- 291,297 ----
X  		perror("ppp: ioctl(TCGETS)");
X  		exit(1);
X  	}
X! 	tios.c_cflag  = /* CRTSCTS | */  (inspeed  ? inspeed : (tios.c_cflag & CBAUD));
X  	tios.c_cflag |= CS8|CREAD|HUPCL;
X  	tios.c_iflag = IGNBRK;
X  	if(ioctl(fd, TCSETS, (caddr_t) &tios) < 0) {
X***************
X*** 315,320 ****
X--- 317,327 ----
X  		perror("ppp: ioctl(I_SRDOPT, RMSGN)");
X  		exit(1);
X  	}
X+ 	/* Flush any waiting messages, or we'll never get SIGPOLL */
X+ 	if(ioctl(fd, I_FLUSH, FLUSHRW) < 0) {
X+ 		perror("ppp: ioctl(I_FLUSH, FLUSHRW)");
X+ 		exit(1);
X+ 	}
X  #else
X      /*
X       * Put the tty in raw mode and set the discipline to PPP.
X***************
X*** 684,690 ****
X   *
X   * Indicates that the physical layer has been disconnected.
X   */
X! hup()
X  {
X      if (debug > 1)
X  	printf("Hangup\n");
X--- 691,697 ----
X   *
X   * Indicates that the physical layer has been disconnected.
X   */
X! void hup()
X  {
X      if (debug > 1)
X  	printf("Hangup\n");
X***************
X*** 698,704 ****
X   *
X   * Indicates that we should initiate a graceful disconnect and exit.
X   */
X! term()
X  {
X      if (debug > 1)
X  	printf("Terminate\n");
X--- 705,711 ----
X   *
X   * Indicates that we should initiate a graceful disconnect and exit.
X   */
X! void term()
X  {
X      if (debug > 1)
X  	printf("Terminate\n");
X***************
X*** 712,718 ****
X   *
X   * Indicates that we should initiate a graceful disconnect and exit.
X   */
X! intr()
X  {
X      if (debug > 1)
X  	printf("Interrupt\n");
X--- 719,725 ----
X   *
X   * Indicates that we should initiate a graceful disconnect and exit.
X   */
X! void intr()
X  {
X      if (debug > 1)
X  	printf("Interrupt\n");
X***************
X*** 726,732 ****
X   *
X   * Indicates a timeout.
X   */
X! alrm()
X  {
X      struct itimerval itv;
X      struct callout *freep;
X--- 733,739 ----
X   *
X   * Indicates a timeout.
X   */
X! void alrm()
X  {
X      struct itimerval itv;
X      struct callout *freep;
X***************
X*** 773,779 ****
X   *
X   * Indicates that incoming data is available.
X   */
X! io()
X  {
X      int len, i;
X      u_char *p;
X--- 780,786 ----
X   *
X   * Indicates that incoming data is available.
X   */
X! void io()
X  {
X      int len, i;
X      u_char *p;
X***************
X*** 845,851 ****
X  	 */
X  	if (protocol != LCP &&
X  	    lcp_fsm[0].state != OPEN) {
X! 	    free(p);
X  	    return;
X  	}
X  
X--- 852,858 ----
X  	 */
X  	if (protocol != LCP &&
X  	    lcp_fsm[0].state != OPEN) {
X! 	    free(p - DLLHEADERLEN);
X  	    return;
X  	}
X  
X***************
X*** 899,905 ****
X   *
X   * Increment debug flag.
X   */
X! incdebug()
X  {
X      debug++;
X  }
X--- 906,912 ----
X   *
X   * Increment debug flag.
X   */
X! void incdebug()
X  {
X      debug++;
X  }
X***************
X*** 910,916 ****
X   *
X   * Turn off debugging.
X   */
X! nodebug()
X  {
X      debug = 0;
X  }
X--- 917,923 ----
X   *
X   * Turn off debugging.
X   */
X! void nodebug()
X  {
X      debug = 0;
X  }
X***************
X*** 1430,1436 ****
X       * Loop till we find an entry for this user.
X       */
X      for (;;) {
X! 	if (fgets(buf, sizeof (buf), fp)) {
X  	    if (feof(fp))
X  		break;
X  	    else {
X--- 1437,1443 ----
X       * Loop till we find an entry for this user.
X       */
X      for (;;) {
X! 	if (fgets(buf, sizeof (buf), fp) == NULL) {
X  	    if (feof(fp))
X  		break;
X  	    else {
Xdiff -c -r ../ppp-sunos.ORIG/ppp_if.c ./ppp_if.c
X*** ../ppp-sunos.ORIG/ppp_if.c	Sun May 20 13:09:08 1990
X--- ./ppp_if.c	Thu May 24 11:35:40 1990
X***************
X*** 456,461 ****
X--- 456,464 ----
X  				putnext(q,mp);
X  				p->pii_ifnet.if_ipackets++;
X  				continue;
X+ #ifndef	VJC
X+ 				}
X+ #endif
X  		}
X  		len  = 0;
X  		mb1 = NULL;
XOnly in .: tar
Xdiff -c -r ../ppp-sunos.ORIG/upap.c ./upap.c
X*** ../ppp-sunos.ORIG/upap.c	Sat Dec 16 20:06:24 1989
X--- ./upap.c	Mon May 21 09:55:09 1990
X***************
X*** 25,30 ****
X--- 25,35 ----
X  #include <sys/types.h>
X  #include <sys/time.h>
X  
X+ #ifdef STREAMS
X+ #include <sys/socket.h>
X+ #include <net/if.h>
X+ #include <sys/stream.h>
X+ #endif
X  #include "ppp.h"
X  #include "upap.h"
X  
X
\End\of\File\ ./ppp-sparc4.1/ppp.patch1
else
    echo "Not overwriting ./ppp-sparc4.1/ppp.patch1"
fi
if `test ! -s ./ppp-sparc4.1/ppp.patch2`
then
    echo "Writing ./ppp-sparc4.1/ppp.patch2"
    sed 's/^X//' > ./ppp-sparc4.1/ppp.patch2 << '\End\of\File\ ./ppp-sparc4.1/ppp.patch2'
X
XFrom karl Wed Nov 14 16:58:39 1990
XTo: Dave Alden <alden@shape.mps.ohio-state.edu>
XSubject: New PPP patch
XReply-to: karl@MorningStar.Com (Karl Fox)
X
XSee if this patch fixes the setsid() problem.  Start with a clean copy
Xof the Brad Clements PPP, then apply my previous patch, then apply this
Xone.  Let me know if it handles "all known problems".
X
X					- Karl
X
XPatch 2 to Brad Clements' SunOs PPP:
X
XFixes include:
X
X  - Fix another free() bug; this on in lcp.c
X  - Fix problem with SunOs 4.1; process group leadership needs to be
X    handled differently.
X  - I use "stty crtscts" on my modem now :-).
X
Xdiff -c ../ppp-sunos.ORIG/lcp.c ./lcp.c
X*** ../ppp-sunos.ORIG/lcp.c	Wed Nov 14 10:22:06 1990
X--- ./lcp.c	Wed Nov 14 10:29:38 1990
X***************
X*** 227,233 ****
X  {
X      fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id,
X  	      PACKET_DATA(p), len);
X!     PACKET_FREE(p);
X  }
X  
X  
X--- 227,233 ----
X  {
X      fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id,
X  	      PACKET_DATA(p), len);
X!     PACKET_FREE(p + DLLHEADERLEN);
X  }
X  
X  
Xdiff -c ../ppp-sunos.ORIG/ppp.c ./ppp.c
X*** ../ppp-sunos.ORIG/ppp.c	Wed Nov 14 10:22:08 1990
X--- ./ppp.c	Wed Nov 14 12:17:26 1990
X***************
X*** 76,81 ****
X--- 76,88 ----
X  #include <sys/conf.h>
X  #endif
X  
X+ #ifdef sun
X+ /*
X+  *	Get definition of SUNOS
X+  */
X+ #include <pixrect/pr_impl_util.h>
X+ #endif
X+ 
X  #include "magic.h"
X  #include "ppp.h"
X  #include "fsm.h"
X***************
X*** 291,297 ****
X  		perror("ppp: ioctl(TCGETS)");
X  		exit(1);
X  	}
X! 	tios.c_cflag  = /* CRTSCTS | */  (inspeed  ? inspeed : (tios.c_cflag & CBAUD));
X  	tios.c_cflag |= CS8|CREAD|HUPCL;
X  	tios.c_iflag = IGNBRK;
X  	if(ioctl(fd, TCSETS, (caddr_t) &tios) < 0) {
X--- 298,304 ----
X  		perror("ppp: ioctl(TCGETS)");
X  		exit(1);
X  	}
X! 	tios.c_cflag  = CRTSCTS | (inspeed  ? inspeed : (tios.c_cflag & CBAUD));
X  	tios.c_cflag |= CS8|CREAD|HUPCL;
X  	tios.c_iflag = IGNBRK;
X  	if(ioctl(fd, TCSETS, (caddr_t) &tios) < 0) {
X***************
X*** 371,379 ****
X--- 378,395 ----
X      pid = getpid();
X      if (debug)
X  	printf("Pid %d.\n", pid);
X+ 
X+ # if defined(sun) && defined(SUNOS) && SUNOS >= 41
X+     if (setsid() < 0)
X+ 	{
X+ 	perror("ppp: setsid()");
X+ 	exit(1);
X+ 	}
X+ # else
X      if (ioctl(fd, TIOCSPGRP, &pid) < 0) {
X  	perror("ppp: ioctl(TIOCSPGRP)");
X  	exit(1);
X+ # endif
X      }
X  
X      /*
X
\End\of\File\ ./ppp-sparc4.1/ppp.patch2
else
    echo "Not overwriting ./ppp-sparc4.1/ppp.patch2"
fi
if `test ! -s ./ppp-sparc4.1/unlock`
then
    echo "Writing ./ppp-sparc4.1/unlock"
    sed 's/^X//' > ./ppp-sparc4.1/unlock << '\End\of\File\ ./ppp-sparc4.1/unlock'
X#!/bin/sh
X
XLOCKDIR=/usr/spool/uucp
X
Xcase "$1" in
X    "")		echo "Usage: unlock lockfile"; exit 1 ;;
X    .*)		echo "Usage: unlock lockfile"; exit 1 ;;
Xesac
X
Xif [ -f $LOCKDIR/$1 -a `wc -c < $LOCKDIR/$1` -eq 4 ]
Xthen
X    rm -f $LOCKDIR/$1
X    exit 0
Xelse
X    echo "Usage: unlock lockfile"
X    exit 1
Xfi
\End\of\File\ ./ppp-sparc4.1/unlock
else
    echo "Not overwriting ./ppp-sparc4.1/unlock"
fi
if `test ! -s ./ppp-sparc4.1/ppp.patch3`
then
    echo "Writing ./ppp-sparc4.1/ppp.patch3"
    sed 's/^X//' > ./ppp-sparc4.1/ppp.patch3 << '\End\of\File\ ./ppp-sparc4.1/ppp.patch3'
X*** Readme.streams.orig	Sun May 20 13:15:31 1990
X--- Readme.streams	Mon Dec 31 15:39:27 1990
X***************
X*** 69,74 ****
X--- 69,78 ----
X  	3. Edit the file /sys/sun/str_conf.c -- Add the following lines at the
X  	   top of the file, where similar lines are located:
X  
X+ 		#include "ppp.h"
X+ 
X+ 	   Likewise, go down a few more lines, and add these lines below,
X+ 
X  		#if     NPPP > 0
X  		extern struct streamtab ppp_asyncinfo;
X  		extern struct streamtab ppp_ifinfo;
\End\of\File\ ./ppp-sparc4.1/ppp.patch3
else
    echo "Not overwriting ./ppp-sparc4.1/ppp.patch3"
fi
echo "Finished archive 1 of 1"
exit
