home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / shell / 3468 < prev    next >
Encoding:
Internet Message Format  |  1992-08-12  |  2.7 KB

  1. 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
  2. From: ask@cbnews.cb.att.com (Arthur S. Kamlet)
  3. Newsgroups: comp.unix.shell
  4. Subject: Re: Password protection for terminal via shell.
  5. Message-ID: <1992Aug12.220656.25712@cbnews.cb.att.com>
  6. Date: 12 Aug 92 22:06:56 GMT
  7. References: <1992Aug3.165658.7658@novell.com> <FRIEDMAN.92Aug3194104@nutrimat.gnu.ai.mit.edu> <4734@daily-planet.concordia.ca>
  8. Organization: AT&T Bell Laboratories,  Columbus, Ohio
  9. Lines: 108
  10.  
  11. In article <4734@daily-planet.concordia.ca> gsa@alcor.concordia.ca ( CON U GRADUATE STUDENTS' ASSOC ) writes:
  12. >Someone sent me a shell script that is supposed to password
  13. >protect your terminal, yet for some reason it doesn't seem
  14. >to be working.  Can someone tell me what's wrong with this?
  15.  
  16. Lots of possibilities.  Need more traps for one thing.
  17.  
  18.  
  19. Here is a pretty good version of a SysV  ksh  script.
  20.  
  21. The "cs" command is machine dependent and does a clear - many screen
  22. clearing commands can be used instead.
  23.  
  24. On a dumb terminal (no windows, no mouse)  it seems to work, though
  25. I'd be curious if it can be broken by non-root users.
  26.  
  27. Like most scripts, anyone who can get to your terminal for a few
  28. seconds while it isn't protected, can just cat the file, and root
  29. can always read it.  But for everyday stuff, it seems to work as
  30. good as a shell script can work.
  31.  
  32.  
  33. Be sure to chmod 700 this script
  34.  
  35.  
  36.  
  37. ==== cut here ===
  38.  
  39. # Copyright (C) Arthur S. Kamlet, 1992
  40. # May be reproduced for private use only as long as this copyright
  41. # notice is intact
  42. #
  43. # chmod 700 for this file
  44.  
  45.  
  46.  
  47. keyword="SECRET_WORD"
  48.  
  49.  
  50.  
  51. case $TERM in
  52.     *hp* | *2621*)
  53.         echo "\033H\033J\c"  #clears the screen
  54.         ;;
  55.     615 | 620 | 630 | 730 )
  56.         echo "\033[2J\033[H"
  57.         ;;
  58.     *)
  59.         test -s /usr/local/bin/cs && /usr/local/bin/cs
  60.          test -s ~/bin/cs && ~/bin/cs
  61.         ;;
  62. esac
  63. stty ignbrk -brkint -isig -echo
  64. systemname=`uname -n`
  65. while true
  66. do
  67.     echo "$@ \c"
  68.     echo "\n$systemname:  Keyboard is locked. Enter key: \c"
  69.     read word
  70.     case $word in
  71.         "$keyword")
  72.             stty -ignbrk brkint isig echo
  73.             echo ""
  74.             break
  75.             ;;
  76.         "cs")
  77.             test -s /usr/local/bin/cs && /usr/local/bin/cs
  78.              test -s ~/bin/cs && ~/bin/cs
  79.             ;;
  80.         "date")
  81.             /bin/date
  82.             ;;
  83.         "who")
  84.             echo
  85.             /bin/who -u
  86.             ;;
  87.         *)
  88.             ;;
  89.     esac
  90. done
  91.  
  92. #===========================  cut here ===============
  93.  
  94. >#
  95. >trap "echo Working on Process;stty echo;kill $$" 2 15
  96. >SECRET="secret"
  97. >stty -echo
  98. >echo "Lock string: \c"
  99. >read BUF1
  100. >echo
  101. >while :
  102. >do
  103. > BUF2= `line < /dev/tty`
  104. >if [ "$BUF2" = "$BUF1" ]
  105. >then break
  106. >elif [ "$BUF2" = "$SECRET" ]
  107. >then break
  108. >fi
  109. >echo "^G\c"
  110. >done
  111. >stty echo
  112. >
  113. >---------
  114. >Dan.
  115.  
  116.  
  117. -- 
  118. Art Kamlet  a_s_kamlet@att.com  AT&T Bell Laboratories, Columbus
  119.