From: Josef 'Jeff' Sipek Date: Thu, 17 Sep 2020 19:42:52 +0000 (-0400) Subject: login-common: Move common client info logging into a helper function X-Git-Tag: 2.3.13~135 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c066b7d60da3f857d99f9db501d5565c8cbba680;p=thirdparty%2Fdovecot%2Fcore.git login-common: Move common client info logging into a helper function --- diff --git a/src/login-common/client-common-auth.c b/src/login-common/client-common-auth.c index 4c1dcf92da..3328d0df1c 100644 --- a/src/login-common/client-common-auth.c +++ b/src/login-common/client-common-auth.c @@ -262,6 +262,16 @@ static void proxy_free_password(struct client *client) i_free_and_null(client->proxy_password); } +static void client_proxy_append_conn_info(string_t *str, struct client *client) +{ + if (strcmp(client->virtual_user, client->proxy_user) != 0) { + /* remote username is different, log it */ + str_printfa(str, " as user %s", client->proxy_user); + } + if (client->proxy_master_user != NULL) + str_printfa(str, " (master %s)", client->proxy_master_user); +} + void client_proxy_finish_destroy_client(struct client *client) { string_t *str = t_str_new(128); @@ -279,12 +289,7 @@ void client_proxy_finish_destroy_client(struct client *client) IP address in the prefix. */ str_printfa(str, "Started proxying to %s", login_proxy_get_host(client->login_proxy)); - if (strcmp(client->virtual_user, client->proxy_user) != 0) { - /* remote username is different, log it */ - str_printfa(str, " as user %s", client->proxy_user); - } - if (client->proxy_master_user != NULL) - str_printfa(str, " (master %s)", client->proxy_master_user); + client_proxy_append_conn_info(str, client); login_proxy_append_success_log_info(client->login_proxy, str); e_info(login_proxy_get_event(client->login_proxy), "%s", str_c(str)); @@ -302,12 +307,7 @@ void client_proxy_log_failure(struct client *client, const char *line) string_t *str = t_str_new(128); str_printfa(str, "Login failed"); - if (strcmp(client->virtual_user, client->proxy_user) != 0) { - /* remote username is different, log it */ - str_printfa(str, " as user %s", client->proxy_user); - } - if (client->proxy_master_user != NULL) - str_printfa(str, " (master %s)", client->proxy_master_user); + client_proxy_append_conn_info(str, client); str_append(str, ": "); str_append(str, line); e_info(login_proxy_get_event(client->login_proxy), "%s", str_c(str));