Locking a terminal

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Sun Sep 9 22:23:43 AEST 1990


In article <ric.652635631 at ace>, ric at ace.sri.com (Richard Steinberger) writes:
[a UNIX shell script for locking a TTY]
It ends with the command

>	stty echo susp '^Z'

***Please*** don't do that!  Why?  Because smashing someone's terminal
settings when you don't need to is just plain bad manners.  Yes,
digging the old susp character out of the output of `stty everything`
is tricky.  Here's one way of doing it
	#!/bin/sh
	stty everything 2>/tmp/stty$$
	ed /tmp/stty$$ <<'end_of_edit' >/dev/null
	1,$-1d
	$s:..     ..     ..     ..     ..     ..     :Susp=":
	$s: .*$:":
	$s:/:" Dsusp=":
	w
	q
	end_of_edit
	. /tmp/stty$$
	rm /tmp/stty$$
After doing this, $Susp is (for example) "^X"
and $Dsusp is (for example) "^Y".  Then one can do
	stty susp "$Susp" dsusp "$Dsusp"
to restore these two characters.

As well as bad manners, the shell script I'm criticising had a mistake:
it switched off the "immediate suspend" character (susp) but not the
"suspend when read" character (dsusp).  So someone typing ^Y in the
middle of a "password" could in fact suspend (and thus bypass) the locker.
Hardly secure...

-- 
Psychiatry is not about cure.  Psychiatry is about power.



More information about the Comp.lang.c mailing list