Hi,
After fiddling with procmail for about a day I wrote the attached
recipes. They do exactly what I want them to do, and everything works
just fine. However there is one problem: anytime procmail is started, a
zero length file is crated: /var/mail/$LOGNAME. The rest of the delivery
goes as planned. Even if I delete the file it is recreated on the next
start of procmail. I am not referring to /var/mail anywhere in my
recipes, there is no .procmailrc and /etc/procmailrc is attached in full
(except for the dummy DELETE ME recipe which is commented on my end).
Please help me solve this.
Thanks
Peter
=====================================================================
=====================================================================
#
# **** NOTE ****
#
# This recipe file requires configuration. It is intentionally
crippled so
# people read the not-so-fine print before using this. Once you
understand
# what these recipes can and can not do, delete or comment out the block
# marked DELETE ME at the end of this text, and mail away!
#
#
# Procmail smart user and extension handling recipes v0.3
#
#
# This procmailrc is intended for system-wide use as /etc/procmailrc.
# It servers two functions:
#
#
# * Prevent mail delivery for system accounts
#
# If an email is sent to a system user (e.g. daemon), most current
# distributions in their default configuration will hapily deliver the mail
# to /var/mail/daemon, where no one will ever find it. On a system
exposed to
# the internet this allows for a DoS attack, where the atacker can easily
# fill up the /var partition. In order to prevent this the existence of the
# user mailspool directory is verified, and if it does not exist the
message
# is forwarded to a designated administrator. The check is not performed
for
# the administrator, as it would result in a mail loop.
#
#
# * Facilitate delivery of mail based on mail extensions (plus addressing)
#
# The extension can be supplied either as the first argument to procmail by
# your favorite MTA or optionally can be extracted from the message TO
header.
# If a mailbox named after the extension is found in the user's mail
# directory, the message is delivered there. Otherwise it is delivered to a
# configurable mailbox. The mailbox name matching is case insensitive.
#
#
# MBOX DELIVERY IS ASSUMED. THIS IS NOT INTENDED FOR MAILDIR SPOOLS!
#
#
#
##### BEGIN DELETE ME ######
:0 :
$DEFAULT
###### END DELETE ME #######
#############
# Settings
#
#
# Tune the variables below to your taste and needs. For additional ifno
about
# procmail variables refer to the 'Environment' section in procmailrc(5)
#
# A shell must be explicitly provided for system accounts which may very
well
# try to use /bin/false
SHELL=/bin/sh
# The directory where all mailboxes are kept. If it does not exist all mail
# is forwarded to ADMIN_USER. Note: MAILDIR is not used here because
procmail
# needs to be able to chdir there, and the directory might not yet exist
MAIL_DIR=/home/$LOGNAME/Mail
# The address which will receive all mail addressed to users whose
$MAILDIR does
# not exist. DO NOT SET THIS TO ROOT!!!
# Alternatively if you have a sendmail compatible /etc/aliases and mail for
# root is forwarded to a real user you can uncomment the awk snippet below
ADMIN_USER=`awk -F '[ ,]' '/root:/ { print $2; exit }' /etc/aliases`
# The file name of the 'Inbox' mailbox. The default is $MAIL_DIR/mbox.
If you
# want to keep it this way you need to add the dir= parameter to every
# invocation of pam_mail.so in /etc/pam.d/ so that the MAIL variable
will be
# set correctly and the new mail notification will function
DEFAULT=mbox
# The mailbox where messages with non-matching extensions are delivered.
You
# can set this to /dev/null in order to discard such mail. By default
deliver
# to the 'Inbox'
UNKNOWN_EXT=$DEFAULT
# Should the To: header be inspected for possible extensions if no
extension was
# supplied to procmail as an argument? 'yes' enables, anything else disables
CHECK_HEADER_EXT=no
# Extension delimiter. Do not change unless you know what you are doing
SEP="+"
#################################################################
# Do not edit anything below unless you agree to keep the pieces
#
:0
{
### check if the maildir is missing
:0
*? test ! -d "$MAIL_DIR"
{
### if we are not the admin - forward the mail to him(her?)
:0
*? test "$LOGNAME" != "$ADMIN_USER"
! $ADMIN_USER
### if it is the admin - create the directory
:0 Ec
| mkdir -p "$MAIL_DIR"
}
### we know that the directory exists - we can chdir there
MAILDIR=$MAIL_DIR
### determine the extension if any
ARG=$1
EXT=`if test -n "$ARG" ; then echo "$ARG" ; elif test
"$CHECK_HEADER_EXT" = "yes" ; then formail -x 'To:' | sed
"s/^.*${SEP}\([^\(_at_)]*\).*$/\1/" ; fi`
### if an extension is provided - use it
:0
*? test -n "$EXT"
{
### see if a mailbox file with the same name as the extension
is present
EXT_BOX=`find -maxdepth 1 -type f -iname "$EXT" -printf '%f' -quit`
### if an extension mailbox exists - deliver there
:0 :
*? test -n "$EXT_BOX"
$EXT_BOX
### otherwise put mail in the UNKNOWN_EXT mailbox
:0 :
$UNKNOWN_EXT
}
### this is the default behavior, just put here for clarity
:0 :
$DEFAULT
}
################################
# MISCELANEOUS
#
# These recipes were written by Peter Rabbitson due to lack of anything
# better on the net. As a compensation for being forced to read them you
can
# use them with or without modifications for any good or evil deed. If you
# have a suggestion or a problem - drop me a line to rabbit(_at_)rabbit(_dot_)us
#
#
# It is assumed that you have the following programs in the default system
# path (all of them are usually present on all but embedded systems):
#
# * sh
# * test
# * find
# * sed
# * awk
# * formail
#
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail