You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

  1. #!/bin/sh
  2. FILTER=/usr/bin/bogofilter
  3. FILTER_DIR=/mnt/sda1/var/spool/bogofilter
  4. # WARNING! The -i is crucial, else you may see
  5. # messages truncated at the first period that is alone on a line
  6. # (which can happen with several kinds of messages, particularly
  7. # quoted-printable)
  8. # -G is ignored before Postfix 2.3 and tells it that the message
  9. # does not originate on the local system (Gateway submission),
  10. # so Postfix avoids some of the local expansions that can leave
  11. # misleading traces in headers, such as local address
  12. # canonicalizations.
  13. POSTFIX="/usr/sbin/sendmail -G -i"
  14. export BOGOFILTER_DIR=/etc/bogofilter
  15. # Exit codes from <sysexits.h>
  16. EX_TEMPFAIL=75
  17. EX_UNAVAILABLE=69
  18. cd $FILTER_DIR || \
  19. { echo $FILTER_DIR does not exist; exit $EX_TEMPFAIL; }
  20. # Clean up when done or when aborting.
  21. trap "rm -f msg.$$ ; exit $EX_TEMPFAIL" 0 1 2 3 15
  22. # bogofilter -e returns: 0 for OK, nonzero for error
  23. rm -f msg.$$ || exit $EX_TEMPFAIL
  24. $FILTER -p -e > msg.$$ || exit $EX_TEMPFAIL
  25. exec <msg.$$ || exit $EX_TEMPFAIL
  26. rm -f msg.$$ # safe, we hold the file descriptor
  27. exec $POSTFIX "$@"
  28. exit $EX_TEMPFAIL