1210254Sgabor#!/bin/sh -
2210254Sgabor#
3210254Sgabor# Copyright (c) 2010  The FreeBSD Project
4210254Sgabor# All rights reserved.
5210254Sgabor#
6210254Sgabor# Redistribution and use in source and binary forms, with or without
7210254Sgabor# modification, are permitted provided that the following conditions
8210254Sgabor# are met:
9210254Sgabor# 1. Redistributions of source code must retain the above copyright
10210254Sgabor#    notice, this list of conditions and the following disclaimer.
11210254Sgabor# 2. Redistributions in binary form must reproduce the above copyright
12210254Sgabor#    notice, this list of conditions and the following disclaimer in the
13210254Sgabor#    documentation and/or other materials provided with the distribution.
14210254Sgabor#
15210254Sgabor# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16210254Sgabor# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17210254Sgabor# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18210254Sgabor# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19210254Sgabor# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20210254Sgabor# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21210254Sgabor# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22210254Sgabor# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23210254Sgabor# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24210254Sgabor# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25210254Sgabor# SUCH DAMAGE.
26210254Sgabor#
27210254Sgabor# $FreeBSD$
28210254Sgabor#
29210254Sgabor
30210254Sgaborif [ -r /etc/defaults/periodic.conf ]
31210254Sgaborthen
32210254Sgabor    . /etc/defaults/periodic.conf
33210254Sgabor    source_periodic_confs
34210254Sgaborfi
35210254Sgabor
36210254Sgabor. /etc/periodic/security/security.functions
37210254Sgabor
38254974Sjlhsecurity_daily_compat_var security_status_chkportsum_enable
39254974Sjlh
40210254Sgaborrc=0
41210254Sgabor
42210254Sgaborecho ""
43210254Sgaborecho 'Checking for ports with mismatched checksums:'
44210254Sgabor
45254974Sjlhif check_yesno_period security_status_chkportsum_enable
46254974Sjlhthen
47211141Sgabor	set -f
48210254Sgabor	pkg_info -ga 2>/dev/null | \
49211141Sgabor	while IFS= read -r line; do
50211141Sgabor		set -- $line
51211141Sgabor		case $1 in
52210254Sgabor			Information)
53211141Sgabor			case $2 in
54211141Sgabor				for) name="${3%%:}" ;;
55211141Sgabor				*) name='??' ;;
56210254Sgabor			esac
57210254Sgabor			;;
58210254Sgabor			Mismatched|'') ;;
59211141Sgabor			*) [ -n "${name}" ] &&
60211141Sgabor				echo "${name}: ${line%% fails the original MD5 checksum}"
61210254Sgabor			;;
62210254Sgabor		esac
63210254Sgabor	done
64254974Sjlhfi
65210254Sgabor
66210254Sgaborexit $rc
67