Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!cwruecmp!hal!ncoast!tdi2!brandon From: brandon@tdi2.UUCP Newsgroups: comp.sources.wanted,comp.unix.wizards,comp.unix.questions Subject: Re: UUCP Port Turnaround Message-ID: <135@tdi2.UUCP> Date: Thu, 19-Feb-87 19:40:55 EST Article-I.D.: tdi2.135 Posted: Thu Feb 19 19:40:55 1987 Date-Received: Sat, 21-Feb-87 04:38:48 EST References: <171@ndmath.UUCP> <4090@nsc.nsc.com> <166@piaget.UUCP> <43099@beno.seismo.CSS.GOV> <2388@homxb.UUCP> <13355@sun.uucp> Reply-To: brandon@tdi2.UUCP (Brandon Allbery) Followup-To: comp.sources.wanted Organization: Tridelta Industries, Inc., Mentor, OH Lines: 101 Xref: utgpu comp.sources.wanted:594 comp.unix.wizards:1068 comp.unix.questions:1125 Quoted from <13355@sun.uucp> ["Re: UUCP Port Turnaround"], by guy%gorodish@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@Case 7350 Corporate Blvd. INTERNET: ncoast!allbery%Case.CSNET@relay.CS.NET Mentor, Ohio 44060 PHONE: +1 216 255 1080 (home) +1 216 974 9210