UUCP Port Turnaround
brandon at tdi2.UUCP
brandon at tdi2.UUCP
Fri Feb 20 10:40:55 AEST 1987
Quoted from <13355 at sun.uucp> ["Re: UUCP Port Turnaround"], by guy%gorodish at Sun.COM (Guy Harris)...
+---------------
| >> You should try the kernel hack on a decent system before dismissing it.
| >
| >I guess it's just the Berkeley philosophy to do things in the kernel
| >whenever possible, even when it's not necessary.
|
| Oh, good grief!
|
| Putting it in the kernel (and it's *not* a lot of code, believe me -
| probably less than 1KB, and probably less than the code you have to
| add to the system if you don't do it in the kernel!) means that, as
| Rick pointed out, you *don't* have to modify "getty" or "uucp" or
| anybody else that wants to dial out.
+---------------
I'm running System V.2 (yes, *that*). The inittab and special init states
a, b, c make life a lot easier.
--------------
uugetty.sh
--------------
tty="`echo $1 | sed 's:/dev/::'`"
while test -f /usr/spool/uucp/uulk."$tty" -o -f /usr/spool/uucp/LCK.."$tty"; do
sleep 300
done
exec /etc/getty "$@"
--------------
uulock.sh
--------------
:
usage="usage: $0 [-lu] tty"
job=lock
exec > /dev/syscon 2>&1
case "$1" in
-l) job=lock
shift
;;
-u) job=unlock
shift
;;
esac
case "$#$1" in
1*) ;;
*) echo "$usage"
exit 1
esac
who -a > /tmp/uul$$
case "$job" in
unlock) grep "^uugetty /dev/$1 " /tmp/uul$$ > /dev/null 2>&1 || {
echo "$0: device /dev/$1 is unlocked or nonexistent"
/bin/rm /tmp/uul$$
exit 3
}
;;
*) grep "^LOGIN /dev/$1 " /tmp/uul$$ > /dev/null 2>&1 || {
echo "$0: device /dev/$1 is busy or nonexistent"
/bin/rm /tmp/uul$$
exit 2
}
esac
case "$job" in
unlock) /usr/lib/uucp/hup $1
rm -f /usr/spool/uucp/uulk.$1
;;
*) touch /usr/spool/uucp/uulk.1
set -- `grep "^LOGIN /dev/$1 " /tmp/uul$$`
kill -9 $7
esac
rm -f /tmp/uul$$
-------------
NOTE: /usr/lib/uucp/hup simply sends an ATZ to the modem to make it happy.
A smarter UUCP or getty or etc. could do this as well.
-------------
/etc/inittab (partial)
-------------
22:2:respawn:/etc/uugetty /dev/tty22 M1200 #Remote Dial-In
ul:b:wait:/etc/uulock -l tty22 # lock it
uu:c:wait:/etc/uulock -u tty22 # unlock it
The only oddness is in killing the existing getty; if there is none, the
program knows it's either locked already or in use.
This is probably adaptable to BSD, given that BSD has a ttys file that lets
you say what getty to run on a port. The telinit b/c stuff from System V is
just handy; it's by no means necessary. However, you'll have to change the
utmp-checking code in uulock.sh to check processes instead.
++Brandon
--
``for is he not of the Children of Luthien? Never shall that line fail, though
the years may lengthen beyond count.'' --J. R. R. Tolkien
Brandon S. Allbery UUCP: cbatt!cwruecmp!ncoast!tdi2!brandon
Tridelta Industries, Inc. CSNET: ncoast!allbery at Case
7350 Corporate Blvd. INTERNET: ncoast!allbery%Case.CSNET at relay.CS.NET
Mentor, Ohio 44060 PHONE: +1 216 255 1080 (home) +1 216 974 9210
More information about the Comp.unix.wizards
mailing list