PCP Pursuit dialers

David L. Smith dave at sdeggo.UUCP
Mon Mar 7 16:20:52 AEST 1988


I whipped up this stuff to make dealing with PC Pursuit for UUCP connections
a little easier; hopefully it will benefit other Microport users out on the
net.  

Enjoy!
David L. Smith
{sdcsvax!jack,ihnp4!jack, hp-sdd!crash, pyramid, uport}!sdeggo!dave
sdeggo!dave at amos.ling.edu 
Sinners can repent, but stupid is forever.
---------cut here------------

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  README lock.c pcpdial pcptime.c uucico.c uucico.sh
# Wrapped by dave at sdeggo on Sun Mar  6 22:18:11 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(3642 characters\)
sed "s/^X//" >README <<'END_OF_README'
X
XFollowing are my kludges for Microport uucp to make it work with PC Pursuit a 
Xlittle more gracefully.
X
Xpcpdial - This is a dialer script which will interact with PC Pursuit.  
XIt takes its arguments from the L-devices file.  An L-devices line should
Xbe made for each site you wish to call through PC Pursuit along with a
Xlink in /dev to the dialout port you wish them to use.  For example, to call
XMicroport:
X
XDIR uportd pcpdial 408 4381680
X
Xuucico.c - Just a front-end for uucico.sh so that uucico.sh can be run setuid
Xuucp.
X
Xuucico.sh - This goes around uucico and implements additional locking.  Since
Xthere are multiple names for the dial-out line, uucico, left to its own 
Xdevices, could try to dial two systems on the same line, thinking that it
Xwas two different devices.  This script has the PC Pursuit system names
Xhardcoded into it and for these systems checks for a lock on the real port
Xname, and if there is not one creates it.  It then calls the renamed
Xuucico to place the call, then removes the lock file when it returns.
X
Xlock.c - Does a lock on a file atomically.
X
Xpcptime.c - This checks to see if it's OK to make a PC-Pursuit call.  Not
Xreally necessary, but it cuts down immensely on the amount of trash
X(CAN'T CALL XXX - WRONG TIME) messages in the LOGFILE.
X
XWhy not just have a dialinfo script?  Well, problem number one is that a
Xdifferent dialer script needs to be called to use PC Pursuit than to make
Xa local call.  System V uucp only allows for DIR and ACU type devices.
XSo, we can't make a PCP device.  We could, however, have different speeds
Xcall different dialer scripts (1200==PCP, 2400==normal dialer).  Problem two 
Xis that the PCP dialer needs to know what area code it is calling and the 
Xdialinfo script cannot parse that out of the phone number uucico passes it
Xfrom the L.sys file.  This leads to creating the different devices so that
Xthe area code can be passed from the L-devices file.  Since the only way
Xto make certain we get the correct dialer is by making it a DIR device and
Xthen having it explicitly specifying that device in the L.sys file, we
Xhave to also pass the phone number from L-devices, so instead of having a
XL-devices entry for each area code, we must have an entry for each system
Xwe call and a device for each system.
X
XIt's kludgey, but it works.
X
XInstallation:
X
X1. Turn off cron, or stop uucp from executing somehow, or it's might get
Xvery confused while you're playing with its files.
X
X2. Go to /usr/lib/uucp and mv uucico uucico.exe . 
X
X3. Compile uucico.c and lock.c and put the executables in /usr/lib/uucp owned 
Xby uucp and with the setuid bit set.  Compile pcptime and put it in 
X/usr/lib/uucp owned by uucp (you can setuid if you like, but it doesn't make
Xa difference).
X
X4. Put uucico.sh in /usr/lib/uucp and edit it for your system.  The comments in
Xthere should be self-explanatory.  You need to change system names and the
Xdevice it locks.
X
X5. Add the pcpdial script into /usr/lib/uucp/dialinfo and edit in your own
XPC Pursuit account number, password and local access number.
X
X6. Edit L-devices and L.sys for those systems you want to call via PC Pursuit.
XYour entries should look something like this:
X
XL-devices:
XDIR uportd pcpdial 1200 408 4381680
X
XL.sys:
X
X# time details are taken care of by the uucico driver script
Xuport Any,1 uportd 1200 uportd "" \n\n in:-\n-in:-\n-in: nuucp
X
X7. Go to /dev and create the devices you need for your PC-Pursuit systems.
XUse ln to make links from your dialer device (e.g. /dev/tty1) to these names,
XNOT mknod.
X
X8.  This should be everything.  Start up a uucico to test it out and stand well
Xback in case anything blows up.
X
X
END_OF_README
if test 3642 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f lock.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"lock.c\"
else
echo shar: Extracting \"lock.c\" \(337 characters\)
sed "s/^X//" >lock.c <<'END_OF_lock.c'
X/*
X  Program to allow shell files to atomically make/check for lock files
X
X*/
X
X#include <stdio.h>
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X if (argc!=2)
X {
X  fprintf(stderr, "usage: lock lockfile\n");
X  exit(-1);
X }
X umask(0);	/* clear the umask */
X if (creat(argv[1], 0400)==-1)	/* couldn't create the file */
X  exit(-1);
X exit(0);
X}
END_OF_lock.c
if test 337 -ne `wc -c <lock.c`; then
    echo shar: \"lock.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f pcpdial -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"pcpdial\"
