SPARC Solaris 10?

randyf at sibernet.com randyf at sibernet.com
Sun May 7 17:48:47 IST 2006



On Sun, 7 May 2006, randyf at sibernet.com wrote:

>> Also long as I'm typing I should also say you'll want to edit
>> 
>> /var/svc/manifest/network/smtp-sendmail.xml
>> and
>> /lib/svc/method/smtp-sendmail
>> 
>> If you want to to get MailScanner running from the sendmail startup
>> scripts.
>
>  NO!  Dont edit the original Solaris manifest _or_ method!  This will cause 
> you great pain should you ever upgrade or patch the system.
>
>  If you want to change the manifest or method, copy them somewhere (say to 
> /opt/MailScanner, or better yet, create an /etc/MailScanner and put it 
> there), edit these files, and import the the new manifest to use the new 
> methods.
>

   For those that may actually want to try MailScanner on S10 (and use the 
Sun versions of the tools), I have attached a manifest and method that can 
be used with MailScanner (maybe Julian will be interested in putting them 
in the contrib space).

   The scripts and instructions expect that the manifest and method will 
reside in the directory /etc/MailScanner/smf.  The method assumes 
MailScanner to reside in /opt/MailScanner.  You will need to update the 
manifest (the .xml file) if you put the method elsewhere, and tne method 
(the non-.xml file) if MailScanner is elsewhere.

   Note, that putting all the MailScanner config files in /etc allows for a 
single install of MailScanner should MailScanner be used in multiple 
Solaris zones.

   To change the manifest for Sendmail to the new manifest, simply do:

     # svcadm disable network/smtp
     # svccfg -s network/smtp
     svc:/network/smtp> import /etc/MailScanner/smf/ms-smtp-sendmail.xml
     svc:/network/smtp> quit
     # svcadm enable network/smtp

   To go back to the original Sun manifest, just change the "import" line 
to:

     svc:/network/smtp> import /var/svc/manifest/network/smtp-sendmail.xml


rf
-------------- next part --------------
#!/sbin/sh
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# Modeled from the Sun distributed smtp-sendmail method.
#

. /lib/svc/share/smf_include.sh

ERRMSG1='WARNING: /var/mail is NFS-mounted without setting actimeo=0,'
ERRMSG2='this can cause mailbox locking and access problems.'
SERVER_PID_FILE="/var/run/sendmail.pid"
SERVER_PID_FILE2="/var/run/sendmail2.pid"
CLIENT_PID_FILE="/var/spool/clientmqueue/sm-client.pid"
DEFAULT_FILE="/etc/default/sendmail"
ALIASES_FILE="/etc/mail/aliases"

check_queue_interval_syntax()
{
	default="15m"
	if [ $# -lt 1 ]; then
		answer=$default
		return
	fi
	if echo $1 | egrep '^([0-9]*[1-9][0-9]*[smhdw])+$' >/dev/null 2>&1; then
		answer=$1
	else
		answer=$default
	fi
}

check_and_kill()
{
	PID=`head -1 $1`
	kill -0 $PID > /dev/null 2>&1
	[ $? -eq 0 ] && kill $PID
}

case "$1" in 
'refresh')
        [ -f $SERVER_PID_FILE ] && kill -1 `head -1 $SERVER_PID_FILE`
        [ -f $SERVER_PID_FILE2 ] && kill -1 `head -1 $SERVER_PID_FILE2`
        [ -f $CLIENT_PID_FILE ] && kill -1 `head -1 $CLIENT_PID_FILE`
	pkill -HUP MailScanner
        ;;

