Annotation of src/usr.bin/skey/skeyaudit.sh, Revision 1.3
1.1 deraadt 1: #!/bin/sh
1.3 ! millert 2: # $OpenBSD: skeyaudit.sh,v 1.2 1996/06/26 05:39:21 deraadt Exp $
1.1 deraadt 3: # This script will look thru the skeykeys file for
4: # people with sequence numbers less then LOWLIMIT=12
5: # and send them an e-mail reminder to use skeyinit soon
6: #
7:
8: AWK=/usr/bin/awk
9: GREP=/usr/bin/grep
10: ECHO=/bin/echo
11: KEYDB=/etc/skeykeys
12: LOWLIMIT=12
13: ADMIN=root
14: SUBJECT="Reminder: Run skeyinit"
15: HOST=`/bin/hostname`
16:
17:
18: if [ "$1" != "" ]
19: then
20: LOWLIMIT=$1
21: fi
22:
23:
24: # an skeykeys entry looks like
25: # jsw 0076 la13079 ba20a75528de9d3a
26: # the sequence number is the second entry
27: #
28:
29: for i in `$AWK '{print $1}' $KEYDB`
30: do
1.3 ! millert 31: SEQ=`$GREP "^$i[ ]" $KEYDB | $AWK '{if ($2 ~ /^MD[0-9]+/) {print $3} else {print $2}}'`
1.1 deraadt 32: if [ $SEQ -lt $LOWLIMIT ]
33: then
1.3 ! millert 34: KEY=`$GREP "^$i[ ]" $KEYDB | $AWK '{if ($2 ~ /^MD[0-9]+/) {print $4} else {print $3}}'`
1.1 deraadt 35: if [ $SEQ -lt 3 ]
36: then
37: SUBJECT="IMPORTANT action required"
38: fi
39: (
40: $ECHO "You are nearing the end of your current S/Key sequence for account $i"
41: $ECHO "on system $HOST."
42: $ECHO ""
43: $ECHO "Your S/key sequence number is now $SEQ. When it reaches zero you"
44: $ECHO "will no longer be able to use S/Key to login into the system. "
45: $ECHO " "
46: $ECHO "Type \"skeyinit -s\" to reinitialize your sequence number."
47: $ECHO ""
48: ) | /usr/bin/Mail -s "$SUBJECT" $i $ADMIN
49: fi
50: done