On 30/09/2024 15:49, Maciej Polewczyński via dovecot wrote:
When using the last_login plugin I noticed that the IP address information is not updated. If there is no entry in the sql database for a given user, the first time the login date and time information and the IP address will be saved. Each subsequent login only updates the date and time. The IP address remains unchanged.
Example configuration for pop3 service:
map { pattern = shared/last-login/pop3/$user/$rip table = last_login value_field = last_pop3_access value_type = uint
fields { userid = $user last_pop3_ip = $rip } }
This is translated into the following sql command:
INSERT INTO last_login (last_pop3_access,userid,last_pop3_ip) VALUES (1727691183673,'test','1.2.3.4') ON DUPLICATE KEY UPDATE last_pop3_access=1727691183673
You can see that after "ON DUPLICATE KEY" only the time is updated.
Is there any way to influence the behavior of the plugin and the sql query so that the IP address is also updated? I'm using Dovecot v2.3.4
One solution to this would be to redefine the primary key so that it is composed from multiple columns userid + last_pop3_id. That way you would get a row inserted per userid and pop3_ip combination and the timestamp would be the last time that userid and pop3_ip logged in.
John