else
echo shar: Extracting \"pcpdial\" \(1780 characters\)
sed "s/^X//" >pcpdial <<'END_OF_pcpdial'
X##############################################################
X#       Dialinfo - Dialer procedure definitions              #
X#                                                            #
X#    See dialer.1 dialprint.1 dial.2 dialinfo.7 for          #
X#    more information.   And good luck.                      #
X#                                                            #
X#                                Gene H. Olson (author)      #
X##############################################################
X
X# Note that this sets your modem for numeric codes.  This is also configured
X# for a USR dialer.  You may need to modify the first few lines for you own
X# modem.
Xpcpdial,
X	star=*, pound=#, flash=H0\,H1,
X	delay=\,, wait=\,, retry=90,
X	s0=P1 M"AT Q0 V0 X2 E0 S11=40 S2=64\r" [0]1 S10 T3,
X	s1=E"dialing Telenet" M"ATDT 2330233\r" [5]9 [3]2 [7]5 [12]8 [4]4 S60 T3,
X	s2=E"no answer ..." D1 R10 G0,
X	s3=E"no modem response ..." D1 R10 G0,
X	s4=E"modem error ..." M"AT H" D1 R10 G0,
X	s5=E"busy ..." R3 G12,
X	s6=E"no dialtone..." D1 R10 G0,
X	s8=E"Voice!" D1 R100 G-,
X# End of modem specifics
X	s9=E"Connected to Telenet" M"\r\r" T20 G12,
X	s12=S3 E"Looking for Telenet prompt\n" M"\r" [@]13 T12 R3,
X	s13=S60 M"C DIAL%4/12\,YourAccount\r" [WORD =]14 S30 T20,
X	s14=M"YourPassword\r" [CONNE]15 [BUSY]7,
X#Yeah, it's out of place, but I didn't want to renumber the file
X	s7=E"Dial%4/12 Busy!" R5 G12,
X# talk to dialer on other end of PC Pursuit
X	s15=P1 M"\r" M"ATZ\r" [OK]16 T3,
X	s16=E"dialing %1 %2 %3 %4 %{DIALDEBUG}" M"AT DT%5\r" [BUSY]17 [CONNE]19 S60 T18,
X	s17=E"no answer ..." R3 G16,
X#if no dialer response, close connection and get a new one ( if possible)
X	s18=E"no modem response ..." M"@\rD\r" [DIS]13 R10 G20,
X	s19=C1 G+,
X	s20=E"Timed out waiting for Telenet response" D1 R3 G0,
END_OF_pcpdial
if test 1780 -ne `wc -c <pcpdial`; then
    echo shar: \"pcpdial\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f pcptime.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"pcptime.c\"
