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

libmilter, rcpt_addr, and alias expansion

19 views
Skip to first unread message

Spike

unread,
May 29, 2003, 2:33:59 PM5/29/03
to
As far as I can tell, xxfi_envrcpt() is called after the recipient address
has been passed though the mailertable and virtusertable, but before it's
passed through the alias map. If I want to get the actual local user name
in a milter, what is the best way to do it?

Thanks,

->Spike

David F. Skoll

unread,
May 29, 2003, 2:59:05 PM5/29/03
to
Spike wrote:

I know of no other way than "manually" running "sendmail -bv" to
expand the alias. This may or may not work, depending on the
permissions on your alias files and the user the milter is running
as. It's also pretty inefficient.

You could also write code that simulates Sendmail's alias processing
by opening the alias maps, but that's an awful lot of work.

--
David.

Neil W Rickert

unread,
May 29, 2003, 2:53:31 PM5/29/03
to
"Spike" <sp...@indra.com> writes:

In the normal scheme of things, sendmail won't try to expand the
alias until it is ready to deliver. The milter has finished its work
before then.

Spike

unread,
May 29, 2003, 7:42:36 PM5/29/03
to
"Neil W Rickert" <ricke...@cs.niu.edu>:

> In the normal scheme of things, sendmail won't try to expand the
> alias until it is ready to deliver. The milter has finished its work
> before then.

Which makes sense, but in my case I'd like to check a per user whitelist in
a milter and need to by able to figure out who the actual user is. I guess
I'll have to look reading the alias db directly.

->Spike

Chris Adams

unread,
May 30, 2003, 4:01:36 PM5/30/03
to
Once upon a time, Spike <sp...@indra.com> said:
>Which makes sense, but in my case I'd like to check a per user whitelist in
>a milter and need to by able to figure out who the actual user is. I guess
>I'll have to look reading the alias db directly.

Something like this should do it (untested of course, but you should get
the idea). Something similar can be used to expand virtusertable
entries or any other server side data that you want to know in your
milter.

dnl # helpful define for adding to comma separated lists
define(`COMMAAPPEND', `define(`$1', ifdef(`$1', `$1`,$2'', `$2'))')

dnl # pass the "alias_user" macro to the milter xxfi_envrcpt() function
COMMAAPPEND(`confMILTER_MACROS_ENVRCPT',`{alias_user}')

LOCAL_CONFIG
# used to create macros to send to milter interface
Kstorage macro

# get access to the aliases file
Kaliases implicit

LOCAL_RULESETS
SLocal_check_rcpt
# clear the alias user storage and parse the recipient
R$* $: $(storage {alias_user} $) $1
R$* $: <?> $>ParseRecipient $1

# look for local users
R<?> $* < @ $=w > $: <!> $1 @ $2
R<?> $* < @ $* > $: $1 < @ $2 >
R<?> $* $: <!> $1

# look up user in aliases - this is not recursive (split this out to
# another ruleset if that is wanted)
R<!> $* $: <?> $1
R<?> $+ + $* @ $+ $: <!> < $(aliases $1 $: @ $) > $1 + $2 @ $3
R<?> $+ @ $+ $: <!> < $(aliases $1 $: @ $) > $1 @ $2
R<?> $+ + $* $: <!> < $(aliases $1 $: @ $) > $1 + $2
R<?> $* $: <!> < $(aliases $1 $: @ $) > $1
R<!> < @ > $+ $: $1
# got a match - store it
R<!> < $+ > $+ $: $(storage {alias_user} $@ $1 $) $2

--
Chris Adams <cma...@hiwaay.net>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.

0 new messages