/usr/bin/lr_rawmail2mail is in lire 2:2.1.1-2.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | #! /bin/sh -e
PROGRAM=lr_rawmail2mail
tag="all all ${LR_ID:-UNSET} $PROGRAM"
# when running directly from .qmail:
# exit 100 : hard error
# exit 111 : soft error
# see qmail-command
# dereference sysconfdir's prefix dependency
prefix="/usr"
etcdir="/etc/lire"
. $etcdir/profile_lean
echo >&2 "$tag info started with $*"
USAGE="Usage $PROGRAM [-i] [-o <outputformat>] anondb sendto+"
# get options (x)
output_flag=""
image_flag=""
subject=""
while getopts :o:ivh\? o; do
case $o in
o) output_flag="-o $OPTARG"
;;
i) image_flag="-i"
;;
h | "?")
echo >&2 "$tag notice $USAGE"
exit 0
;;
v)
echo >&2 "$tag notice $PROGRAM" '$Id: lr_rawmail2mail.in,v 1.25 2006/07/23 13:16:33 vanbaal Exp $,' "shipped with Lire 2.1.1"
exit 0
;;
*)
echo >&2 "$tag err $USAGE"
exit 1
;;
esac
done
# yes, the '|| true' is needed. solaris' /bin/sh feels it should bawl out when
# encountering an 'expr 1 - 1', while running -e
shift `expr $OPTIND - 1 || true`
if test $# -lt 2
then
echo >&2 "$tag err $USAGE"
exit 1
fi
if test -z "$TMPDIR"
then
echo >&2 "$tag err TMPDIR not set. did you source sysconfdir/defaults?"
exit 1
fi
if test ! -d "$TMPDIR"
then
echo >&2 "$tag notice dir $TMPDIR does not exist, creating it"
if mkdir $TMPDIR
then
:
else
echo >&2 "$tag err cannot create $TMPDIR, exiting"
exit 1
fi
fi
if /usr/bin/perl -MMIME::Tools -e 'exit 0' 2>/dev/null
then
:
else
cat >&2 <<EOF
$tag err can't parse email: the needed MIME::Entity perl module isn't available
$tag err Please install the MIME::Tools perl modules from a local CPAN mirror.
$tag err Consult the Lire User's Manual for more informations.
EOF
#' Fontification hack
exit 1
fi
DUMPSTEM="$1"; shift
# TO= "$@"
MAILFILE=$TMPDIR/$PROGRAM.$$.mail
cat > $MAILFILE
# this sets lr_getbody_FILE, lr_getbody_SUBJECT
# and lr_getbody_SUBMITTER
eval `lr_getbody -c text/xml $MAILFILE || true`
if test -z "lr_getbody_OK"
then
echo >&2 "$tag err lr_getbody failed. Keeping $MAILFILE for debugging"
exit 1
else
echo >&2 "$tag info lr_getbody gave FILE '$lr_getbody_FILE'"
echo >&2 "$tag info lr_getbody gave SUBJECT '$lr_getbody_SUBJECT'"
echo >&2 "$tag info lr_getbody gave SUBMITTER '$lr_getbody_SUBMITTER'"
fi
if test -n "$lr_getbody_FILE"
then
# We found an text/xml attachment
echo >&2 "$tag info file $MAILFILE is a message containing a XML report"
REPORTFILE=$TMPDIR/$PROGRAM.$$.xml
# Deanonymize the report
if lr_deanonymize $DUMPSTEM < $lr_getbody_FILE > $REPORTFILE
then
:
else
echo >&2 "$tag err lr_deanonymize failed. Keeping $lr_getbody_FILE for debugging"
exit 1
fi
echo >&2 "$tag info Formatting and sending report to $@"
subject="[LogReport] deanonymized report (was: $lr_getbody_SUBJECT)"
if lr_xml2mail -q -s "$subject" $image_flag $output_flag $REPORTFILE "$@"
then
:
else
echo >&2 "$tag err lr_xml2mail failed. Keeping $lr_getbody_FILE for debugging"
exit 1
fi
if test -n "$LR_KEEP"
then
echo >&2 "$tag notice keeping $lr_getbody_FILE on your request. remove manually."
echo >&2 "$tag notice keeping $REPORTFILE on your request. remove manually."
else
rm $lr_getbody_FILE $REPORTFILE
fi
fi
if test -n "$LR_KEEP"
then
echo >&2 "$tag notice keeping $MAILFILE on your request. remove manually."
else
rm $MAILFILE
fi
exit 0
POD=<<'EOPOD'
=pod
=head1 NAME
B<lr_rawmail2mail> - deanonymizes and formats a report from an email message
=head1 SYNOPSIS
B<lr_rawmail2mail> B<[I<options>]> I<dumpstem> I<addresses>...
B<lr_rawmail2mail> B<-h>
B<lr_rawmail2mail> B<-v>
=head1 OPTIONS
=over 4
=item B<-h>
Prints usage information and exits.
=item B<-i>
Generate charts for all reports that support it. Normally, charts will
be generated only if the variable I<LR_INCLUDEIMAGES> is set to 1.
=item B<-o> I<output format>
One of B<pdf>, B<html>, B<html_page>, B<xhtml>, B<xhtml_page>, B<txt>,
B<docbookx>, B<rtf> and B<xml>. Per default, simple txt output is
generated.
=item B<-v>
Prints Lire's version and exits.
=back
=head1 DESCRIPTION
B<lr_rawmail2mail> can be used to automatically process reply from an
Online Responder which contains a XML report. It will extract the
report (which should have a content type of text/xml)
and deanonymized it. It will then use the lr_xml2mail(1) command to
formats and send the report to the recipients specified on the command
line.
The I<dumpstem> argument is used by lr_deanonymize(1) to find the database
that was used in the anonymization process.
Environment variable TMPDIR, as set in sysconfdir/defaults, is used to
store tmpfiles; if LR_KEEP is set to a nonempty string, temporary files
are kept.
=head1 VERSION
$Id: lr_rawmail2mail.in,v 1.25 2006/07/23 13:16:33 vanbaal Exp $
=head1 COPYRIGHT
Copyright (C) 2000, 2001, 2002 Stichting LogReport Foundation LogReport@LogReport.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html.
=head1 AUTHOR
Joost van Baal <joostvb@logreport.org>
=cut
EOPOD
|