cleaned up lockem
[feisty_meow.git] / scripts / tty / lockem.sh
index 473e086769529dbdf8d03271b5f628d8d2cbecde..fb781b144d6c4084397a3460c0998164a80f1f08 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # Can be used to lock up a terminal screen until the user enters the correct
-# password.  Pretty sturdy.  Store your password in the file "PASSWORDFILE",
+# password.  Pretty sturdy.  Store your password in the file "PASSWORD_FILE",
 # configured below.
 #
 # Thanks to Kevin Wika for this shell.
@@ -15,27 +15,29 @@ trap '' STOP
 trap '' EXIT
 trap '' TSTP
 
-PASSWORDFILE=$TMP/lockup_password_file
-LOGFILE=$TMP/session-lockup.log
+PASSWORD_FILE=$TMP/lockem.password
+LOG_FILE=$TMP/session-lockem.log
 
-if [ ! -f "$PASSWORDFILE" ]; then
+if [ ! -f "$PASSWORD_FILE" ]; then
   sep
   echo "no password file is configured.  please put your unlock password in:"
-  echo "$PASSWORDFILE"
+  echo "$PASSWORD_FILE"
   sep
   exit 1
 fi
 
-read password <$PASSWORDFILE
+chmod 700 "$PASSWORD_FILE"
 
-echo "$(date_stringer): +++ terminal locked" >>$LOGFILE
+read password <"$PASSWORD_FILE"
+
+echo "$(date_stringer): +++ terminal locked" >>"$LOG_FILE"
 
 attempt=""
 
 stty -echo
 while [[ $attempt != $password ]]; do
   if [ ! -z "$attempt" ]; then
-    echo "$(date_stringer): login attempt with wrong password at $(date)" >>$LOGFILE
+    echo "$(date_stringer): login attempt with wrong password at $(date)" >>$LOG_FILE
   fi
   clear
   nechung
@@ -44,8 +46,8 @@ while [[ $attempt != $password ]]; do
 done
 stty echo
 
-echo "$(date_stringer): successful login" >>$LOGFILE
-echo "$(date_stringer): --- terminal unlocked" >>$LOGFILE
+echo "$(date_stringer): successful login" >>$LOG_FILE
+echo "$(date_stringer): --- terminal unlocked" >>$LOG_FILE
 
 clear
 echo "hi $USER, your password has been accepted.  enjoy your computer."