From: Timo Sirainen Date: Mon, 21 Feb 2022 11:39:02 +0000 (+0100) Subject: lib: Fix losing log prefix or IP change when log process is busy X-Git-Tag: 2.4.0~4387 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6cd6732f3f0c4b149c7174decd46a40c4183a91d;p=thirdparty%2Fdovecot%2Fcore.git lib: Fix losing log prefix or IP change when log process is busy The fd for writing to log process is non-blocking. When sending options to log process, it was done with write_full(), which stopped whenever EAGAIN was returned. This error was simply ignored, and the logging code thought that the prefix was successfully changed (or the IP was sent). This mainly caused a problem when processes were reused and log process was busy. The prefix update could have failed, and the following logging would be using the previous session's log prefix, i.e. log lines could have been logged for the wrong user/session. Broken by 9372e48b702a3af5705785e08fbf47b0e37f2047 --- diff --git a/src/lib/failures.c b/src/lib/failures.c index d3d0002f5f..e98a749db4 100644 --- a/src/lib/failures.c +++ b/src/lib/failures.c @@ -724,7 +724,8 @@ static void i_failure_send_option_forced(const char *key, const char *value) 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)); + (void)log_fd_write(STDERR_FILENO, (const unsigned char *)str, + strlen(str)); } static void i_failure_send_option(const char *key, const char *value)