last_login plugin with MySQL
Gedalya
gedalya at gedalya.net
Sat Oct 18 15:36:48 UTC 2014
On 10/18/2014 10:37 AM, Luigi Rosa wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Gedalya wrote on 18/10/2014 16:10:
>
>> I guess you have to use the proxy.
>>
>> So maybe something like
>>
>> plugin { last_login_dict = proxy::lastlogin }
>>
>> dict { lastlogin = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext }
>>
>> I'll try it later myself, thanks for taking it thus far :-) I've been
>> meaning to try this out but was rather perplexed.
> I made some progress thank to your suggestions.
>
> dovecot-dict-sql.conf.ext content is:
>
> map {
> pattern = /shared/last-login/$user
> table = mailbox
> username_field = username
> value_field = lastlogin
> fields {
> username = $user
> }
> }
>
> Note that you must not specify "driver" parameter
>
>
> Plugin is defined this way:
>
>
> plugin {
> last_login_dict = proxy::lastlogin
> last_login_key = last-login/%u # default
> }
>
> dict {
> lastlogin = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
> mode = 0660
> user = 501
> }
>
>
> But I get two errors.
>
>
> First is the permission of /var/run/dovecot/dict that is 700 root.root and I
> get a permission error. Nothing changes if I put user = root. I have to
> manually chmod /var/run/dovecot/dict every time I restart Dovecot otherwise I get
>
> Error: net_connect_unix(/var/run/dovecot//dict) failed: Permission denied
> (euid=501(mailvirtuale) egid=501(mailvirtuale) missing +r perm:
> /var/run/dovecot//dict, dir owned by 0:0 mode=0755)
>
> If I chmod 777 /var/run/dovecot/dict the error disappears but I get this:
>
> dovecot: imap-login: Login: user=<username>, method=PLAIN, rip=127.0.0.1,
> lip=127.0.0.1, mpid=497913, secured, session=<6R0mYbMFFwB/AAAB>
> dovecot: dict: Error: sql dict set: Invalid/unmapped key:
> shared/last-login/username
>
>
>
OK I got it.
The code looks at shared/$last_login_key, so shared/last-login/username,
but your map says /shared/last-login/$user, note the leading slash!
That's probably all it is.
More information about the dovecot
mailing list