PC7300 dial-in lock creator
Dave Brower
daveb at rtech.UUCP
Thu Dec 5 18:43:55 AEST 1985
Below is a program that creates a /usr/spool/uucp/LCK file for the
phone line being used by a dialed-in user. The 7300 shares one
line for outgoing uucp and cu and incoming users. Outgoing processes
will just hang up on a remote user when they decide they want the phone
unless an LCK file is there.
The program is to be run out of the /etc/profile when the dial-in user
is selecting his terminal type. It creates the LCK file, then puts a
reaper child to sleep. When the line is eventually hung up, the child
gets a HUP, wakes up, deletes the lock file and exits.
---------------- hack 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 the files:
# Makefile
# dialin.c
# This archive created: Thu Dec 5 00:04:14 1985
export PATH; PATH=/bin:$PATH
if test -f 'Makefile'
then
echo shar: will not over-write existing file "'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
#
# Makefile for dialin program to make /usr/spool/uucp/LCK.. files
# to keep dial in lines from getting dropped by outgoin uucp or cu.
#
# you probably need to be root to do the install.
dialin: dialin.o
ld /lib/crt0s.o /lib/shlib.ifile dialin.o -o dialin
strip dialin
@size dialin
@ls -l dialin
install: dialin
cp dialin /usr/bin
chmod 755 /usr/bin/dialin
chgrp bin /usr/bin/dialin
chown bin /usr/bin/dialin
@echo 'Now edit the file /etc/profile -- see the source'
SHAR_EOF
fi # end of overwriting check
if test -f 'dialin.c'
then
echo shar: will not over-write existing file "'dialin.c'"
else
cat << \SHAR_EOF > 'dialin.c'
/*----------------------------------------------------------------
**
** dialin.c -- create uucp LCK file for a dialin line.
**
** The 7300 has an annoying habit of blasting a dialed-in user
** when it wants the UUCP phone line. Running this program out
** of the profile prevents that from happening by creating a
** /usr/spool/uucp/LCK..ph? file for the line. A child process
** is left sleeping, and when the phone is hung up by the caller,
** the lock file is removed.
**
** Compile:
** cc -O -c dialin.c
** ld /lib/crt0s.o /lib/shlib.ifile dialin.o -o dialin
** strip dialin
** cp dialin /usr/bin
**
** Edit /etc/profile and add the line:
**
** /usr/bin/dialin
**
** to the block that asks what kind of terminal is being used, BEFORE
** the 'while true' loop is started.
**
** Author:
** David Brower, {ucbvax!mtxinu,cbosgd,amdahl}!rtech!gonzo!daveb
**
** Rights:
** No rights reserved. This program is placed in the public domain.
*/
# include <stdio.h>
# include <signal.h>
bye()
{
/* a null signal catcher */
}
main()
{
char cmd[80];
char ttydev[ 20 ];
char * strrchr();
char * ttyname();
char * tty;
strcpy( ttydev, ttyname());
tty = strrchr( ttydev, '/' ) + 1;
printf("locking %s until HUP\n", ttydev );
sprintf( cmd, "echo $LOGNAME > /usr/spool/uucp/LCK..%s\n", tty );
system( cmd );
sprintf( cmd, "rm /usr/spool/uucp/LCK..%s\n", tty );
if( !fork() )
{
/* wait for HUP and remove lock file */
(void) signal( SIGHUP, bye );
pause();
system( cmd );
}
exit( 0 );
}
SHAR_EOF
fi # end of overwriting check
# End of shell archive
exit 0
--
More information about the Comp.sources.unix
mailing list