Support client_id variable expansion
Hello,
We are using imap_id_log='*' (and imap_id_retain=yes) to log user client information to the dovecot logs, and this information is aggregated to give us extra debugging information for customer support.
However, as some clients send the ID information pre-login and others send it post-login, the aggregation logic is needlessly complex as we need to correlate the session IDs of the pre-login ID messages in order to determine the correct user.
Hoping to simplify this, I wanted to log the client_id variable on logout, in imap_logout_format:
imap_logout_format = in=%i out=%o deleted=%{deleted} expunged=%{expunged} trashed=%{trashed} hdr_count=%{fetch_hdr_count} hdr_bytes=%{fetch_hdr_bytes} body_count=%{fetch_body_count} body_bytes=%{fetch_body_bytes} client_id="%{client_id}"
However, this only results in the following log being printed:
client_id="UNSUPPORTED_VARIABLE_client_id"
While examining the source code (login-common/client-common.c), it seems like this could be trivially supported by adding client_id
to the login_var_expand_empty_tab
struct, and adding the relevant code to populate this variable to get_var_expand_table(struct client *client)
.
I am willing to write a pull request for this, unless I am missing some obvious reason why expansion of the client's client_id
field is not supported in the first place?
- Eirik
On 02/06/2021 17:45 Eirik Rye rye@trojka.no wrote:
Hello,
We are using imap_id_log='*' (and imap_id_retain=yes) to log user client information to the dovecot logs, and this information is aggregated to give us extra debugging information for customer support.
However, as some clients send the ID information pre-login and others send it post-login, the aggregation logic is needlessly complex as we need to correlate the session IDs of the pre-login ID messages in order to determine the correct user.
Hoping to simplify this, I wanted to log the client_id variable on logout, in imap_logout_format:
imap_logout_format = in=%i out=%o deleted=%{deleted} expunged=%{expunged} trashed=%{trashed} hdr_count=%{fetch_hdr_count} hdr_bytes=%{fetch_hdr_bytes} body_count=%{fetch_body_count} body_bytes=%{fetch_body_bytes} client_id="%{client_id}"
However, this only results in the following log being printed:
client_id="UNSUPPORTED_VARIABLE_client_id"
While examining the source code (login-common/client-common.c), it seems like this could be trivially supported by adding
client_id
to thelogin_var_expand_empty_tab
struct, and adding the relevant code to populate this variable toget_var_expand_table(struct client *client)
.I am willing to write a pull request for this, unless I am missing some obvious reason why expansion of the client's
client_id
field is not supported in the first place?
- Eirik
Hi!
To use client_id like that you'd need to export it to imap process first. You can try exporting it with userdb_client_id=%{client_id} in your passwd-file, then it will be available as %{client_id} in your imap process.
In non-passwd-file userdb, you can use just client_id=%{client_id}
Aki
participants (2)
-
Aki Tuomi
-
Eirik Rye