]>
git.ipfire.org Git - people/ms/dma.git/blob - dbounce-simple-safecat
3 # Copyright (c) 2009, 2010 Peter Pentchev
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 Usage: dbounce-simple-safecat [-a addr] [-d dir] [-i queueid] [-t type] -f msg
33 -a the recipient of the bounced message
34 -d the bounce directory, default $DEFBOUNCEDIR
35 -f the full path to the bounced message to process
36 -i the ID of the bounce message in the local MTA's queue
37 -t the MTA type, currently ignored
41 DEFBOUNCEDIR
='/var/spool/mail/dma-bounces'
42 BOUNCEDIR
="$DEFBOUNCEDIR"
44 while getopts 'a:d:f:i:t:' o
; do
67 if [ ! -r "$FILENAME" ]; then
68 echo "Nonexistent or unreadable bounce file $FILENAME" 1>&2
72 bname
=`basename "$FILENAME"`
73 dname
=`dirname "$FILENAME"`
74 if expr "$bname" : 'Q' > /dev
/null
; then
77 if [ ! -r "$qfile" ]; then
78 echo "Nonexistent or unreadable bounce queue file $qfile" 1>&2
85 F
=`cat "$FILENAME" ${qfile:+"$qfile"} | safecat "$BOUNCEDIR/tmp" "$BOUNCEDIR/new"`
86 OUTFILE
="$BOUNCEDIR/new/$F"
87 if [ ! -f "$OUTFILE" ]; then
88 echo "safecat indicated success, but '$OUTFILE' does not exist" 1>&2
91 echo "Successfully written the message to $OUTFILE"