Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sendmail: rewrite rule question

493 views
Skip to first unread message

ziikell101

unread,
Oct 6, 2009, 9:40:27 AM10/6/09
to

hi all,

I have been asked to set-up some email on a UAT environment on an HP-UX
uat-fred B.11.31 U 9000/800 1568112650 unlimited-user license

A programme creates Emails that are sent to many different addresses.
All addressed end with the domain name: fred.com.

So that these emails are not sent to the actual addresses, the
developers would like the emails sent to a catchall address of
uat...@fred.com.

The header info in the sendmail.cf is:
##### SENDMAIL CONFIGURATION FILE
#####
##### built by eshwares@barbet on Mon Jan 2 16:24:30 IST 2006
##### in /ux/core/inet/src/sendmail-8.13.1/cf/cf
##### using ../ as configuration include directory

I cannot seem to use virtusertable to do this, because for some reason
it does not work. I added this,

Kvirtuser hash -o /etc/mail/virtusertable.db

and made the virtusertable.db, but it did not do anything.


I thought that I could get around this lack of virtusertable by having
sendmail rewrite all emails that end is a domain name to be rewitten to
uat-env, and mark it for local delivery to the local user uat-env.

Example:
R$-@$+ uat...@fred.com

I don't know if this is correct because I very seldom touch sendmail,
and nor am I certain whether it ought to be put into the sendmail.cf
file of in the .mc file and compiled.

Has anyone got any comments?

Best regards, J.

Andrzej Adam Filip

unread,
Oct 6, 2009, 6:40:58 PM10/6/09
to
ziikell101 <joek...@yahoo.com> wrote:
> hi all,
>
> I have been asked to set-up some email on a UAT environment on an HP-UX
> uat-fred B.11.31 U 9000/800 1568112650 unlimited-user license
>
> A programme creates Emails that are sent to many different addresses.
> All addressed end with the domain name: fred.com.
>
> So that these emails are not sent to the actual addresses, the
> developers would like the emails sent to a catchall address of
> uat...@fred.com.
>
> The header info in the sendmail.cf is:
> ##### SENDMAIL CONFIGURATION FILE
> #####
> ##### built by eshwares@barbet on Mon Jan 2 16:24:30 IST 2006
> ##### in /ux/core/inet/src/sendmail-8.13.1/cf/cf
> ##### using ../ as configuration include directory
>
> I cannot seem to use virtusertable to do this, because for some reason
> it does not work. I added this,
>
> Kvirtuser hash -o /etc/mail/virtusertable.db
>
> and made the virtusertable.db, but it did not do anything.
> [...]

The above line alone in sendmail.cf is insufficient to make sendmail
support virtusertable. Support for virtusertable should be added via
modification of sendmail.mc file used to generate sendmail.cf

URL(s):
http://www.sendmail.org/m4/intro.html
http://www.sendmail.org/m4/features.html#virtusertable

--
[pl>en Andrew] Andrzej Adam Filip : an...@onet.eu : Andrze...@gmail.com
Open-Sendmail: http://open-sendmail.sourceforge.net/
Men of lofty genius when they are doing the least work are most active.
-- Leonardo da Vinci

ziikell101

unread,
Oct 7, 2009, 3:58:14 AM10/7/09
to
Andrzej Adam Filip wrote:
> ziikell101 <joek...@yahoo.com> wrote:
>> hi all,
>> [SNIP]]

>>
>> Kvirtuser hash -o /etc/mail/virtusertable.db
>>
>> and made the virtusertable.db, but it did not do anything.
>> [...]
>
> The above line alone in sendmail.cf is insufficient to make sendmail
> support virtusertable. Support for virtusertable should be added via
> modification of sendmail.mc file used to generate sendmail.cf
>
> URL(s):
> http://www.sendmail.org/m4/intro.html
> http://www.sendmail.org/m4/features.html#virtusertable
>

Thanks for the URLs. I read these and there is a reference to building
the .mc files. These are the ones in the system:

root@uat-env:/# find / -name "*.mc"
/usr/newconfig/etc/mail/cf/cf/generic-hpux10.mc
/usr/newconfig/etc/mail/cf/cf/submit.mc


