[comp.sources.misc] v10i002: modem callback program, part 2 of 2

howard@hasse.ericsson.se (Howard Gayle) (01/07/90)

Posting-number: Volume 10, Issue 2
Submitted-by: howard@hasse.ericsson.se (Howard Gayle)
Archive-name: callback_hg/part02

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of archive 2 (of 2)."
# Contents:  FREEZE MakeCommon callback.1 uMakefile
# Wrapped by howard@hasse on Fri Dec 29 10:22:52 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'FREEZE' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'FREEZE'\"
else
echo shar: Extracting \"'FREEZE'\" \(578 characters\)
sed "s/^X//" >'FREEZE' <<'END_OF_FILE'
X$Header: FREEZE,v 2.1 89/12/29 10:22:15 howard Exp $
X$Log:	FREEZE,v $
X# Revision 2.1  89/12/29  10:22:15  howard
X# *** empty log message ***
X# 
X# Revision 1.1  89/12/26  09:50:08  howard
X# Initial revision
X# 
X========================================
XMakeCommon   1.1     1989-12-26 09:27:08
XMakefile     1.2     1989-12-28 10:37:29
XREADME       1.2     1989-12-29 10:17:06
Xcallback.1   1.5     1989-12-29 10:16:57
Xcallback.c   1.11    1989-12-28 10:34:24
Xcallback.h   1.6     1989-12-28 16:43:44
Xcallback0.c  1.6     1989-12-28 10:34:27
XuMakefile    1.2     1989-12-28 10:50:49
END_OF_FILE
if test 578 -ne `wc -c <'FREEZE'`; then
    echo shar: \"'FREEZE'\" unpacked with wrong size!
fi
# end of 'FREEZE'
fi
if test -f 'MakeCommon' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MakeCommon'\"
else
echo shar: Extracting \"'MakeCommon'\" \(1155 characters\)
sed "s/^X//" >'MakeCommon' <<'END_OF_FILE'
X# MakeCommon - common definitions for uMakefile and Makefile for ~
X#
X# $Header: MakeCommon,v 1.1 89/12/26 09:27:08 howard Exp $
X#
X# Copyright 1990 Howard Lee Gayle
X# This file is written in the ISO 8859/1 character set.
X# 
X# This program is free software; you can redistribute it and/or modify
X# it under the terms of the GNU General Public License version 1,
X# as published by the Free Software Foundation.
X# 
X# This program is distributed in the hope that it will be useful,
X# but WITHOUT ANY WARRANTY; without even the implied warranty of
X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X# GNU General Public License for more details.
X# 
X# You should have received a copy of the GNU General Public License
X# along with this program; if not, write to the Free Software
X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X# 
X
X# Change mode of a file.
XCHMOD=chmod
X
X# Get a file from the distribution directory.
XDISTI=mkDistI
X
X# Remove a file.
XRM=zap -f
X
X# Uncompress if necessary and check out from RCS or SCCS.
XUNCMPRS=mkUncmprs
X
X# C include file search path.
XINCLUDES=-I/usr/local/local-include -I/usr/local/free/howard/0/include
END_OF_FILE
if test 1155 -ne `wc -c <'MakeCommon'`; then
    echo shar: \"'MakeCommon'\" unpacked with wrong size!
