[Dovecot] Best way to get login protocol (pop3/imap) in post-login script

Timo Sirainen tss at iki.fi
Mon Aug 3 04:47:54 EEST 2009


On Sun, 2009-08-02 at 10:51 +0800, Zhang Huangbin wrote:
> Hi, all.
> 
> I found doc here: http://wiki.dovecot.org/PostLoginScripting
> and use ${USER}, ${IP} to track last-login username and remote ip  
> address, but how can i track the mail protocol it used? like pop3,  
> pop3s, imap, imaps?

How about giving the imap or pop3 as parameter? You're already modifying
mail_executable, so:

protocol imap {
  mail_executable = script.sh imap
}
protocol pop3 {
  mail_executable = script.sh pop3
}

As for separating imap from imaps.. What about STARTTLS? If you just
want to know if SSL/TLS was used vs. not used, then.. Well, that
information is kind of lost already at that point. Although you could
have your userdb return an extra field with that state.

For example let's say you're using static userdb, you can use:

userdb static {
  args = ... secured=%c
}

And then you'll have "SECURED=secured" environment. Although %c also
returns "secured" with localhost connections.
http://wiki.dovecot.org/Variables

The same way you could also set service=%s to avoid giving the imap/pop3
parameter.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://dovecot.org/pipermail/dovecot/attachments/20090802/96cca7e1/attachment.bin 


More information about the dovecot mailing list