How to properly run qmail-smtpd via xinetd

qmail-smtpd's normal way of logging is printing to stderr. When run as a daemon, its stdout/stderr is piped to splogger, an auxiliary program to send messages to syslogd. Here is how a standalone daemon is launched:

/opt/ucspi-tcp/current/bin/tcpserver -v -H \
        -c 500 \
        -x /opt/vpopmail/config/relay/rules.cdb \
        -u $QMAILD_UID -g $NOFILES_GID \
        -D \
        127.0.0.1 smtp \
        /opt/netqmail/current/bin/qmail-smtpd \
                /opt/vpopmail/current/bin/vchkpw /bin/true 2>&1 | \
                        /opt/netqmail/current/bin/splogger smtpd 2 &

In the case of xinetd, both stdout and stderr are sent to the socket, and if we leave it as is, qmail-smtpd log messages and SMTP messages will create a mess-up. The solution is to redirect stderr to /opt/netqmail/current/bin/splogger leaving stdout unaffected. Such a behaviour can be implemented by the following script (to be run from within xinetd instead of qmail-smtpd):

$ cat /opt/netqmail/current/bin/qmail-smtpd-inetd
#!/bin/sh
dir=`dirname "$0"`
exec 3>&1
$dir/qmail-smtpd 2>&1 1>&3 3>&-| $dir/splogger smtpd 2 3>&-
exec 3>&-

One of Shell tricks is used by this script. Then the portion of xinetd config will look as follows:

service smtp
{
      id              = smtp-local
      socket_type     = stream
      protocol        = tcp
      user            = qmaild
      wait            = no
      server          = /opt/netqmail/current/bin/tcp-env
      server_args     = -R /opt/netqmail/current/bin/qmail-smtpd-inetd
      env             = RELAYCLIENT=
      interface       = 127.0.0.1
      instances       = 250
      per_source      = 250
      cps             = 1000 1
}
 
internal/email/qmail.txt · Last modified: 2008/05/22 20:13 by solar
 
Recent changes RSS feed Creative Commons License Donate to DokuWiki Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki Powered by OpenVZ Powered by Openwall GNU/*/Linux