On 01/06/2023 10:24 EEST Eirik Rye <rye@trojka.no> wrote:
Hello,
In my setup, I am running dovecot with the following last_login config:
plugin { last_login_dict = file:~/.last_login last_login_key = %s }
I would like to distinguish between logins through webmail (Roundcube) and logins through regular IMAP clients. Roundcube sends "x-forward-service=webmail" in ID, and I have working logging for this by putting the following in login_log_format_elements:
service=%{if;%{passdb:forward_service};eq;webmail;webmail;%s}
(Is there may be a more elegant way to do this conditional?)
This will print
service=webmail
for webmail logins, andservice=imap
for regular IMAP client logins.However, the same conditional does not work in last_login_key:
last_login_key = %{if;%{passdb:forward_service};eq;webmail;webmail;%s}
Using this, the login fails and the error log outputs the following error:
Error: Failed to expand plugin setting last_login_key = '%{if;%{passdb:forward_service};eq;webmail;webmail;%s}': Unknown variable '%passdb'
How can I tell which variables are available to use in this plugin? Are the forwarded variables not available? If not, any other suggestions on how to differentiate these logins in last_login? Looking at the remote_ip is not feasible for my setup.
Best regards, Eirik
You can't use passdb variables in mail session.
userdb_some_service=%{passdb:forward_service} in your passdb.
and then you can use %{some_service} in your last_login_key.
please note that %{service} itself is a reserved key.
Aki