else
echo shar: Extracting \"pcptime.c\" \(522 characters\)
sed "s/^X//" >pcptime.c <<'END_OF_pcptime.c'
X/*
X   pcptime - returns 1 if it's OK to make a PCP call, 0 if not
X   Needs to learn about holidays
X
X*/
Xextern long time();
X
X#include <time.h>
X
Xmain()
X{
X long inttime;
X struct tm * curtime;
X
X inttime=time(0);
X curtime=localtime(&inttime);
X
X if ((curtime->tm_wday==0) || (curtime->tm_wday==6))	/* Saturday or Sunday */
X   return(0);	/* anytime Sat or Sun is good */
X
X if ((curtime->tm_hour>=18)||(curtime->tm_hour<7))
X   return(0);	/* anytime between 6:15 PM and 7 AM is good */
X 
X return(-1);	/* otherwise, it's no go */
X}
END_OF_pcptime.c
if test 522 -ne `wc -c <pcptime.c`; then
    echo shar: \"pcptime.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uucico.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uucico.c\"
else
echo shar: Extracting \"uucico.c\" \(349 characters\)
sed "s/^X//" >uucico.c <<'END_OF_uucico.c'
X/*
X	This is a silly little program to execute a shell file via
X	/bin/sh, undeniably, with no possibility of screw-up
X
X*/
X
X#include <stdio.h>
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X char line[255];
X int i;
X sprintf(line,"/usr/lib/uucp/uucico.sh ",argv[0]);
X for(i=1;i<argc;i++)
X {
X  strcat(line, argv[i]);
X  strcat(line," ");
X }
X system(line);
X}
END_OF_uucico.c
if test 349 -ne `wc -c <uucico.c`; then
    echo shar: \"uucico.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uucico.sh -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uucico.sh\"
else
echo shar: Extracting \"uucico.sh\" \(1413 characters\)
sed "s/^X//" >uucico.sh <<'END_OF_uucico.sh'
X
X# wrapper for uucico
X# checks to see if the system to be called is one of the PC Pursuit ones
X# and if so, checks for and then creates the LCK..tty1  Otherwise it just
X# passes through to uucico
X
X# check to see if we were called with any arguments
Xif test $# -eq 0
Xthen
X exec /usr/lib/uucp/uucico.exe
Xfi
X
X# check for "uucico -r1"
X# this one can be tricky
X# we will call the script again for each system, spawning new processes
Xif test $# -eq 1
Xthen
X  if test $1 = "-r1"
X  then
X#important!  Only put first six letters of system name in here
X#this line should contain all systems called, local and PC Pursuit
X  for i in System1 System2 Etc
X  do
X    if test -f /usr/spool/uucp/C.$i*
X    then
X# call the script again for this particular system
X      /usr/lib/uucp/uucico -r1 -s$i
X    fi
X  done
X# we're done, exit now
X  exit
X  fi
Xfi
X
X# check to see if we got called with a system name
Xif test $# -ge 2
Xthen
X# check to see if it's one of the PC Pursuit systems
X#important!  Only put first six letters of system name in here
X  if test $2 = "-sPCPSystem1"  -o $2 = "-sPCPSystem2" 
X  then
X    if pcptime
X    then
X# check to see if port is locked
X# change this line to reflect the real dialout port you're using
X      if /usr/lib/uucp/lock /usr/spool/uucp/LCK..tty1
X      then
X        /usr/lib/uucp/uucico.exe $*
X        rm -f /usr/spool/uucp/LCK..tty1
X      fi
X    fi
X    exit
X  fi
Xfi
X
Xexec /usr/lib/uucp/uucico.exe $*
X
X
END_OF_uucico.sh
if test 1413 -ne `wc -c <uucico.sh`; then
    echo shar: \"uucico.sh\" unpacked with wrong size!
fi
chmod +x uucico.sh
# end of overwriting check
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 1 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
David L. Smith
{sdcsvax!jack,ihnp4!jack, hp-sdd!crash, pyramid, uport}!sdeggo!dave
sdeggo!dave at amos.ling.edu 
Sinners can repent, but stupid is forever.



More information about the Comp.unix.microport mailing list