home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!cs.utexas.edu!swrinde!mips!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnews!ask
- From: ask@cbnews.cb.att.com (Arthur S. Kamlet)
- Newsgroups: comp.unix.shell
- Subject: Re: Password protection for terminal via shell.
- Message-ID: <1992Aug12.220656.25712@cbnews.cb.att.com>
- Date: 12 Aug 92 22:06:56 GMT
- References: <1992Aug3.165658.7658@novell.com> <FRIEDMAN.92Aug3194104@nutrimat.gnu.ai.mit.edu> <4734@daily-planet.concordia.ca>
- Organization: AT&T Bell Laboratories, Columbus, Ohio
- Lines: 108
-
- In article <4734@daily-planet.concordia.ca> gsa@alcor.concordia.ca ( CON U GRADUATE STUDENTS' ASSOC ) writes:
- >Someone sent me a shell script that is supposed to password
- >protect your terminal, yet for some reason it doesn't seem
- >to be working. Can someone tell me what's wrong with this?
-
- Lots of possibilities. Need more traps for one thing.
-
-
- Here is a pretty good version of a SysV ksh script.
-
- The "cs" command is machine dependent and does a clear - many screen
- clearing commands can be used instead.
-
- On a dumb terminal (no windows, no mouse) it seems to work, though
- I'd be curious if it can be broken by non-root users.
-
- Like most scripts, anyone who can get to your terminal for a few
- seconds while it isn't protected, can just cat the file, and root
- can always read it. But for everyday stuff, it seems to work as
- good as a shell script can work.
-
-
- Be sure to chmod 700 this script
-
-
-
- ==== cut here ===
-
- # Copyright (C) Arthur S. Kamlet, 1992
- # May be reproduced for private use only as long as this copyright
- # notice is intact
- #
- # chmod 700 for this file
-
-
-
- keyword="SECRET_WORD"
-
-
-
- case $TERM in
- *hp* | *2621*)
- echo "\033H\033J\c" #clears the screen
- ;;
- 615 | 620 | 630 | 730 )
- echo "\033[2J\033[H"
- ;;
- *)
- test -s /usr/local/bin/cs && /usr/local/bin/cs
- test -s ~/bin/cs && ~/bin/cs
- ;;
- esac
- stty ignbrk -brkint -isig -echo
- systemname=`uname -n`
- while true
- do
- echo "$@ \c"
- echo "\n$systemname: Keyboard is locked. Enter key: \c"
- read word
- case $word in
- "$keyword")
- stty -ignbrk brkint isig echo
- echo ""
- break
- ;;
- "cs")
- test -s /usr/local/bin/cs && /usr/local/bin/cs
- test -s ~/bin/cs && ~/bin/cs
- ;;
- "date")
- /bin/date
- ;;
- "who")
- echo
- /bin/who -u
- ;;
- *)
- ;;
- esac
- done
-
- #=========================== cut here ===============
-
- >#
- >trap "echo Working on Process;stty echo;kill $$" 2 15
- >SECRET="secret"
- >stty -echo
- >echo "Lock string: \c"
- >read BUF1
- >echo
- >while :
- >do
- > BUF2= `line < /dev/tty`
- >if [ "$BUF2" = "$BUF1" ]
- >then break
- >elif [ "$BUF2" = "$SECRET" ]
- >then break
- >fi
- >echo "^G\c"
- >done
- >stty echo
- >
- >---------
- >Dan.
-
-
- --
- Art Kamlet a_s_kamlet@att.com AT&T Bell Laboratories, Columbus
-