Change filename of mailertable at commandline
Change filename of mailertable at commandline
am 31.10.2007 11:09:16 von andreas.sachs
Hello,
is there a possibility to overwrite the filename of the mailertable
with an command line argument?
Example:
mailertable.db <- default mailertable
mailertable-x.db
sendmail -qRxyz
At the moment i have a second sendmail.cf and change the filename
inside. Then i invoke sendmail with -C
sendmail -C sendmail-mailertabe-x.cf -qRxyz
Thanks
Andreas
Re: Change filename of mailertable at commandline
am 31.10.2007 23:05:58 von per
In article <1193825356.887950.34960@d55g2000hsg.googlegroups.com> andi
writes:
>is there a possibility to overwrite the filename of the mailertable
>with an command line argument?
>
>Example:
>mailertable.db <- default mailertable
>mailertable-x.db
>
>sendmail -qRxyz
Not directly, but from a quick check of the source it seems the K line
is macro-expanded, and you can set macros on the commandline with -M
(see doc/op/op.* - it's not in the man page, only for "advanced
users":-). So, totally untested, but something along these lines could
work:
In .mc:
LOCAL_CONFIG
D{MailerTable}mailertable
FEATURE(`mailertable', `hash /etc/mail/${MailerTable}')
Override on the command line with:
sendmail -M{MailerTable}mailertable-x
(Requires quoting in *csh.) Hm, actually I did very minimal testing and
it seems you can't override macro definitions that are in the .cf, so
you'd have to take out the D line and either *always* use -M, or get a
bit more complex:
FEATURE(`mailertable',
`hash /etc/mail/$?{MailerTable}${MailerTable}$|mailertable$.')
- which would use {MailerTable} if it's set (from the command line),
otherwise "mailertable".
>At the moment i have a second sendmail.cf and change the filename
>inside. Then i invoke sendmail with -C
>
>sendmail -C sendmail-mailertabe-x.cf -qRxyz
If the above works, it will obviously require as much privilege as -C
does (i.e. root in a normal installation), but you'd be able to have a
single sendmail.cf which I guess is the goal.
--Per Hedeland
per@hedeland.org
Re: Change filename of mailertable at commandline
am 01.11.2007 12:51:20 von andreas.sachs
Thanks for this solutions. I will try it. At the moment i found
another solution, but your solution looks better to me. I use two
mailertables. The first one is empty. If i need special entries i will
put them in the first table to overwrite the entries from the second
table.
Kmailertablemap1 hash /etc/mail/mailertable-x
Kmailertablemap2 hash /etc/mail/mailertable
FEATURE(mailertable, `sequence mailertablemap1 mailertablemap2')dnl
> sendmail -M{MailerTable}mailertable-x
> ...
> FEATURE(`mailertable',
> `hash /etc/mail/$?{MailerTable}${MailerTable}$|mailertable$.')
>
> If the above works, it will obviously require as much privilege as -C
> does (i.e. root in a normal installation), but you'd be able to have a
> single sendmail.cf which I guess is the goal.
Yes, that's my goal.
Andreas
Re: Change filename of mailertable at commandline
am 03.11.2007 00:55:32 von per
In article <1193917880.051315.234700@v3g2000hsg.googlegroups.com> andi
writes:
>Thanks for this solutions. I will try it. At the moment i found
>another solution, but your solution looks better to me. I use two
>mailertables. The first one is empty. If i need special entries i will
>put them in the first table to overwrite the entries from the second
>table.
>
>Kmailertablemap1 hash /etc/mail/mailertable-x
>Kmailertablemap2 hash /etc/mail/mailertable
>FEATURE(mailertable, `sequence mailertablemap1 mailertablemap2')dnl
Well, I'm not sure one is necessarily better than the other, but they
have rather different semantics: What you asked for and I described was
something where different instances of sendmail had different
mailertables (based on commandline args), what you describe here is
something where all instances of sendmail have the same mailertable at a
given point in time, but you can change it from under them.
The first question is which of those two you really need/want:-) - if
it's really the latter, there's no point in trying the way I described.
And in that case your solution is a bit sub-optimal, as it will often
need to do two lookups instead of one - and there's no reason for that,
you can just update the standard single mailertable from under sendmail,
either with total rebuild, or if that takes too long for your liking,
you can use editmap(8) included in the sendmail distribution.
If on the other hand you actually want different mailertables for
different sendmail instances at a given point in time, your solution is
broken.:-)
--Per Hedeland
per@hedeland.org