1193323Sed#!/bin/sh -
2193323Sed#
3193323Sed# Copyright (c) 2001  The FreeBSD Project
4193323Sed# All rights reserved.
5193323Sed#
6193323Sed# Redistribution and use in source and binary forms, with or without
7193323Sed# modification, are permitted provided that the following conditions
8193323Sed# are met:
9193323Sed# 1. Redistributions of source code must retain the above copyright
10193323Sed#    notice, this list of conditions and the following disclaimer.
11193323Sed# 2. Redistributions in binary form must reproduce the above copyright
12193323Sed#    notice, this list of conditions and the following disclaimer in the
13193323Sed#    documentation and/or other materials provided with the distribution.
14193323Sed#
15193323Sed# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16193323Sed# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17193323Sed# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18249423Sdim# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19198090Srdivacky# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20249423Sdim# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21249423Sdim# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22193323Sed# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23193323Sed# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24193323Sed# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25193323Sed# SUCH DAMAGE.
26193323Sed#
27193323Sed# $FreeBSD$
28193323Sed#
29193323Sed
30193323Sed# Show login failures
31193323Sed#
32193323Sed
33207618Srdivacky# If there is a global system configuration file, suck it in.
34207618Srdivacky#
35193323Sedif [ -r /etc/defaults/periodic.conf ]
36193323Sedthen
37193323Sed    . /etc/defaults/periodic.conf
38193323Sed    source_periodic_confs
39193323Sedfi
40193323Sed
41193323Sedsecurity_daily_compat_var security_status_logdir
42193323Sedsecurity_daily_compat_var security_status_loginfail_enable
43193323Sed
44193323SedLOG="${security_status_logdir}"
45207618Srdivacky
46207618Srdivackyyesterday=`date -v-1d "+%b %e "`
47193323Sed
48193323Sedcatmsgs() {
49193323Sed	find ${LOG} -name 'auth.log.*' -mtime -2 |
50193323Sed	    sort -t. -r -n -k 2,2 |
51193323Sed	    while read f
52207618Srdivacky	    do
53193323Sed		case $f in
54193323Sed		    *.gz)	zcat -f $f;;
55207618Srdivacky		    *.bz2)	bzcat -f $f;;
56193323Sed		esac
57193323Sed	    done
58193323Sed	[ -f ${LOG}/auth.log ] && cat $LOG/auth.log
59193323Sed}
60193323Sed
61193323Sedrc=0
62193323Sed
63193323Sedif check_yesno_period security_status_loginfail_enable
64207618Srdivackythen
65207618Srdivacky	echo ""
66193323Sed	echo "${host} login failures:"
67193323Sed	n=$(catmsgs | egrep -ia "^$yesterday.*: .*(fail|invalid|bad|illegal)" |
68193323Sed	    tee /dev/stderr | wc -l)
69207618Srdivacky	[ $n -gt 0 ] && rc=1 || rc=0
70207618Srdivackyfi
71207618Srdivacky
72207618Srdivackyexit $rc
73193323Sed