#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1998-10-08 14:16 EDT by <warlord@indiana.mit.edu>.
# Source directory was `/afs/sipb.mit.edu/user/warlord/media/C/secure-ppp/src'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#    589 -r--r--r-- Makefile
#   2353 -r--r--r-- main.c
#    959 -r--r--r-- ip-up
#    133 -r--r--r-- ip-down
#    149 -r--r--r-- .ppprc
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh19885; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= Makefile ==============
if test -f 'Makefile' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'Makefile' '(file already exists)'
else
  $echo 'x -' extracting 'Makefile' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
CC=cc
SHAR=shar
X
#SSH= wherever your ssh build tree lives.....
SSH=Athena-TopDir/third/ssh/
X
# Define where to find (or put) various files
SSH_PROG=	/usr/athena/bin/ssh
SSH_USER=	Pwarlord
PPPD_PROG=	/sbin/pppd
PPPD_RC=	/home/borer/.ppprc
PIDFILE=	/home/borer/ptyfu.pid
X
CFLAGS+= -DPIDFILE=\"$(PIDFILE)\" -DSSH_PROG=\"$(SSH_PROG)\" \
X	-DSSH_USER=\"$(SSH_USER)\" -DPPPD_PROG=\"$(PPPD_PROG)\" \
X	-DPPPD_RC=\"$(PPPD_RC)\"
X
OBJS=main.o ${SSH}pty.o ${SSH}log-client.o ${SSH}xmalloc.o
X
pppfu: ${OBJS}
X	$(CC) -o ptyfu ${OBJS} -lutil
X
pppfu.shar:
X	$(SHAR) Makefile main.c  ip-up ip-down .ppprc >$@
SHAR_EOF
  $shar_touch -am 1008141498 'Makefile' &&
  chmod 0444 'Makefile' ||
  $echo 'restore of' 'Makefile' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'Makefile:' 'MD5 check failed'
55486db89f3abee37f55ec7929277011  Makefile
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'Makefile'`"
    test 589 -eq "$shar_count" ||
    $echo 'Makefile:' 'original size' '589,' 'current size' "$shar_count!"
  fi
fi
# ============= main.c ==============
if test -f 'main.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'main.c' '(file already exists)'
else
  $echo 'x -' extracting 'main.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'main.c' &&
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h> 
X
int ppppid, sshpid;
X
#ifndef PIDFILE
#define PIDFILE "/d2/borer/ptyfu.pid"
#endif
X
#ifndef SSH_PROG
#define SSH_PROG "/usr/pkg/bin/ssh"
#endif
X
#ifndef SSH_USER
#define SSH_USER "Porchard"
#endif
X
#ifndef PPPD_PROG
#define PPPD_PROG "/usr/sbin/pppd"
#endif
X
#ifndef PPPD_RC
#define PPPD_RC "/d2/borer/.ppprc"
#endif
X
void cleanup(int sig) {
X  if (ppppid)
X    kill(ppppid, SIGTERM);
X  sleep(1);
X  if (sshpid)
X    kill(sshpid, SIGTERM);
X  unlink(PIDFILE);
X  exit(1);
}
X
void reaper(int sig) {
X  int status;
X  int deadpid = waitpid(-1, &status, WNOHANG);
X  if (deadpid) {
X    if (deadpid == ppppid) {
X      fprintf(stderr, "pppd died\n");
X      ppppid = 0;
X    }
X    if (deadpid == sshpid) {
X      fprintf(stderr, "ssh died\n");
X      sshpid = 0;
X    }
X  }
}
X
main(int argc, char **argv)
{
X  sigset_t nosig;
X  char ptybuf[64];
X  int pty, tty;
X  char *host;
X  int mypid = getpid();
X  FILE *pidfile;
X
X  if (argc != 2) {
X    fprintf (stderr, "Usage: %s host\n", argv[0]);
X    exit (1);
X  }
X
X  host = argv[1];
X  
X  /* unholy pipefitting: pppd<-ssh->sshd->pppd */
X  signal(SIGCHLD, reaper);
X  signal(SIGINT, cleanup);
X  signal(SIGTERM, cleanup);
X
X  pidfile = fopen(PIDFILE, "w");
X  if (pidfile == NULL) {
X    perror(PIDFILE);
X    exit(1);
X  }
X  fprintf(pidfile, "%d\n", mypid);
X  fclose(pidfile);
X
X  /* grab a pty.. */
X  pty_allocate(&pty, &tty, ptybuf);
X
X  printf("Grabbed %s\n", ptybuf);
X
X  fflush(NULL);
X  ppppid = fork();
X  if (ppppid < 0) {
X    perror("fork");
X    cleanup(0);
X  }
X
X  if (ppppid == 0) {
X    /* child.  start pppd... */
X    dup2(tty, 0);
X    dup2(tty, 1);
X    close(pty);
X    close(tty);
X    sleep(10);
X    fprintf(stderr, "execing pppd...\n");
X    execlp(PPPD_PROG, "pppd", ptybuf, "file", PPPD_RC, NULL);
X    _exit(1);
X  }
X
X  sshpid = fork();
X  if (sshpid < 0) {
X    perror("fork");
X    cleanup(0);
X  }
X
X  if (sshpid == 0) {
X    /* child.  start sshd... */
X    dup2(pty, 0);
X    dup2(pty, 1);
X    close(pty);
X    close(tty);
X
X    fprintf(stderr, "execing ssh...\n");
X    execlp(SSH_PROG, "ssh", host, "-v", "-x", "-l", SSH_USER, NULL);
X    _exit(1);
X  }
X  close(tty);
X  close(pty);
X  while (sshpid || ppppid) {
X    sigemptyset(&nosig);
X    sigsuspend(&nosig);
X    fprintf(stderr, "awake!\n");
X  }
X  cleanup(0);
}
SHAR_EOF
  $shar_touch -am 1001150198 'main.c' &&
  chmod 0444 'main.c' ||
  $echo 'restore of' 'main.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'main.c:' 'MD5 check failed'
201e7995713b3ef06eb6c702c4aa8088  main.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'main.c'`"
    test 2353 -eq "$shar_count" ||
    $echo 'main.c:' 'original size' '2353,' 'current size' "$shar_count!"
  fi
