[Mimedefang] Adding mimedefang to sendmail's startup script

John Nemeth jnemeth at victoria.tc.ca
Fri Aug 3 21:03:11 EDT 2007


On Dec 21, 12:19pm, "Lisa Casey" wrote:

     First the disclaimer:  I'm a NetBSD developer who amongst other
things dabbles in Pkgsrc (including being the "official" maintainer of
the Sendmail package).  Pkgsrc was derived from FreeBSD's Ports system
and is NetBSD's packaging system.  FreeBSD's rcNG system was derived
from NetBSD.  My comments are based on this experience.

} I'm going to leave my earlier email intact at the bottom of this one because
} I think it's related to this.
} 
} Since installing mimedefang on this FreeBSD box, when I reboot it there's
} something screwy going on when sendmail starts up. It's got something to do
} with startup scripts and either something I've failed to do or something
} I've done incorrectly. Before installing mimedefang, sendmail started fine
} on bootup. Now when I reboot the box I get this in /var/log/maillog:
} 
} Jul 31 17:19:20 mail sm-mta[399]: NOQUEUE: SYSERR(root): opendaemonsocket:
} daemon IPv4: cannot bind: Address already in use
} Jul 31 17:19:20 mail sm-mta[399]: daemon IPv4: problem creating SMTP socket
} Jul 31 17:19:25 mail sm-mta[399]: NOQUEUE: SYSERR(root): opendaemonsocket:
} daemon IPv4: cannot bind: Address already in use
} 
} It looks like perhaps sendmail is being started twice???

     That is certainly what it looks like.

} and these just repeat over and over. The only way to fix it is to log into
} the box and manually stop sendmail, manually stop mimedefang, then manually
} start mimedefang and manually start sendmail. Naturally, this isn't very
} acceptable. If you folks could help me solve this issue I think I'ld have
} sendmail and mimedefang working together nicely.

     Without knowing what you've done, it is impossible to tell you how
to fix it.

} > I need to add mimedefang to sendmails startup script so that mimedefang
} > will start before sendmail starts and stop after sendmail stops. On my
} > Redhat box I edited  /etc/rc.d/sendmail and put /etc/init.d/mimedefang
} > start just before the script starts sendmail and put
} > /etc/init.d/mimedefang stop just after the script stops sendmail. Thus if
} >
} > [snip]
} >
} > I'm a bit confused on the FreeBSD box though. There is a
} > /etc/rc.d/sendmail file but it is dissimiliar to the /etc/rc.d/sendmail
} > file on the Redhat box and it's not apparent to me where this script
} > starts and stops the sendmail daemon. There's also a /etc/rc.sendmail

     Much of the work is done in /etc/rc.subr.  The rc.d scripts just
setup a few things.

} > script but I think this script isn't being used because in it it says:

     Looking at http://cvsweb.netbsd.org/ , I found /etc/rc.sendmail in
the "Attic".  That means that it has been deleted.  I don't know why it
is still on your system (NetBSD's upgrade process automatically deletes
obsolete files like this).

} > /etc/rc.conf the only lines relating to sendmail are:
} >
} > sendmail_enable="YES"
} > sendmail_pidfile="/var/run/sendmail.pid"
} > sendmail_flags="-L sm-mta -bd -q30m"
} >
} > Which file do I need to modify in FreeBSD so that mimedefang will start
} > just before sendmail starts and stop just after sendmail stops?
} > /etc/rc.d/sendmail or /etc/rc.sendmail? And if it is /etc/rc.d/sendmail
} > could someone tell me just where in that file I should put the mimedefang
} > stuff because, as I said, it is not apparent to me just where in that file
} > sendmail is started and stopped.

     You really shouldn't modify /etc/rc.d/sendmail as it is maintained
by the system and any changes would be wiped out when you upgrade the
system.  The proper way to do things would be to create /etc/rc.d files
for MIMEDefang.  I actually find it rather incredible that the Ports
version of MIMEDefang doesn't include these.  It does install the
sample mimedefang.sh script as /usr/local/etc/rc.d/mimedefang.sh-dist.
But, this is rather inadequate.  Anyways, here are the lines that I
have in /etc/rc.conf:

