summaryrefslogtreecommitdiff
path: root/usr/src/cmd/sendmail
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/sendmail')
-rw-r--r--usr/src/cmd/sendmail/lib/Makefile8
-rw-r--r--usr/src/cmd/sendmail/lib/sendmail-client80
-rw-r--r--usr/src/cmd/sendmail/lib/sendmail-client.xml145
-rw-r--r--usr/src/cmd/sendmail/lib/smtp-sendmail101
4 files changed, 232 insertions, 102 deletions
diff --git a/usr/src/cmd/sendmail/lib/Makefile b/usr/src/cmd/sendmail/lib/Makefile
index c1bf1e59d9..e685a9778e 100644
--- a/usr/src/cmd/sendmail/lib/Makefile
+++ b/usr/src/cmd/sendmail/lib/Makefile
@@ -19,14 +19,12 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
-MANIFEST= smtp-sendmail.xml
-SVCMETHOD= smtp-sendmail
+MANIFEST= smtp-sendmail.xml sendmail-client.xml
+SVCMETHOD= smtp-sendmail sendmail-client
include ../../Makefile.cmd
diff --git a/usr/src/cmd/sendmail/lib/sendmail-client b/usr/src/cmd/sendmail/lib/sendmail-client
new file mode 100644
index 0000000000..68f96fb033
--- /dev/null
+++ b/usr/src/cmd/sendmail/lib/sendmail-client
@@ -0,0 +1,80 @@
+#!/sbin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+
+. /lib/svc/share/smf_include.sh
+. /lib/svc/share/sendmail_include.sh
+
+CLIENT_PID_FILE="/var/spool/clientmqueue/sm-client.pid"
+SUBMIT_CF="/etc/mail/submit.cf"
+
+case "$1" in
+'refresh')
+ [ -f $CLIENT_PID_FILE ] && kill -1 `head -1 $CLIENT_PID_FILE`
+ ;;
+
+'start')
+ exist_or_exit $SENDMAIL
+ [ -f $DEFAULT_FILE ] && . $DEFAULT_FILE
+ #
+ # * CLIENTQUEUEINTERVAL should be set to some legal value;
+ # sanity checks are done below.
+ # * CLIENTOPTIONS are catch-alls; set with care.
+ #
+ check_queue_interval_syntax $CLIENTQUEUEINTERVAL
+ CLIENTQUEUEINTERVAL=$answer
+
+ submit_path=`svcprop -p config/path_to_submit_mc $SMF_FMRI 2>/dev/null`
+ if [ $? -eq 0 -a -n "$submit_path" ]; then
+ turn_m4_crank $SUBMIT_CF $submit_path
+ fi
+ exist_or_exit $SUBMIT_CF
+
+ $SENDMAIL -Ac -q$CLIENTQUEUEINTERVAL $CLIENTOPTIONS &
+ ;;
+
+'stop')
+ if [ -f $CLIENT_PID_FILE ]; then
+ check_and_kill $CLIENT_PID_FILE
+ rm -f $CLIENT_PID_FILE
+ fi
+ # 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
+
+ # Sendmail can take its time responding to SIGTERM, as it waits for
+ # things like child processes and SMTP connections to clean up. 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
diff --git a/usr/src/cmd/sendmail/lib/sendmail-client.xml b/usr/src/cmd/sendmail/lib/sendmail-client.xml
new file mode 100644
index 0000000000..b72b4503d5
--- /dev/null
+++ b/usr/src/cmd/sendmail/lib/sendmail-client.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+ CDDL HEADER START
+
+ The contents of this file are subject to the terms of the
+ Common Development and Distribution License (the "License").
+ You may not use this file except in compliance with the License.
+
+ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ or http://www.opensolaris.org/os/licensing.
+ See the License for the specific language governing permissions
+ and limitations under the License.
+
+ When distributing Covered Code, include this CDDL HEADER in each
+ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ If applicable, add the following below this CDDL HEADER, with the
+ fields enclosed by brackets "[]" replaced with your own identifying
+ information: Portions Copyright [yyyy] [name of copyright owner]
+
+ CDDL HEADER END
+
+ Copyright 2009 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.
+-->
+
+<service_bundle type='manifest' name='SUNWsndmr:sendmail'>
+
+<service
+ name='network/sendmail-client'
+ 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='default' enabled='true'>
+
+ <dependency
+ name='config-file'
+ grouping='require_all'
+ restart_on='refresh'
+ type='path'>
+ <service_fmri
+ value='file://localhost/etc/mail/submit.cf' />
+ </dependency>
+
+ <!--
+ 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='/lib/svc/method/sendmail-client start'
+ timeout_seconds='120' />
+
+ <exec_method
+ type='method'
+ name='stop'
+ exec='/lib/svc/method/sendmail-client stop %{restarter/contract}'
+ timeout_seconds='60' />
+
+ <exec_method
+ type='method'
+ name='refresh'
+ exec='/lib/svc/method/sendmail-client refresh'
+ timeout_seconds='60' />
+
+ <property_group name='general' type='framework'>
+ <propval name='action_authorization' type='astring'
+ value='solaris.smf.manage.sendmail' />
+ </property_group>
+
+ <property_group name='config' type='application'>
+ <propval name='value_authorization' type='astring'
+ value='solaris.smf.value.sendmail' />
+ </property_group>
+
+ <template>
+ <common_name>
+ <loctext xml:lang='C'>
+ sendmail SMTP client queue runner
+ </loctext>
+ </common_name>
+ <documentation>
+ <manpage title='sendmail' section='1M'
+ manpath='/usr/share/man' />
+ </documentation>
+ </template>
+
+ </instance>
+
+ <stability value='Unstable' />
+
+</service>
+
+</service_bundle>
diff --git a/usr/src/cmd/sendmail/lib/smtp-sendmail b/usr/src/cmd/sendmail/lib/smtp-sendmail
index a95468b5f5..d9aafec092 100644
--- a/usr/src/cmd/sendmail/lib/smtp-sendmail
+++ b/usr/src/cmd/sendmail/lib/smtp-sendmail
@@ -19,102 +19,21 @@
#
# CDDL HEADER END
#
-# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
. /lib/svc/share/smf_include.sh
+. /lib/svc/share/sendmail_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"
-CLIENT_PID_FILE="/var/spool/clientmqueue/sm-client.pid"
-DEFAULT_FILE="/etc/default/sendmail"
ALIASES_FILE="/etc/mail/aliases"
SENDMAIL_CF="/etc/mail/sendmail.cf"
-SUBMIT_CF="/etc/mail/submit.cf"
-SENDMAIL="/usr/lib/sendmail"
-PATH="/usr/bin:/usr/sbin:/usr/ccs/bin"
-export PATH
-
-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
-}
-
-exist_or_exit()
-{
- if [ ! -f $1 ]; then
- echo "$1 does not exist"
- exit $SMF_EXIT_ERR_CONFIG
- fi
-}
-
-turn_m4_crank()
-{
- # expected to be called with two arguments: .cf path & path to m4 file
- [ $# -lt 2 ] && return
- cf_path=$1
- m4_path=$2
- case "$m4_path" in
- /*) ;; # absolute path
- *) return;;
- esac
- if [ "$m4_path" = "_DONT_TOUCH_THIS" ]; then
- if [ -f "${cf_path}.old" ]; then
- mv "$cf_path" "${cf_path}.new"
- [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG
- mv "${cf_path}.old" "$cf_path"
- [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG
- fi
- #
- # If ${cf_path}.old does not exist, assume it was taken care
- # of on a previous run.
- #
- else
- exist_or_exit "$m4_path"
- cd `dirname "$m4_path"`
- base=`basename "$m4_path"`
- name=`basename "$m4_path" .mc`
- info=`svcprop -p config/include_info $SMF_FMRI 2>/dev/null`
- if [ "$info" = "true" ]; then
- m4flags=""
- else
- m4flags="-DSUN_HIDE_INTERNAL_DETAILS"
- fi
- m4 $m4flags /etc/mail/cf/m4/cf.m4 "$base" > "${name}.cf"
- [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG
- cmp -s "${name}.cf" "$cf_path" || (
- cp "${name}.cf" "${cf_path}.tmp" &&
- chown root:bin "${cf_path}.tmp" &&
- chmod 444 "${cf_path}.tmp" &&
- mv "${cf_path}.tmp" "$cf_path"
- )
- [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG
- fi
-}
case "$1" in
'refresh')
[ -f $SERVER_PID_FILE ] && kill -1 `head -1 $SERVER_PID_FILE`
- [ -f $CLIENT_PID_FILE ] && kill -1 `head -1 $CLIENT_PID_FILE`
;;
'start')
@@ -133,9 +52,9 @@ case "$1" in
# * 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;
+ # * QUEUEINTERVAL should be set to some legal value;
# sanity checks are done below.
- # * [CLIENT]OPTIONS are catch-alls; set with care.
+ # * OPTIONS are catch-alls; set with care.
#
if [ -n "$QUEUEOPTION" -a "$QUEUEOPTION" != "p" ]; then
QUEUEOPTION=""
@@ -144,8 +63,6 @@ case "$1" in
check_queue_interval_syntax $QUEUEINTERVAL
QUEUEINTERVAL=$answer
fi
- check_queue_interval_syntax $CLIENTQUEUEINTERVAL
- CLIENTQUEUEINTERVAL=$answer
local=`/usr/bin/svcprop -p config/local_only $SMF_FMRI 2>/dev/null`
if [ $? -eq 0 -a "$local" = "true" ]; then
@@ -157,14 +74,8 @@ case "$1" in
turn_m4_crank $SENDMAIL_CF $sendmail_path
fi
exist_or_exit $SENDMAIL_CF
- submit_path=`svcprop -p config/path_to_submit_mc $SMF_FMRI 2>/dev/null`
- if [ $? -eq 0 -a -n "$submit_path" ]; then
- turn_m4_crank $SUBMIT_CF $submit_path
- fi
- exist_or_exit $SUBMIT_CF
$SENDMAIL $MODE -q$QUEUEOPTION$QUEUEINTERVAL $OPTIONS &
- $SENDMAIL -Ac -q$CLIENTQUEUEINTERVAL $CLIENTOPTIONS &
#
# ETRN_HOSTS should be of the form
@@ -196,10 +107,6 @@ case "$1" in
'stop')
[ -f $SERVER_PID_FILE ] && check_and_kill $SERVER_PID_FILE
- if [ -f $CLIENT_PID_FILE ]; then
- check_and_kill $CLIENT_PID_FILE
- rm -f $CLIENT_PID_FILE
- fi
# Need to kill the entire service contract to kill all sendmail related
# processes
smf_kill_contract $2 TERM 1 30