Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Locking a terminal Keywords: lock, tty Message-ID: <3711@goanna.cs.rmit.oz.au> Date: 9 Sep 90 12:23:43 GMT References: Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 35 In article , ric@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.