mimedefang=YES
mimedefang_fdlimit=1024
mimedefang_multiplexor_flags="-s /var/spool/MIMEDefang/mimedefang-multiplexor.sock -l -Z -m 10 -x 10 -b 600"
mimedefang_multiplexor=YES
mimedefang_multiplexor_fdlimit=1024

You may want to adjust these for your site.  And, here are the
/etc/rc.d scripts:

----  /etc/rc.d/mimedefang-multiplexor  ----

#!/bin/sh
#
# $NetBSD: mimedefang-multiplexor.sh,v 1.1 2004/03/07 11:18:33 markd Exp $
#
# mimedefang-multiplexor handles communications between sendmail and
# the real processor
#
## only for NetBSD
# PROVIDE: mimedefang-multiplexor
# REQUIRE: LOGIN 
# BEFORE: mail
# KEYWORD: shutdown
##

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/pkg/bin
export PATH

if [ -f /etc/rc.subr ]
then
	. /etc/rc.subr
fi


name="mimedefang_multiplexor"
rcvar="$name"
mimedefang_multiplexor_user=${mimedefang_multiplexor_user-"defang"}

defangdir="/var/spool/MIMEDefang"
command="/usr/pkg/bin/mimedefang-multiplexor"
pidfile="${defangdir}/${name}.pid"
command_args="-p ${pidfile}"

# default values, may be overridden on NetBSD by setting them in /etc/rc.conf
mimedefang_multiplexor_flags=${mimedefang_multiplexor_flags-\
	    "-s ${defangdir}/mimedefang-multiplexor.sock"}
mimedefang_multiplexor=${mimedefang_multiplexor:-NO}
mimedefang_multiplexor_fdlimit=${mimedefang_multiplexor_fdlimit-"128"}

sig_stop="TERM"
sig_reload="INT"
extra_commands="reload"

# A default limit of 64 (at least on NetBSD) may be too low for many
# people (eg with addional RBL rules)
SOFT_FDLIMIT=`ulimit -S -n`
HARD_FDLIMIT=`ulimit -H -n`

if [ ${mimedefang_multiplexor_fdlimit} -gt ${SOFT_FDLIMIT} ]; then
  if [ ${mimedefang_multiplexor_fdlimit} -le ${HARD_FDLIMIT} ]; then 
    ulimit -S -n ${mimedefang_multiplexor_fdlimit}
  else
    ulimit -S -n ${HARD_FDLIMIT}
  fi
fi

load_rc_config $name
run_rc_command "$1"

----  /etc/rc.d/mimedefang  ----

#!/bin/sh
#
# $NetBSD: mimedefang.sh,v 1.1 2004/03/07 11:18:33 markd Exp $
#
# mimedefang does "in-stream" spam and virus checking using 
# sendmail's MailFilter interfaces.
#
## only for NetBSD
# PROVIDE: mimedefang
# REQUIRE: LOGIN mimedefang-multiplexor
# BEFORE: mail
# KEYWORD: shutdown
##

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/pkg/bin
export PATH

if [ -f /etc/rc.subr ]
then
	. /etc/rc.subr
fi

defangdir="/var/spool/MIMEDefang"

name="mimedefang"
rcvar=$name
command="/usr/pkg/bin/mimedefang"
pidfile="${defangdir}/${name}.pid"
mimedefang_user=${mimedefang_user-"defang"}
command_args="-P ${pidfile}"

# default values, may be overridden on NetBSD by setting them in /etc/rc.conf
mimedefang_flags=${mimedefang_flags-"-p ${defangdir}/mimedefang.sock \
			-m ${defangdir}/mimedefang-multiplexor.sock"}

mimedefang=${mimedefang:-NO}
mimedefang_fdlimit=${mimedefang_fdlimit-"128"}

# A default limit of 64 (at least on NetBSD) may be too low for many
# people (eg with addional RBL rules)
SOFT_FDLIMIT=`ulimit -S -n`
HARD_FDLIMIT=`ulimit -H -n`

if [ ${mimedefang_fdlimit} -gt ${SOFT_FDLIMIT} ]; then
  if [ ${mimedefang_fdlimit} -le ${HARD_FDLIMIT} ]; then 
    ulimit -S -n ${mimedefang_fdlimit}
  else
    ulimit -S -n ${HARD_FDLIMIT}
  fi
fi

load_rc_config $name
run_rc_command "$1"

----

}-- End of excerpt from "Lisa Casey"



More information about the MIMEDefang mailing list