fi
# ============= ip-up ==============
if test -f 'ip-up' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'ip-up' '(file already exists)'
else
  $echo 'x -' extracting 'ip-up' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'ip-up' &&
#! /bin/sh
X
# hpnet() {
# 	defdomain=ch.apollo.hp.com
# 	rootcache=/etc/namedb/cache.root.hp
# 	forwarders="15.254.24.3"
# 	xntpd="-c /etc/ntp.conf.hp -p /var/run/xntp.pid"
# 	rm -f /etc/resolv.conf
# 	if [ ! -z "${defdomain}" ]
# 	then
# 		echo "search ${defdomain}" >/etc/resolv.conf
# 	fi
# 	if [ ! -z "${rootcache}" ]
# 	then    (
# 		echo "directory		/etc/namedb"
# 		echo "cache	.	${rootcache}"
# 		echo "primary	127.in-addr.arpa	local"
# 		if [ ! -z "${forwarders}" ]
# 		then
# 			echo "forwarders	${forwarders}"
# 		fi
# 		) >/etc/named.boot
# 		named_flags="/etc/named.boot"
# 	fi
# 	if [ "X${named_flags}" != X"NO" ]; then
# 		echo ' named'; /usr/sbin/named $named_flags
# 	fi
# }
X
umask 22
intf=$1
tty=$2
speed=$3
local=$4
remote=$5
misc=$6
case $remote
in
X	15.22.*)
X		/sbin/route add 15.0.0.0 $remote
#		/sbin/route add 15.254.24.3 205.180.222.1
#		kill $(cat /var/run/named.pid)
#		hpnet
X		;;
#	15.20.0.3)
#		hpnet
#		. /etc/rc.local
X		;;
esac
X
SHAR_EOF
  $shar_touch -am 1001144498 'ip-up' &&
  chmod 0444 'ip-up' ||
  $echo 'restore of' 'ip-up' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'ip-up:' 'MD5 check failed'
504266c4d05c46ee00b7196907fd5a64  ip-up
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'ip-up'`"
    test 959 -eq "$shar_count" ||
    $echo 'ip-up:' 'original size' '959,' 'current size' "$shar_count!"
  fi
fi
# ============= ip-down ==============
if test -f 'ip-down' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'ip-down' '(file already exists)'
else
  $echo 'x -' extracting 'ip-down' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'ip-down' &&
#! /bin/sh
intf=$1
tty=$2
speed=$3
local=$4
remote=$5
misc=$6
case $remote
in
X	15.*)
X		/sbin/route delete 15.0.0.0 $remote
X		;;
esac
SHAR_EOF
  $shar_touch -am 1001144498 'ip-down' &&
  chmod 0444 'ip-down' ||
  $echo 'restore of' 'ip-down' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'ip-down:' 'MD5 check failed'
6f297588353b5ec526448328a62283b9  ip-down
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'ip-down'`"
    test 133 -eq "$shar_count" ||
    $echo 'ip-down:' 'original size' '133,' 'current size' "$shar_count!"
  fi
fi
# ============= .ppprc ==============
if test -f '.ppprc' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING '.ppprc' '(file already exists)'
else
  $echo 'x -' extracting '.ppprc' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > '.ppprc' &&
noipdefault
asyncmap 00000000
128.224.138.254:128.224.138.253
-bsdcomp
ipparam sludge
vj-max-slots 16
mtu 576
netmask 255.255.255.252
nodefaultroute
SHAR_EOF
  $shar_touch -am 1001144498 '.ppprc' &&
  chmod 0444 '.ppprc' ||
  $echo 'restore of' '.ppprc' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo '.ppprc:' 'MD5 check failed'
28ea604565e8675cad060780e6ff710a  .ppprc
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < '.ppprc'`"
    test 149 -eq "$shar_count" ||
    $echo '.ppprc:' 'original size' '149,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh19885
exit 0
