SUSE Support

Here When You Need Us

SendMail: Config Option with a Space Causes SendMail to Fail on Startup

This document (7001059) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 10 Service Pack 2

Situation

SendMail script containing spaces in the conventions causes the script to fail on startup or boot.

EXAMPLE:
O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA

This failure was reportedly introduced after the update to SP2 for SuSE Linux Enterprise Server 10.

Resolution

Use the following changed startup syntax.  Note that the syntax specifically addresses the issue stated above in the example.
Similar syntax may be used for related issues.  Administrators should always make a backup of their original scripts prior to testing out solutions of this nature.

#! /bin/sh
# Copyright (c) 1996-2002 SuSE Gmbh Nuernberg, Germany.
# Copyright (c) 2006-2008 SuSE LINUX Products GmbH, Germany.
#
# Author: Florian La Roche, 1996, 1997
#         Werner Fink, 1996, 1999-2007
# Please send feedback to http://www.suse.de/feedback/
#
### BEGIN INIT INFO
# Provides:          sendmail smtp
# Required-Start:    $named $network $remote_fs $syslog $time
# Required-Stop:
# Should-Start:      amavis cyrus ldap nscd ypbind
# Should-Stop:
# Default-Start:     3 5
# Default-Stop:
# Short-Description: Start the Sendmail MTA
# Description:       Start the Sendmail MTA
### END INIT INFO

test -s /etc/sysconfig/mail && \
      . /etc/sysconfig/mail

test -s /etc/sysconfig/sendmail && \
      . /etc/sysconfig/sendmail

if test -z "$SENDMAIL_ARGS" ; then
    SENDMAIL_ARGS="-L sendmail -Am -bd -q30m -om"
fi
if test -z "$SENDMAIL_CLIENT_ARGS" ; then
    SENDMAIL_CLIENT_ARGS="-L sendmail-client -Ac -qp30m"
fi

PortOpts=""
for cfg in /etc/sendmail.cf /etc/mail/sendmail.cf
do
    test -s $cfg || continue
    PortOpts=$(sed -rn '/^O[[:blank:]]+DaemonPortOptions=.*Name=MTA.*$/I {
s/[[:blank:]]+//g
s/^O[^=]+=(.*)/\1/p
}' $cfg)
    break
done
unset cfg

if test "$SMTPD_LISTEN_REMOTE" != "yes" ; then
    PortOpts="${PortOpts:+${PortOpts},}Addr=127.0.0.1"
    SENDMAIL_ARGS="-O DaemonPortOptions=${PortOpts} $SENDMAIL_ARGS"
fi

msppid=/var/spool/clientmqueue/sm-client.pid
srvpid=/var/run/sendmail.pid

#
# This function polls ten seconds on port 25 of localhost
#
poll25 ()
{
    local timeout=1000
    local port=25
    local opt

    for opt in ${PortOpts//,/ } ; do
case "${opt%=*}" in
[Pp]ort) port=${opt#*=}
esac
    done

    while ! fuser -sn tcp $port > /dev/null 2>&1 ; do
test $timeout -eq 0 && return 1
usleep 10000
: $((timeout--))
    done
    return 0
}

. /etc/rc.status
rc_reset
case "$1" in
    start)
echo -n "Initializing SMTP port (sendmail)"
startproc -p $srvpid -i $msppid /usr/sbin/sendmail $SENDMAIL_ARGS
rc_status && \
poll25
rc_status && \
startproc -p $msppid -i $srvpid /usr/sbin/sendmail $SENDMAIL_CLIENT_ARGS
rc_status -v
;;
    stop)
echo -n "Shutting down SMTP port"
killproc  -p $msppid -i $srvpid -TERM /usr/sbin/sendmail
rc_status
killproc  -p $srvpid -i $msppid -TERM /usr/sbin/sendmail
rc_status -v
;;
    try-restart)
$0 stop && $0 start
rc_status
;;
    restart)
$0 stop
$0 start
rc_status
;;
    reload|force-reload)
echo -n "Reload service sendmail"
killproc  -p $msppid -i $srvpid -TERM /usr/sbin/sendmail
rc_status
startproc -p $msppid -i $srvpid /usr/sbin/sendmail $SENDMAIL_CLIENT_ARGS
rc_status
killproc  -p $srvpid -i $msppid -HUP  /usr/sbin/sendmail
rc_status -v
;;
    status)
echo -n "Checking for service sendmail: "
checkproc -p $srvpid -i $msppid /usr/sbin/sendmail
rc_status
checkproc -p $msppid -i $srvpid /usr/sbin/sendmail
rc_status -v
;;
    probe)
todo=""
test /etc/sendmail.cf    -nt $srvpid && todo=reload
test /etc/mail/submit.cf -nt $msppid && todo=reload
checkproc -p $srvpid -i $msppid /usr/sbin/sendmail || todo=restart
checkproc -p $msppid -i $srvpid /usr/sbin/sendmail || todo=restart
test -z "$todo" || echo "$todo"
;;
    *)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
esac
rc_exit

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7001059
  • Creation Date: 30-Jul-2008
  • Modified Date:06-Mar-2021
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.