Re: [Exim] $home in filter when check_local_user is not set

Pàgina inicial
Delete this message
Reply to this message
Autor: Nico Erfurth
Data:  
A: Miquel van Smoorenburg
CC: exim-users
Assumpte: Re: [Exim] $home in filter when check_local_user is not set
Miquel van Smoorenburg wrote:
> I'm using exim-4.04 in an unusual config; I'm not using
> check_local_user but I'm setting user = based on something
> else than the $local_part.
>
> This all works fine, I use $address_data to pass things like
> username and homedir around.
>
> However when I execute a filter, $home is not set, and I
> would like it to be (for logging, for example).
>
> I supposed that transport_current_directory and
> transport_home_directory would also influence the settings
> for filtering but they don't.
>
> Now I see two solutions:
>
> - Add an option called 'local_user' that makes exim look at
> the value of that option instead of $local_user when
> check_local_user is set
>
> - Set $home to the value of transport_home_directory
> even for filters
>
> Both fixes are easy enough, in fact I already implemented
> the first one for fun.
>
> Philip, is this something that should be fixed, if so,
> which solution do you prefer and would you like a patch?


I had a similar problem, some time ago, i fixed it this way
(quoted mail follows)

-------------------------------------------------------------
pmail_forward:
   driver = redirect
   allow_filter
   check_ancestor
   no_check_local_user
   no_expn
   require_files = "USERHOME/$local_part.filt"
   data =  ${sg {${readfile{USERHOME/$local_part.filt}}} \
     {save\\s+([^/].*)\\s*}{save USERHOME/$local_part/\$1\\n}}
   file_transport = pmail_delivery
   pipe_transport = address_pipe
   reply_transport = address_reply
   directory_transport = pmail_delivery
   retry_use_local_part
   user = mail
   no_verify


USERHOME is a macro that looks up the "home directory" of our virtual user,
My one:

USERHOME = /var/imap/${lookup mysql{SELECT s.Name FROM pm_domains d,
pm_sites s, pm_users u WHERE s.ID = d.SiteID AND d
.Name = '$domain' and u.Name = '$local_part' and u.SiteID = s.ID AND
s.SiteState != 'locked_bounce' AND u.AccountState
!= 'locked_bounce'}{${value}}}/

The trick is, we read the whole filterfile, and "preprocess", by using
${sg} we search for    save (RELATIVE-PATH) and replace it with save
USERHOME/RELATIVE-PATH


This one works for me, i would be glad if someone with the same problem
could test this solution and give some response.
-------------------------------------------------------------

you could do something like this in your case

${ sg {${readfile{yourfilter-file}}} {\$home}{YOURHOME}}

(maybe you need \\$home instead of \$home)
This should replace all occurences of $home with YOURHOME, and
everything is passed to the filter-router in data=


ciao