Technical article 105706

How do I get the baduser functionality in mmdf using sendmail?

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4

Written · Last revised

Problem

I would like to get the functionality of the baduser option in mmdf
using sendmail.  This option forwards any mail sent to a non-local
user (not present in /etc/passwd) to a different host machine.  The
only mail I want affected is mail sent in the following format:
user

Mail sent with a fully qualified domain name will be sent through the usual SMTP channels.

Solution

This solution will only work on sendmail version 8.7.x or greater. The latest version of sendmail is available as SCO Support Level Supplement (SLS) OSS443, the Sendmail Security Supplement.

As root, copy the file /usr/lib/sendmail.cf to
/usr/lib/sendmail.old.  Using your favorite text editor, edit
the file /usr/lib/sendmail.cf.
1. Search for the entry "Smart".  Make the following entry just
below the "DS" macro.
# place to which unknown users should be forwarded
Kuser user -m -a<>
DL

The result should look similar to the following:

# "Smart" relay host (may be null)
DS
# place to which unknown users should be forwarded
Kuser user -m -a<>
DL
After the DL macro, enter the fully qualified domain name for the
machine you want non-local user's mail forwarded to.  The result
will look similar to the following (for the host "machine1"):
# "Smart" relay host (may be null)
DS
# place to which unknown users should be forwarded
Kuser user -m -a<>
DLmachine1.domain.com
2.  Search for the entry "S5".  Comment out the lines that are
already listed under that ruleset and add the following rules:
# deal with plussed users so aliases work nicely
R$+ + *         $#local $@ $&h $: $1
R$+ + $*        $#local $@ $2 $: $1 + *
# prepend an empty "forward host" on the front
R$+             $: <> $1
# send unrecognized local users to a relay host
R< > $+ + $*    $: < $L . > $( user $1 $) + $2
R< > $+         $: < $L . > $( user $1 $)   look up user
R< $* > $+ <> $*        $: < > $2 $3        found; strip $L
R< $* . > $+    $: < $1 > $2                strip extra dot
# handle plussed local names
R< > $+ + $*    $#local $@ $2 $: $1
# see if we have a relay or a hub
R< > $+         $: < $H > $1                try hub
R< > $+         $: < $R > $1                try relay
R< > $+         $@ $1                       nope, give up
R< local : $* > $*      $: $>95 < local : $1 > $2
R< error : $* > $*      $: $>95 < error : $1 > $2
R< $- : $+ > $+         $: $>95 < $1 : $2 > $3 < @ $2 >
R< $+ > $+              $@ $>95 < $1 > $2 < @ $1 >

The resulting ruleset will look similar to the following:

S5
# deal with plussed users so aliases work nicely
R$+ + *         $#local $@ $&h $: $1
R$+ + $*        $#local $@ $2 $: $1 + *
# prepend an empty "forward host" on the front
R$+             $: <> $1
# send unrecognized local users to a relay host
R< > $+ + $*    $: < $L . > $( user $1 $) + $2
R< > $+         $: < $L . > $( user $1 $)   look up user
R< $* > $+ <> $*        $: < > $2 $3        found; strip $L
R< $* . > $+    $: < $1 > $2                strip extra dot
# handle plussed local names
R< > $+ + $*    $#local $@ $2 $: $1
# see if we have a relay or a hub
R< > $+         $: < $H > $1                try hub
R< > $+         $: < $R > $1                try relay
R< > $+         $@ $1                       nope, give up
R< local : $* > $*      $: $>95 < local : $1 > $2
R< error : $* > $*      $: $>95 < error : $1 > $2
R< $- : $+ > $+         $: $>95 < $1 : $2 > $3 < @ $2 >
R< $+ > $+              $@ $>95 < $1 > $2 < @ $1 >
# see if we have a relay or a hub
#R$+                    $: < $R > $1            try relay
#R< > $+                $: < $H > $1            try hub
#R< > $+                $@ $1                   nope, give up
#R< $- : $+ > $+        $: $>95 < $1 : $2 > $3 < @ $2 >
#R< $+ > $+             $@ $>95 < $1 > $2 < @ $1 >
Make sure that the spaces between the left-hand-side and
right-hand-side in the above entries are tabs.  Save your
file and test this configuration.

See also

sendmail(ADMN), mail(C)

From the Xinuos technical article database, record 105706. Reproduced with permission. The original is at www.sco.com/ta/105706, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.