I see that I have to add the line:
FEATURE(`virtusertable', `dbm /etc/mail/virtusers')
into one of the .mc files, but don't know which one it ought to be added
into to.

The URL reads that one had to use this cmd to build the cf files:
m4 ${CFDIR}/m4/cf.m4 config.mc > config.cf

Thus, I think I should use:
m4 /usr/newconfig/etc/mail/cf/cf/cf.m4 config.mc > config.cf
However, the config.mc file does not exist on this system, so I am at a
loss here: Unless I have to add the line FEATURE(`virtusertable', `dbm
/etc/mail/virtusers') into a new config.mc file and build this one line
file.

After I have built this, should I simply append the contents of the
config.cf to the /etc/mail/sendmail.cf?

Rgeards,j

ziikell101

unread,
Oct 8, 2009, 4:16:29 AM10/8/09
to
I found a file for virtusertable in /usr/newconfig/etc/mail/cf/feature.

root@uat-env:/usr/newconfig/etc/mail/cf/feature# ls virtuser*
virtuser_entire_domain.m4 virtusertable.m4

I have no idea what to do with this, but a guess is:

m4 virtusertable.m4 null.mc > /etc/mail/sendmail.cf

(null.mc was referred to in
http://www.faqs.org/docs/securing/chap22sec177.html

However, there is no such file called null.mc anywhere on the system:
root@uat-env:/usr/newconfig/etc# find / -name null.mc
root@uat-env:/usr/newconfig/etc#

Because I can predict the outcome of this, does any one know of a good
guide for sendmail compilation for simple folk like me?

Best regards.

ziikell101

unread,
Oct 8, 2009, 4:20:40 AM10/8/09
to
I realised that I have to create the null.mc file:

One example is this:
OSTYPE(`linux')dnl
DOMAIN(`generic')dnl
FEATURE(`nullclient',`mail.openna.com')dnl
undefine(`ALIAS_FILE')dnl

I suppose mine would be:

OSTYPE(`hpux')dnl
DOMAIN(`generic')dnl
FEATURE(`nullclient',`uat-env.fred.com')dnl
undefine(`ALIAS_FILE')dnl

Will it complain it I add the incorrect details when it compiles, or
will it just blindly carry on?

ziikell101

unread,
Oct 8, 2009, 5:31:15 AM10/8/09
to
It look a while, but I think this might be ok. now to test it.
Note for others that read this archive: I created the file
virtusertable.cf myself and copied the FEATURE into it from a web page.
One could have probably added an include into the cf.m4, but this way is
easier for me.

# cat virtusertable.cf
FEATURE(`virtusertable', `dbm /etc/mail/virtusertable')dnl

# m4 ../../cf/m4/cf.m4 virtusertable.cf ../../cf/cf/generic-hpux10.mc
>/etc/mail/sendmail.cf

# grep -i virtuser /etc/mail/sendmail.cf
##### $Id: virtusertable.m4,v 8.23 2002/06/27 23:23:57 gshapiro Exp $
#####
Kvirtuser dbm /etc/mail/virtusertable
R<!> $+ < @ $={VirtHost} . > $: < $(virtuser $1 @ $2 $@ $1 $: @ $) >
$1 < @ $2 . >
R<!> $+ < @ $=w . > $: < $(virtuser $1 @ $2 $@ $1 $: @ $) > $1 < @
$2 . >
$: < $(virtuser $1 + + @ $3 $@ $1 $@ $2 $@ +$2
$: @ $) > $1 + $2 < @ $3 . >
$: < $(virtuser $1 + * @ $3 $@ $1 $@ $2 $@ +$2
$: @ $) > $1 + $2 < @ $3 . >
$: < $(virtuser $1 @ $3 $@ $1 $@ $2 $@ +$2 $: @
$) > $1 + $2 < @ $3 . >
R<@> $+ + $+ < @ $+ . > $: < $(virtuser + + @ $3 $@ $1 $@ $2 $@ +$2 $: @
$) > $1 + $2 < @ $3 . >
R<@> $+ + $* < @ $+ . > $: < $(virtuser + * @ $3 $@ $1 $@ $2 $@ +$2 $: @
$) > $1 + $2 < @ $3 . >
R<@> $+ + $* < @ $+ . > $: < $(virtuser @ $3 $@ $1 $@ $2 $@ +$2 $: ! $)
> $1 + $2 < @ $3 . >
R<@> $+ < @ $+ . > $: < $(virtuser @ $2 $@ $1 $: @ $) > $1 < @ $2 . >

ziikell101

unread,
Oct 8, 2009, 6:13:37 AM10/8/09
to
Oops.

> Oct 8 11:53:56 uat-env sendmail[29381]: n989qLAn029381: SYSERR(root):
dbm map "virtuser": missing map file /etc/mail/virtusertable


I used this command to create the file:

# makemap hash /etc/mail/virtusertable < virtusertable.txt

and have this file created:


root@uat-env:/etc/mail# file virtusertable.db
virtusertable.db: data
root@uat-env:/etc/mail# ls -l !$
ls -l virtusertable.db
-rw-r--r-- 1 root sys 24576 Oct 8 12:10 virtusertable.db

I do not know why it created a virtusertable.db and not a virtusertable.

ziikell101

unread,
Oct 8, 2009, 6:20:11 AM10/8/09
to
Recreated the file with the dbm option:
makemap dbm /etc/mail/virtusertable < virtusertable.txt

This time there was no error message, but also there was no match:

# cat virtusertable.txt
@fred.com uat-mail

uat-mail is certainly for local delivery, which is correct:
> 3,0 uat-mail
canonify input: uat-mail
Canonify2 input: uat-mail
Canonify2 returns: uat-mail
canonify returns: uat-mail
parse input: uat-mail
Parse0 input: uat-mail
Parse0 returns: uat-mail
ParseLocal input: uat-mail
ParseLocal returns: uat-mail
Parse1 input: uat-mail
Parse1 returns: $# local $: uat-mail
parse returns: $# local $: uat-mail

But there it does not find the table:
> /map virtuser f...@tele2.com
map_lookup: virtuser (f...@fred.com) no match (0)

ziikell101

unread,
Oct 8, 2009, 7:52:02 AM10/8/09
to
Next test:

f...@fred.com uat-mail
@fred.com uat-mail

Results:
# sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> /map virtuser f...@fred.com
map_lookup: virtuser (f...@fred.com) returns uat-mail (0)
> /map virtuser edw...@fred.com
map_lookup: virtuser ( edw...@fred.com) no match (0)

Odd, f...@tele2.com matches, but edw...@fred.com failed to be matched by
the line: @fred.com uat-mail


at this point, I am little lost, because all documentation that I had
read, and understood, indicates that a catch-all can be set up in the
file as:
@domain.com catch-all-account

ziikell101

unread,
Oct 8, 2009, 7:54:11 AM10/8/09
to
Additionally, I realise that I also have to change the way mail is
rewritten, because at present sendmail will not delivery it locally anyway;

3,0 f...@fred.com
canonify input: f @ fred . com
Canonify2 input: f < @ fred . com >
Canonify2 returns: f < @ fred . com . >
canonify returns: f < @ fred . com . >
parse input: f < @ fred . com . >
Parse0 input: f < @ fred . com . >
Parse0 returns: f < @ fred . com . >
ParseLocal input: f < @ fred . com . >
ParseLocal returns: f < @ fred . com . >
Parse1 input: f < @ fred . com . >
MailerToTriple input: < > f < @ fred . com . >
MailerToTriple returns: f < @ fred . com . >
Parse1 returns: $# esmtp $@ fred . com . $: f < @ fred . com . >
parse returns: $# esmtp $@ fred . com . $: f < @ fred . com . >

ziikell101

unread,
Oct 8, 2009, 8:25:16 AM10/8/09
to
Looks like I have mixed up some domain names I was using for testing
purposes. Its best that I rewrite the current question for clarify.

--------------------------------------------------------------------

Current situation:
# cat /etc/mail/virtusertable
f...@fred.com uat-mail
@fred.com uat-mail

Results:
# sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
/map virtuser f...@fred.com
map_lookup: virtuser (f...@fred.com) returns uat-mail (0)
/map virtuser edw...@fred.com
map_lookup: virtuser ( edw...@fred.com) no match (0)

Odd, f...@fred.com matches, but edw...@fred.com failed to be matched by
the line: @fred.com uat-mail
I had expected this to work.

Next, I added this to the virtusertable.txt and rebuilt the index.
@fred.com %1...@newfred.com

I started sendmail and tested again:


/map virtuser edw...@fred.com
map_lookup: virtuser ( edw...@fred.com) no match (0)


At this point, I am little lost, because all documentation that I had

Loki Harfagr

unread,
Oct 8, 2009, 1:16:58 PM10/8/09
to
Thu, 08 Oct 2009 14:25:16 +0200, ziikell101 did cat :


Would you please try calmly this:

$ echo "fred.com" > /etc/mail/local-host-names

and then test again like examples below made with
just for test time:
---------
$ cat local-host-names
itsallmyfau.lt
nobodylikes.me
---------
---------
cat virtusertable
to...@nobodylikes.me loki
@itsallmyfau.lt root
---------

---------
$ sendmail -bt


ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>

...
> /parse to...@nobodylikes.me
final returns: loki
mailer local, user loki
---------

or simply:
---------
$ sendmail -bv bonga...@itsallmyfau.lt
nonga...@itsallmyfau.lt... deliverable: mailer local, user root

$ sendmail -bv to...@nobodylikes.me
to...@nobodylikes.me... deliverable: mailer local, user loki

$ sendmail -bv riup...@nobodylikes.me
riup...@nobodylikes.me... User unknown
---------

Andrzej Adam Filip

unread,
Oct 8, 2009, 1:22:20 PM10/8/09
to

Sendmail does virtusertable servicing using more than one virtusertable
lookup. Use the command below for testing to see all the lookups:

echo '3,0 edw...@fred.com' | sendmail -bt -d60.5

-d60.5 -- turns on tracking map lookups

--
[pl>en Andrew] Andrzej Adam Filip : an...@onet.eu : Andrze...@gmail.com
Open-Sendmail: http://open-sendmail.sourceforge.net/

Mother is far too clever to understand anything she does not like.
-- Arnold Bennett

ziikell101

unread,
Oct 12, 2009, 5:55:13 AM10/12/09
to
Andrzej Adam Filip wrote:
> ziikell101 <joek...@yahoo.com> wrote:
[snip]

>
> Sendmail does virtusertable servicing using more than one virtusertable
> lookup. Use the command below for testing to see all the lookups:
>
> echo '3,0 edw...@fred.com' | sendmail -bt -d60.5
>
> -d60.5 -- turns on tracking map lookups

Hi Andrzej,

This looks well. Thank-you for the command to test all the lookups.

# echo '3,0 edw...@fred.com' | sendmail -bt -d60.5


ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>

> canonify input: edwsew @ fred . com
Canonify2 input: edwsew < @ fred . com >
map_lookup(host, fred.com, %0=fred.com) => fred.com. (0)
Canonify2 returns: edwsew < @ fred . com . >
canonify returns: edwsew < @ fred . com . >
parse input: edwsew < @ fred . com . >
Parse0 input: edwsew < @ fred . com . >
map_lookup(dequote, edwsew, %0=edwsew) => NOT FOUND (0)
Parse0 returns: edwsew < @ fred . com . >
ParseLocal input: edwsew < @ fred . com . >
ParseLocal returns: edwsew < @ fred . com . >
Parse1 input: edwsew < @ fred . com . >
map_lookup(virtuser, edw...@fred.com, %0=edw...@fred.com, %1=edwsew) =>
NOT FOUND (0)
map_lookup(virtuser, @fred.com, %0=@fred.com, %1=edwsew) => uat-mail (0)
Recurse input: uat-mail


canonify input: uat-mail
Canonify2 input: uat-mail
Canonify2 returns: uat-mail
canonify returns: uat-mail
parse input: uat-mail
Parse0 input: uat-mail

map_lookup(dequote, uat-mail, %0=uat-mail) => NOT FOUND (0)


Parse0 returns: uat-mail
ParseLocal input: uat-mail
ParseLocal returns: uat-mail
Parse1 input: uat-mail
Parse1 returns: $# local $: uat-mail
parse returns: $# local $: uat-mail

Recurse returns: $# local $: uat-mail

ziikell101

unread,
Oct 12, 2009, 5:56:33 AM10/12/09
to

I calmly added fred.com into sendmail.cw and it works now. Adding it
into local-host-names did not make any difference.

> $ sendmail -bv to...@nobodylikes.me
If this were the case, then I would have no friends.

> > $ sendmail -bv bonga...@itsallmyfau.lt
Yes, of course it is, because I do not clearly understand sendmail. If
I did then I doubt I would have posted into this group.

Regardless, thank-you for your help.

Loki Harfagr

unread,
Oct 12, 2009, 7:46:00 AM10/12/09
to
Mon, 12 Oct 2009 11:56:33 +0200, ziikell101 did cat :

Excellent :-)

> Adding it
> into local-host-names did not make any difference.

Now, this is quite puzzling for me as I think the local-host-names is
just the *new* name/file for the old sendmail.cw!

>
>> $ sendmail -bv to...@nobodylikes.me
> If this were the case, then I would have no friends.
>
>> > $ sendmail -bv bonga...@itsallmyfau.lt
> Yes, of course it is, because I do not clearly understand sendmail.

Don't worry, I just tried and put some humor to catch your attention
as I felt that you were on the verge of panicking :-) I'm sincerely
sorry if it somehow has vexed you and it was not my intention to.

> If
> I did then I doubt I would have posted into this group.
>
> Regardless, thank-you for your help.

My apologies for my cheap puns and congratulations for
winning on your routing problem :-)

ziikell101

unread,
Oct 12, 2009, 9:51:51 AM10/12/09
to

Loki Harfagr wrote:
>
> My apologies for my cheap puns and congratulations for
> winning on your routing problem :-)

No problem. You notation did bring a smile to my face, but I thought
that I would reply tartly :D

Its the sendmail.cw here because its an old sendmail implementation from HP.

ziikell101

unread,
Oct 14, 2009, 4:49:35 AM10/14/09
to
In the end, the virtualtable did not do what we wanted it to do so a
rewrite rule was written and the rule works as we want it to do:

R $+@$+ $: test.s...@fred.com

The rule rewrites anything to the RHS test.s...@fred.com, and the $:
terminates it, thus avoiding a mail loop, or rewite loop, or how ever it
is called. It works:


# echo '3,0 this...@fred.com' | sendmail -bt -d60.5


ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>

> canonify input: thisworks @ bob . com
Canonify2 input: test . surname < @ fred . com >


map_lookup(host, fred.com, %0=fred.com) => fred.com. (0)

Canonify2 returns: test . surname < @ fred . com . >
canonify returns: test . surname < @ fred . com . >
parse input: test . surname < @ fred . com . >
Parse0 input: test . surname < @ fred . com . >
Parse0 returns: test . surname < @ fred . com . >
ParseLocal input: test . surname < @ fred . com . >
ParseLocal returns: test . surname < @ fred . com . >
Parse1 input: test . surname < @ fred . com . >
MailerToTriple input: < smtp2 . mailservices . com > test . surname


< @ fred . com . >

MailerToTriple returns: $# relay $@ smtp2 . mailservices . com $: test
. surname < @ fred . com . >
Parse1 returns: $# relay $@ smtp2 . mailservices . com $: test
. surname < @ fred . com . >
parse returns: $# relay $@ smtp2 . mailservices . com $: test
. surname < @ fred . com . >


However, when I start sendmail, the rule is ignored :

# mailx -s "to test email" test.s...@missed1234.co.uk </tmp/test
Oct 14 10:38:03 uat-triton sendmail[781]: n9E8c3l5000779:
to=test.s...@missed1234.co.uk, ctladdr=root (0/3), delay=00:00:00,
xdelay=00:00:00, mailer=relay, pri=120175, relay=smtp2.mailservices.com.
[10.254.42.6], dsn=2.0.0, stat=Sent (
<200910140838....@uat-triton.nmz.mailservices.com> Queued
mail for delivery)

The only change I made was to add a DSsmtp2.mailservices.com.


Does anyone know why the rewrite seems to be ignored.

Cheers.

ziikell101

unread,
Oct 14, 2009, 5:23:42 AM10/14/09
to
Further testing reveals that the rule works very well and I have
succeeded in spaming myself with 11190 emails. I am rather pleased.
Thus, ignore my previous post; posted in haste :D All is well.

Johann Klasek - swap last two domainparts

unread,
Oct 23, 2009, 4:54:41 AM10/23/09
to
Loki Harfagr <l0...@thedarkdesign.free.fr.invalid> wrote:
> Thu, 08 Oct 2009 14:25:16 +0200, ziikell101 did cat�:
>
> > Looks like I have mixed up some domain names I was using for testing
> > purposes. Its best that I rewrite the current question for clarify.
> >
> > --------------------------------------------------------------------
> >
> > Current situation:
> > # cat /etc/mail/virtusertable
> > f...@fred.com uat-mail
> > @fred.com uat-mail
> >
[..]

> > I started sendmail and tested again:
> > /map virtuser edw...@fred.com
> > map_lookup: virtuser ( edw...@fred.com) no match (0)
> >
> >
> > At this point, I am little lost, because all documentation that I had
> > read, and understood, indicates that a catch-all can be set up in the
> > file as:
> > @domain.com catch-all-account
>
>
> Would you please try calmly this:
>
> $ echo "fred.com" > /etc/mail/local-host-names
>
> and then test again like examples below made with
> just for test time:
> ---------
> $ cat local-host-names
> itsallmyfau.lt
> nobodylikes.me
> ---------
> ---------
> cat virtusertable
> to...@nobodylikes.me loki
> @itsallmyfau.lt root
> ---------

As a variation from above you can use following in your MC config:

dnl # virtual users
VIRTUSER_DOMAIN_FILE(`-o /etc/mail/virtual-hosts %[^\#]')dnl
FEATURE(virtusertable)dnl

echo "fred.com" >/etc/mail/virtual-hosts

This separates your virtual domains (listed in /etc/mail/virtual-hosts)
from your real local domains and all its aliases and accounts. This
means all local aliases from aliases.db and account names are not mapped
automatically into every virtual domain ... just if you want or need
this behavior.

Johann Klasek

0 new messages