]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Fix log prefix in internal handler when log handler has been overridden
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 14 Jun 2021 18:14:13 +0000 (20:14 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 2 Jul 2021 08:41:47 +0000 (08:41 +0000)
Adds back mail_log_prefix to doveadm mail commands when doveadm-server was
accessed via TCP.

Originally broken by c9dd53f7180a78668cbc1e6eb34d5b1722beccb9

src/lib/failures.c

index ab9470029676553ed064a728222d271f59050bf5..3364da6a331e733c49879e3c93b7c5b925c1847d 100644 (file)
@@ -61,7 +61,7 @@ static bool failure_ignore_errors = FALSE, log_prefix_sent = FALSE;
 static bool coredump_on_error = FALSE;
 static void log_timestamp_add(const struct failure_context *ctx, string_t *str);
 static void log_prefix_add(const struct failure_context *ctx, string_t *str);
-static void i_failure_send_option(const char *key, const char *value);
+static void i_failure_send_option_forced(const char *key, const char *value);
 static int internal_send_split(string_t *full_str, size_t prefix_len);
 
 static string_t * ATTR_FORMAT(3, 0) default_format(const struct failure_context *ctx,
@@ -192,7 +192,7 @@ static string_t * ATTR_FORMAT(3, 0) internal_format(const struct failure_context
                        log_type |= LOG_TYPE_FLAG_PREFIX_LEN;
        } else if (!log_prefix_sent && log_prefix != NULL) {
                log_prefix_sent = TRUE;
-               i_failure_send_option("prefix", log_prefix);
+               i_failure_send_option_forced("prefix", log_prefix);
        }
 
        str = t_str_new(128);
@@ -720,18 +720,21 @@ void i_set_failure_file(const char *path, const char *prefix)
        i_set_debug_handler(default_error_handler);
 }
 
-static void i_failure_send_option(const char *key, const char *value)
+static void i_failure_send_option_forced(const char *key, const char *value)
 {
        const char *str;
 
-       if (error_handler != i_internal_error_handler)
-               return;
-
        str = t_strdup_printf("\001%c%s %s=%s\n", LOG_TYPE_OPTION+1,
                              my_pid, key, value);
        (void)write_full(STDERR_FILENO, str, strlen(str));
 }
 
+static void i_failure_send_option(const char *key, const char *value)
+{
+       if (error_handler == i_internal_error_handler)
+               i_failure_send_option_forced(key, value);
+}
+
 void i_set_failure_prefix(const char *prefix_fmt, ...)
 {
        va_list args;