#!/bin/sh

[ "$1" = "-h" ] && cat <<tac

This example tests the following features of the sanitizer:

  - Support for the F-Prot command-line scanner

tac

rm -f test.log test.out
touch test.log test.out

if [ ! -e /usr/local/bin/f-prot ]; then
    # F-Prot not installed, fake a successful run.
    echo -n "SKIPPED: F-Prot not installed.  " >&2
    ./rot13 <$TEST_RESULTS/sanitizer.fprotd.ok.rot13 >test.out
    exit 0
fi

if [ "$(/usr/local/bin/f-prot -verno |grep Program)" != "Program version: 4.6.3" ]; then
    # Incorrect version of F-Prot installed, fake.
    echo -n "SKIPPED: Test assumes F-Prot 4.6.3.  " >&2
    ./rot13 <$TEST_RESULTS/sanitizer.fprotd.ok.rot13 >test.out
    exit 0
fi

# Obfuscated so it does not trigger the scanner...
export EIC='X5O!P%@AP[4\PZX54(P^'
export ICA=')7CC)7}$EICAR-STANDARD'
export CAR='-ANTIVIRUS-TEST-FILE!$H+H*'

for ARG in -nofprot -yesfprot; do
  $ANOMY/bin/sanitizer.pl $ARG $SAN_CONF \
    'header_rev = 0' \
    'feat_testing = 1' \
    'feat_log_stderr = 1' \
    'feat_log_inline = 2' \
    'feat_log_trace = 1' <<EOF 2>>test.log |perl -ne 'next if (/(^\s\s+$|Time:|Searching:|DEF created|version:|scanning report)/); s/\/tmp\/\S+/FILE/; print' >>test.out
From xxx@example.com  Thu Aug  3 07:32:10 2000
Return-Path: <xxx@example.com>
Received: from example.com (root@example.com [149.144.245.5])
	by example.com (8.9.3/8.9.3) with ESMTP id HAA01305
	for <bre@example.com>; Thu, 3 Aug 2000 07:32:03 GMT
From: xxx@example.com
Date: Thu, 3 Aug 2000 06:39:59 GMT
Message-Id: <200008030639.GAA23780@example.com>
MIME-Version: 1.0
Sender: xxx@example.com
Subject: Elephant man! $ARG
To: fake@example.com
Content-Type: application/octet-stream
Content-Transfer-Encoding: 8bit

$EIC$ICA$CAR
EOF
done

