Users home path inside a sieve script

Mark Constable markc at renta.net
Tue Apr 4 03:46:19 EEST 2017


On 04/04/17 04:00, Stephan Bosch wrote:
>> Perhaps I have not looked hard enough but is it possible to get at
>> the current users auth userdb "home" (or $HOME) variable from
>> inside a sieve script? Example?
>
> What do you want to do with it?

I was hoping to replace the 2 variables below with the actual home dir
path directly instead of building up "/home/u/${rhs}/home/${lhs}/"...

require ["vnd.dovecot.execute", "fileinto", "envelope", "variables", "editheader"];
if envelope :localpart :matches "to" "*" { set "lhs" "${1}"; }
if envelope :domain :matches "to" "*" { set "rhs" "${1}"; }
execute :pipe :output "SCORE" "spamprobe" ["-c", "-d", "/home/u/${rhs}/home/${lhs}/.spamprobe", "receive"];
addheader :last "X-Spam" "${SCORE}";
if header :matches "X-Spam" "SPAM*" { fileinto "Spam"; }

The above works but I am concerned it's fragile and might break when
aliases and CC/BCC are taken into consideration. The "home" directory
is obviously known to LMTP at this point so I was hoping it could be
somehow exposed inside a sieve script?


More information about the dovecot mailing list