fi
# end of 'MakeCommon'
fi
if test -f 'callback.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'callback.1'\"
else
echo shar: Extracting \"'callback.1'\" \(5316 characters\)
sed "s/^X//" >'callback.1' <<'END_OF_FILE'
X.\" $Header: callback.1,v 1.5 89/12/29 10:16:57 howard Exp $
X.TH CALLBACK 1 "$Revision: 1.5 $"
X.SH NAME
Xcallback \- accept call, call back, then accept login
X.SH SYNOPSIS
X.B callback
X[
X.I type
X[
X.I tty
X] ]
X.SH COPYRIGHT
XCopyright \(co 1990 Howard Lee Gayle
X.SH DESCRIPTION
X.I callback
Xallows a user to dial up a host,
Xhave the host place a call back to the user,
Xand then initiate a login session.
XIt runs after
X.IR getty (8)
Xand before
X.IR login (1).
XWhen the user first dials up,
Xgetty presents the usual login: prompt.
XThe user can cycle through various line speeds in the usual way.
XNext,
X.I callback
Xprompts for a symbolic telephone number.
XThe prompt is the line speed, given twice.
XOn receiving a known symbolic telephone number,
X.I callback
Xwrites "BYE bye,"
Xdisconnects the call, waits a specified time 
X(default 10 seconds),
Xdials the real telephone number corresponding to the given
Xsymbolic number,
Xand then waits for connection.
XIf a modem answers,
X.I callback
Xwrites the line speed, the number of times it tried to dial the
Xtelephone number, and the line speed again.
XIt then starts up login, which prompts for the password as usual.
XIf a known symbolic telephone number is not supplied within a
Xspecified time,
Xor a connection with a modem is not established within a
Xspecified time,
X.I callback
Xtimes out.
XThe default timeout time is two minutes.
X.PP
X.I callback
Xhas the same arguments as
X.IR getty (8).
X.SH EXAMPLE
XThis example shows a session with a Hayes-compatible modem.
XThe symbolic telephone number is "hovel."
X.nf
X   atdt9999999
X
X   CONNECT 2400
X
X   hasse login: howard
X   2400 2400hovel
X   BYE bye
X
X   NO CARRIER
X
X   RING
X
X   CONNECT 2400
X
X   2400 1 2400
X   Password:
X.fi
X.SH FILES
X.DT
X.nf
X/dev/ttyd* \- dialup ports
X/dev/cua* \- dial-out ports
X/etc/ttytab \- tells init to run callback on dialup lines
X\&./bin/callback \- run by init
X\&./bin/getty-cb \- special getty that execs /bin/.cb0 instead of login
X/bin/.cb0 \- symbolic link to ./bin/callback0
X\&./bin/callback0 \- run by getty-cb
X/etc/local/callback/control/ttyd* \- symbolic-to-real phone numbers
X/etc/local/callback/log/ttyd* \- log files
X/etc/local/callback/state/ttyd* \- state files
X.fi
X.PP
XIn control files, comments start with a semicolon (;) and
Xcontinue to the end of the line.
XOnce comments, blank lines, lines containing only comments, and
Xleading and trailing white space have been stripped, each line
Xof a control file should consist of one symbolic telephone
Xnumber followed by an at sign (@) followed by a line speed
Xfollowed by white space followed by a string to command the
Xmodem to dial the desired real telephone number.
XFor example:
X.nf
X   ; Shared control file for all lines.
X   hovel@2400 atdt1234567 ; Howard's hovel.
X   hovel@1200 atdt1234567 ; Same at 1200 bit/sec.
X.fi
XWhen
X.I callback
Xsearches the control file, it appends an at sign and the line
Xspeed to the symbolic telephone number given by the user.
XThis makes it possible to send different modem commands for
Xeach line speed.
X.PP
XEach tty can have its own control file,
Xbut if the control files of several different ttys are
Xidentical, they can be links.
X.SH "SEE ALSO"
X.IR login (1),
X.IR ttytab (5),
X.IR getty (8).
X.SH DIAGNOSTICS
X"NO no" indicates an unknown symbolic telephone number.
XA time delay of a few seconds is taken to discourage brute-force attacks.
X.SH BUGS
XFor more security, it might be a good idea to turn off echo
Xwhen reading the symbolic telephone number.
XIt might also be a good idea to store symbolic telephone
Xnumbers in encrypted form.
X.PP
XThere ought to be a secure way to add a new symbolic telephone
Xnumber and its corresponding real telephone number without
Xlogging in.
XThis would be useful when travelling.
XAn approach based on one-time encryption should solve the
Xproblem.
XThe user would first encrypt the real telephone number with a
Xone-time pad corresponding to a special symbolic telephone
Xnumber,
X.I e.g.
Xby treating the telephone number as a decimal number and adding
Xanother number to it.
XThis can be done by hand.
XThe user then dials up and responds to the symbolic telephone
Xnumber prompt with a special keyword.
X.I callback
Xthen prompts for the symbolic telephone number and the
Xencrypted real telephone number (twice),
Xdecrypts it, and stores it in the control file.
X.PP
X.I callback
Xalways calls back on the line used for the incoming call.
XIf multiple lines are available, it should be possible to place
Xthe callback on a different line.
XThis greatly reduces the opportunities for spoofing.
X.SH LICENSE
XThis program is free software; you can redistribute it and/or modify
Xit under the terms of the GNU General Public License version 1,
Xas published by the Free Software Foundation.
X.PP
XThis program is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
XGNU General Public License for more details.
X.PP
XYou should have received a copy of the GNU General Public License
Xalong with this program; if not, write to the Free Software
XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X.SH AUTHOR
XHoward Gayle,
XTN/ETX/TT/HL,
XEricsson Telecom AB,
XS-126 25 Stockholm,
XSweden,
Xhoward@ericsson.se,
Xuunet!ericsson.se!howard,
XPhone: +46 8 719 5565,
XFAX: +46 8 719 9598,
XTelex: 14910 ERIC S
END_OF_FILE
if test 5316 -ne `wc -c <'callback.1'`; then
    echo shar: \"'callback.1'\" unpacked with wrong size!
fi
# end of 'callback.1'
fi
if test -f 'uMakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'uMakefile'\"
else
echo shar: Extracting \"'uMakefile'\" \(1448 characters\)
sed "s/^X//" >'uMakefile' <<'END_OF_FILE'
X# uMakefile - micro GNU makefile for callback
X#
X# $Header: uMakefile,v 1.2 89/12/28 10:50:49 howard Exp $
X#
X# Copyright 1990 Howard Lee Gayle
X# This file is written in the ISO 8859/1 character set.
X# 
X# This program is free software; you can redistribute it and/or modify
X# it under the terms of the GNU General Public License version 1,
X# as published by the Free Software Foundation.
X# 
X# This program is distributed in the hope that it will be useful,
X# but WITHOUT ANY WARRANTY; without even the implied warranty of
X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X# GNU General Public License for more details.
X# 
X# You should have received a copy of the GNU General Public License
X# along with this program; if not, write to the Free Software
X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X# 
X
Xinclude MakeCommon
X
X# Commands:
X
X# Make depend file that shows include files that C programs use.
XDEPEND=mkCIncl
X
X# Make FREEZE.*.
XMKFREEZE=mkFreeze
X
X# Sources:
XCS := $(filter %.c,$(SRCS))
XHS := $(filter %.h,$(SRCS))
X
X# Targets:
Xit = FREEZE.i
X
Xtargets := $(it) Makefile depend
X
Xifdef WORK
X.DEFAULT:
X	$(UNCMPRS) $@
Xelse # WORK
X.DEFAULT:
X	$(DISTI) $@ $(DD)
Xendif # WORK
X
X.SUFFIXES:
X.PHONY: default
X
Xdefault: $(targets)
X
Xifndef WORK
XMakefile: $(DD)/Makefile
X	$(DISTI) $@ $(DD)
Xendif # WORK
X
Xdepend: $(CS) $(HS) $(it)
X	$(DEPEND) "$(INCLUDES)" $(CS) > $@
X
XFREEZE.i: FREEZE
X	$(RM) FREEZE.*
X	$(MKFREEZE)
X	$(CHMOD) a=r FREEZE.*
END_OF_FILE
if test 1448 -ne `wc -c <'uMakefile'`; then
    echo shar: \"'uMakefile'\" unpacked with wrong size!
fi
# end of 'uMakefile'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both 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