'start')
	if [ -f /usr/lib/sendmail -a -f /etc/mail/sendmail.cf ]; then
		if [ ! -d /var/spool/mqueue ]; then
			/usr/bin/mkdir -m 0750 /var/spool/mqueue
			/usr/bin/chown root:bin /var/spool/mqueue
		fi
		if [ ! -d /var/spool/mqueue.in ]; then
			/usr/bin/mkdir -m 0750 /var/spool/mqueue.in
			/usr/bin/chown root:bin /var/spool/mqueue.in
		fi
		if [ ! -f $ALIASES_FILE.db ] && [ ! -f $ALIASES_FILE.dir ] \
		    && [ ! -f $ALIASES_FILE.pag ]; then
			/usr/sbin/newaliases
		fi
		MODE="-bd"
		[ -f $DEFAULT_FILE ] && . $DEFAULT_FILE
		#
		# * MODE should be "-bd" or null (MODE= or MODE="") or
		#   left alone.  Anything else and you're on your own.
		# * QUEUEOPTION should be "p" or null (as above).
		# * [CLIENT]QUEUEINTERVAL should be set to some legal value;
		#   sanity checks are done below.
		# * [CLIENT]OPTIONS are catch-alls; set with care.
		#
		if [ -n "$QUEUEOPTION" -a "$QUEUEOPTION" != "p" ]; then
			QUEUEOPTION=""
		fi
		if [ -z "$QUEUEOPTION" -o -n "$QUEUEINTERVAL" ]; then
			check_queue_interval_syntax $QUEUEINTERVAL
			QUEUEINTERVAL=$answer
		fi
		check_queue_interval_syntax $CLIENTQUEUEINTERVAL
		CLIENTQUEUEINTERVAL=$answer
		/usr/lib/sendmail $MODE -ODeliveryMode=queueonly -OQueueDirectory=/var/spool/mqueue.in -O PidFile=$SERVER_PID_FILE2&
		/usr/lib/sendmail -q$QUEUEOPTION$QUEUEINTERVAL $OPTIONS &
		/usr/lib/sendmail -Ac -q$CLIENTQUEUEINTERVAL $CLIENTOPTIONS &
		#
		# ETRN_HOSTS should be of the form
		# "s1:c1.1,c1.2        s2:c2.1 s3:c3.1,c3.2,c3.3"
		# i.e., white-space separated groups of server:client where
		# client can be one or more comma-separated names; N.B. that
		# the :client part is optional; see etrn(1M) for details.
		# server is the name of the server to prod; a mail queue run
		# is requested for each client name.  This is comparable to
		# running "/usr/lib/sendmail -qRclient" on the host server.
		#
		# See RFC 1985 for more information.
		#
		for i in $ETRN_HOSTS; do
			SERVER=`echo $i | /usr/bin/sed -e 's/:.*$//'`
			CLIENTS=`echo $i | /usr/bin/sed -n -e 's/,/ /g' \
			    -e '/:/s/^.*://p'`
			/usr/sbin/etrn -b $SERVER $CLIENTS >/dev/null 2>&1 &
		done
		#
		# Start MailScanner
		#
		/opt/MailScanner/bin/check_mailscanner
	fi	

	if /usr/bin/nawk 'BEGIN{s = 1}
	    $2 == "/var/mail" && $3 == "nfs" && $4 !~ /actimeo=0/ &&
	    $4 !~ /noac/{s = 0} END{exit s}' /etc/mnttab; then

		/usr/bin/logger -p mail.crit "$ERRMSG1"
		/usr/bin/logger -p mail.crit "$ERRMSG2"
	fi
	;;

'stop')
	[ -f $SERVER_PID_FILE ] && check_and_kill $SERVER_PID_FILE
	[ -f $SERVER_PID_FILE2 ] && check_and_kill $SERVER_PID_FILE2
	if [ -f $CLIENT_PID_FILE ]; then
		check_and_kill $CLIENT_PID_FILE
		rm -f $CLIENT_PID_FILE
	fi
	/usr/bin/pkill -15 -x -u 0 MailScanner
	# Need to kill the entire service contract to kill all sendmail related
	# processes
	smf_kill_contract $2 TERM 1 30
	ret=$?
	[ $ret -eq 1 ] && exit 1

	# Since sendmail spawns user processes out of .forward files, it is
	# possible that some of these are not responding to TERM.  If the
	# contract did not empty after TERM, move on to KILL.
	if [ $ret -eq 2 ] ; then
		smf_kill_contract $2 KILL 1
	fi
	;;

