[Dovecot] Executing SQL update upon login

Tom Sommer mail at tomsommer.dk
Tue Oct 10 15:44:00 UTC 2006


On Tue, October 10, 2006 16:02, Timo Sirainen wrote:
> On 10.10.2006, at 16.31, /dev/rob0 wrote:
>
>
>> On Tuesday 10 October 2006 05:51, Tom Sommer wrote:
>>
>>>>> anyone had any ideas as to how I could run an UPDATE statement
>>>>> upon each login, to set time of last login (and other interesting
>>>>>  stuff) in the database table.
>>>>
>>>> Set mail_executable to point to a script:
>>>>
>>>>
>>>> #!/bin/sh
>>>> echo "update blah where user = '$USER'" | mysql .. exec
>>>> /usr/local/libexec/dovecot/imap
>>>>
>>>
>>> Won't the overhead on that be pretty high? Considerings it now has
>>> to wrap the imap command in to a script.
>>
>> I doubt overhead would be much of a problem, since all the shells will
>> use shared memory. The problem I see is that at the time you're running
>> the update, you have not yet authenticated the user, so your data could
>> be unreliable.
>
> No, mail_executable is run only after a successful authentication.

Would it not be better to add a on_login_query which allowed access to a
list of variables, IP address, username, password etc.

on_login_query = UPDATE users SET last_login = NOW(), last_ip = %i WHERE
user = %u




More information about the dovecot mailing list