Nullclient with alias processing

From Brandonhutchinson.com

Revision as of 20:19, 14 November 2008 by Hutch (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Situation: You want to use the sendmail nullclient FEATURE, but you want to use the alias database and/or .forward files.

In this example, I'm running sendmail 8.11.7p3+Sun on a Solaris 8 SPARC system.

Enabling the alias database

Given my existing sendmail.mc file:

VERSIONID(`$Header: /var/cfengine/masterfiles/solaris/etc/mail/RCS/sendmail.mc.mm,v 1.6 2008/11/07 19:44:56 hutchib Exp $') 
OSTYPE(`solaris8')
define(`confFALLBACK_MX',`host.example.com')
FEATURE(`nullclient',`host.example.com')

And given /usr/lib/sendmail/feature/nullclient.m4:

divert(-1)
#
# Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
#       All rights reserved.
# Copyright (c) 1983 Eric P. Allman.  All rights reserved.
# Copyright (c) 1988, 1993
#       The Regents of the University of California.  All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#
ifelse(defn(`_ARG_'), `', `errprint(`Feature "nullclient" requires argument')',
        `define(`_NULL_CLIENT_', _ARG_)')

#
#  This is used only for relaying mail from a client to a hub when
#  that client does absolutely nothing else -- i.e., it is a "null
#  mailer".  In this sense, it acts like the "R" option in Sun
#  sendmail.
#

divert(0)
VERSIONID(`$Id: nullclient.m4,v 8.21.16.3 2000/09/17 17:04:22 gshapiro Exp $')
divert(-1)

undefine(`ALIAS_FILE')
define(`MAIL_HUB', _NULL_CLIENT_)
define(`SMART_HOST', _NULL_CLIENT_)
define(`confFORWARD_PATH', `')
ifdef(`confFROM_HEADER',, `define(`confFROM_HEADER', `<$g>')')
define(`_DEF_LOCAL_MAILER_FLAGS', `lsDFM5q')
MASQUERADE_AS(_NULL_CLIENT_)
FEATURE(`allmasquerade')
FEATURE(`masquerade_envelope')
MAILER(`local')
MAILER(`smtp')

I replace FEATURE(`nullclient',`host.example.com') with the above lines in bold from nullclient.m4.

My sendmail.mc now looks like:

VERSIONID(`$Header: /var/cfengine/masterfiles/solaris/etc/mail/RCS/sendmail.mc.mm,v 1.6 2008/11/07 19:44:56 hutchib Exp $') 
OSTYPE(`solaris8')
define(`confFALLBACK_MX',`host.example.com')
FEATURE(`nullclient',`host.example.com')
define(`MAIL_HUB', _NULL_CLIENT_)
define(`SMART_HOST', _NULL_CLIENT_)
define(`confFORWARD_PATH', `')
ifdef(`confFROM_HEADER',, `define(`confFROM_HEADER', `<$g>')')
define(`_DEF_LOCAL_MAILER_FLAGS', `lsDFM5q')
MASQUERADE_AS(_NULL_CLIENT_)
FEATURE(`allmasquerade')
FEATURE(`masquerade_envelope')
MAILER(`local')
MAILER(`smtp')

Next, I substitute `host.example.com' for _NULL_CLIENT_.

I also have to add the A flag to LOCAL_MAILER_FLAGS above to enable the alias database. From op.pdf:

A Look up the user (address) part of the resolved mailer triple, in the alias database. Normally this is only set for local mailers.

My sendmail.mc now looks like:

VERSIONID(`$Header: /var/cfengine/masterfiles/solaris/etc/mail/RCS/sendmail.mc.mm,v 1.6 2008/11/07 19:44:56 hutchib Exp $') 
OSTYPE(`solaris8')
define(`confFALLBACK_MX',`host.example.com')
define(`MAIL_HUB',`host.example.com')
define(`SMART_HOST',`host.example.com')
define(`confFORWARD_PATH', `')
ifdef(`confFROM_HEADER',, `define(`confFROM_HEADER', `<$g>')')
define(`_DEF_LOCAL_MAILER_FLAGS', `lsADFM5q')
MASQUERADE_AS(`host.example.com)
FEATURE(`allmasquerade')
FEATURE(`masquerade_envelope')
MAILER(`local')
MAILER(`smtp')

We now essentially have a "nullclient" configuration that uses the alias database.

Enabling .forward files

To enable .forward files, the following changes need to be made to the above sendmail.mc file:

  • define(`confFORWARD_PATH', `') needs to be removed.
  • The host cannot use a mail hub; define(`MAIL_HUB',`host.example.com') needs to be removed.
  • The w flag needs to be added to LOCAL_MAILER_FLAGS. From op.pdf:
w The user must have a valid account on this machine, i.e., getpwnam must succeed. If not, the mail is bounced. See also the MailBoxDatabase option. This is required to get “.forward” capability.

sendmail.mc now looks like:

VERSIONID(`$Header: /var/cfengine/masterfiles/solaris/etc/mail/RCS/sendmail.mc.mm,v 1.6 2008/11/07 19:44:56 hutchib Exp $') 
OSTYPE(`solaris8')
define(`confFALLBACK_MX',`host.example.com')
define(`SMART_HOST',`host.example.com')
ifdef(`confFROM_HEADER',, `define(`confFROM_HEADER', `<$g>')')
define(`_DEF_LOCAL_MAILER_FLAGS', `lsADFMw5q')
MASQUERADE_AS(`host.example.com)
FEATURE(`allmasquerade')
FEATURE(`masquerade_envelope')
MAILER(`local')
MAILER(`smtp')

Links

Personal tools