Re: [Exim] Recipients in local_scan()

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: Joe Doehler
CC: exim-users
Subject: Re: [Exim] Recipients in local_scan()
On Mon, 18 Aug 2003, Joe Doehler wrote:

> 1- I seem unable to read certain global variables. This code snippet causes
> local_scan to crash:
>
> //////////////////////////////////////////////////
> int local_scan(int fd, uschar **return_text)
> {
> char line [80];
> char *z;
> z = &line[0];
> strcpy (z, sender_host_address) ;
> return LOCAL_SCAN_ACCEPT;
> }
> //////////////////////////////////////////////////


sender_host_address will be set only when a message is being received
from an external host, using TCP/IP. This will certainly crash if you
feed Exim a local message (i.e. not via TCP/IP), because the variable
will contain NULL. This is documented.

> whereas the following code snippet works:
>
> ////////////////////////////////////////////////////////
> int local_scan(int fd, uschar **return_text)
> {
> char line [80];
> char *z;
> z = &line[0];
> strcpy (z, sender_address) ;
> return LOCAL_SCAN_ACCEPT;
> }
> /////////////////////////////////////////////////////////


sender_address is set for every message, so yes, this should be OK
(assuming that sender_address is shorter than 80 characters. Don't count
on it! You never know what crap somebody will feed you.

> 2- I cannot read any recipient's address. Everything I have done tried so
> far causes local_scan to crash, including the use of expand_string.


If you don't tell us what you've tried, it's hard to help. Section 38.6
of the 4.20 manual describes the format of recipient address structures.

> It appears that local_scan() is called once per e-mail, not once per
> recipient.


Yes. At the point where Exim is about to say "OK" to the sending entity.

> Are the recipient addresses stored in a global list that
> local_scan can read?


Yes. See section 38.6 and the description of recipients_list.

> A code snippet will be appreciated, because any
> reference I make to recipient_item stops the compiler: I am overlooking
> something simple here.


The address of the first recipient is pointed to by

recipients_list[0].address

recipients_count holds the number of recipients.

> It appears that some people had problem reading recipient's addresses into
> local_scan with Exim 4.1, and I am wondering if fixes were implemented in 4.2.


Can't remember, but every change is listed in the ChangeLog file.

--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book