]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Proxy: Log destuser in the "proxying" line if it's different from username.
authorTimo Sirainen <tss@iki.fi>
Thu, 14 Aug 2008 07:10:34 +0000 (03:10 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 14 Aug 2008 07:10:34 +0000 (03:10 -0400)
--HG--
branch : HEAD

src/imap-login/imap-proxy.c
src/pop3-login/pop3-proxy.c

index b38e24da243066c88f77ad8012b10c963e33256a..104e38fd9e8d6635a6a8fa61a9419c2e521f65ca 100644 (file)
@@ -50,7 +50,6 @@ static int proxy_input_line(struct imap_client *client,
                            struct ostream *output, const char *line)
 {
        string_t *str;
-       const char *msg;
 
        i_assert(!client->destroyed);
 
@@ -91,10 +90,17 @@ static int proxy_input_line(struct imap_client *client,
                (void)o_stream_send(client->output,
                                    str_data(str), str_len(str));
 
-               msg = t_strdup_printf("proxy(%s): started proxying to %s:%u",
-                                     client->common.virtual_user,
-                                     login_proxy_get_host(client->proxy),
-                                     login_proxy_get_port(client->proxy));
+               str_truncate(str, 0);
+               str_printfa(str, "proxy(%s): started proxying to %s:%u",
+                           client->common.virtual_user,
+                           login_proxy_get_host(client->proxy),
+                           login_proxy_get_port(client->proxy));
+               if (strcmp(client->common.virtual_user,
+                          client->proxy_user) != 0) {
+                       /* remote username is different, log it */
+                       str_append_c(str, '/');
+                       str_append(str, client->proxy_user);
+               }
 
                (void)client_skip_line(client);
                login_proxy_detach(client->proxy, client->common.input,
@@ -104,7 +110,7 @@ static int proxy_input_line(struct imap_client *client,
                client->common.input = NULL;
                client->output = NULL;
                client->common.fd = -1;
-               client_destroy_success(client, msg);
+               client_destroy_success(client, str_c(str));
                return -1;
        } else if (strncmp(line, "P ", 2) == 0) {
                /* If the backend server isn't Dovecot, the error message may
index 30a68c16b4637a8892a9a4997b0fdfd447640b3c..061cc31b83f9cc96992513c50a9cbfe94e742f89 100644 (file)
@@ -15,7 +15,7 @@ static void proxy_input(struct istream *input, struct ostream *output,
                        struct pop3_client *client)
 {
        string_t *str;
-       const char *line, *msg;
+       const char *line;
 
        if (input == NULL) {
                if (client->io != NULL) {
@@ -102,10 +102,17 @@ static void proxy_input(struct istream *input, struct ostream *output,
                line = t_strconcat(line, "\r\n", NULL);
                (void)o_stream_send_str(client->output, line);
 
-               msg = t_strdup_printf("proxy(%s): started proxying to %s:%u",
-                                     client->common.virtual_user,
-                                     login_proxy_get_host(client->proxy),
-                                     login_proxy_get_port(client->proxy));
+               str = t_str_new(128);
+               str_printfa(str, "proxy(%s): started proxying to %s:%u",
+                           client->common.virtual_user,
+                           login_proxy_get_host(client->proxy),
+                           login_proxy_get_port(client->proxy));
+               if (strcmp(client->common.virtual_user,
+                          client->proxy_user) != 0) {
+                       /* remote username is different, log it */
+                       str_append_c(str, '/');
+                       str_append(str, client->proxy_user);
+               }
 
                login_proxy_detach(client->proxy, client->common.input,
                                   client->output);
@@ -114,7 +121,7 @@ static void proxy_input(struct istream *input, struct ostream *output,
                client->common.input = NULL;
                client->output = NULL;
                client->common.fd = -1;
-               client_destroy_success(client, msg);
+               client_destroy_success(client, str_c(str));
                return;
        }