]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: Move common client info logging into a helper function
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Thu, 17 Sep 2020 19:42:52 +0000 (15:42 -0400)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 7 Oct 2020 11:46:54 +0000 (11:46 +0000)
src/login-common/client-common-auth.c

index 4c1dcf92dac94c8ac8dad895a9cfdfa7feeb4b7f..3328d0df1ca97657ff141698571f3e286f8d8388 100644 (file)
@@ -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));