*)
	echo "Usage: $0 { start | stop | refresh }"
	exit 1
	;;
esac
exit 0
-------------- next part --------------
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
	Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
	Use is subject to license terms.

	NOTE:  This service manifest is not editable; its contents will
	be overwritten by package or patch operations, including
	operating system upgrade.  Make customizations in a different
	file.

	This file is modeled on the Sun distributed manifest, and should
	not in any way overwrite the original manifest.
-->

<service_bundle type='manifest' name='SUNWsndmr:sendmail'>

<service
	name='network/smtp'
	type='service'
	version='1'>

	<single_instance />

	<dependency
	    name='fs-local'
	    grouping='require_all'
	    restart_on='none'
	    type='service'>
		<service_fmri value='svc:/system/filesystem/local' />
	</dependency>

	<dependency
	    name='network-service'
	    grouping='require_all'
	    restart_on='none'
	    type='service'>
		<service_fmri value='svc:/network/service' />
	</dependency>

	<dependency
	    name='name-services'
	    grouping='require_all'
	    restart_on='refresh'
	    type='service'>
		<service_fmri value='svc:/milestone/name-services' />
	</dependency>

	<dependency
	    name='identity'
	    grouping='optional_all'
	    restart_on='refresh'
	    type='service'>
		<service_fmri value='svc:/system/identity:domain' />
	</dependency>

	<dependency
	    name='system-log'
	    grouping='optional_all'
	    restart_on='none'
	    type='service'>
		<service_fmri value='svc:/system/system-log' />
	</dependency>

	<instance name='sendmail' enabled='false'>

		<dependency
		    name='config-file'
		    grouping='require_all'
		    restart_on='refresh'
		    type='path'>
			<service_fmri
			    value='file://localhost/etc/mail/sendmail.cf' />
		</dependency>

		<dependency
		    name='nsswitch'
		    grouping='require_all'
		    restart_on='refresh'
		    type='path'>
			<service_fmri
			    value='file://localhost/etc/nsswitch.conf' />
		</dependency>

		<!--
		If autofs is enabled, wait for it to get users' home
		directories.
		-->
		<dependency
		    name='autofs'
		    grouping='optional_all'
		    restart_on='none'
		    type='service'>
			<service_fmri value='svc:/system/filesystem/autofs' />
		</dependency>

		<dependent
			name='smtp-sendmail_multi-user'
			grouping='optional_all'
			restart_on='none'>
				<service_fmri
				    value='svc:/milestone/multi-user' />
		</dependent>

		<!--
		Sendmail is hard-coded to sleep for 60 seconds if it cannot
		determine the FQHN, so the timeout for start must be longer
		than that.  For details, see
		http://www.sendmail.org/vendor/sun/differences.html#3.2
		-->

		<exec_method
			type='method'
			name='start'
			exec='/etc/MailScanner/smf/ms-smtp-sendmail start'
			timeout_seconds='120' />

		<exec_method
			type='method'
			name='stop'
			exec='/etc/MailScanner/smf/ms-smtp-sendmail stop %{restarter/contract}'
			timeout_seconds='60' />

		<exec_method
			type='method'
			name='refresh'
			exec='/etc/MailScanner/smf/ms-smtp-sendmail refresh'
			timeout_seconds='60' />

		<property_group name='startd' type='framework'>
			<propval name='ignore_error' type='astring'
			    value='core,signal' />
		</property_group>

		<property_group name='general' type='framework'>
			<propval name='action_authorization' type='astring'
				value='solaris.smf.manage.sendmail' />
		</property_group>

		<template>
			<common_name>
				<loctext xml:lang='C'>
				sendmail SMTP mail transfer agent
				</loctext>
			</common_name>
			<documentation>
				<manpage title='sendmail' section='1M'
				    manpath='/usr/share/man' />
			</documentation>
		</template>

	</instance>

	<stability value='Unstable' />

</service>

</service_bundle>


More information about the MailScanner mailing list