- fl.rcpt_in_progress = FALSE;
- }
-
-/* Now write the string */
-
-#ifdef SUPPORT_TLS
-if (tls_in.active.sock >= 0)
- {
- if (tls_write(NULL, big_buffer, Ustrlen(big_buffer), more) < 0)
- smtp_write_error = -1;
- }
-else
-#endif
-
-if (fprintf(smtp_out, "%s", big_buffer) < 0) smtp_write_error = -1;
-}
-
-
-
-/*************************************************
-* Flush SMTP out and check for error *
-*************************************************/
-
-/* This function isn't currently used within Exim (it detects errors when it
-tries to read the next SMTP input), but is available for use in local_scan().
-For non-TLS connections, it flushes the output and checks for errors. For
-TLS-connections, it checks for a previously-detected TLS write error.
-
-Arguments: none
-Returns: 0 for no error; -1 after an error
-*/
-
-int
-smtp_fflush(void)
-{
-if (tls_in.active.sock < 0 && fflush(smtp_out) != 0) smtp_write_error = -1;
-return smtp_write_error;
-}
-
-
-
-/*************************************************
-* SMTP command read timeout *
-*************************************************/
-
-/* Signal handler for timing out incoming SMTP commands. This attempts to
-finish off tidily.
-
-Argument: signal number (SIGALRM)
-Returns: nothing
-*/
-
-static void
-command_timeout_handler(int sig)
-{
-had_command_timeout = sig;
-}
-
-
-
-/*************************************************
-* SIGTERM received *
-*************************************************/
-
-/* Signal handler for handling SIGTERM. Again, try to finish tidily.
-
-Argument: signal number (SIGTERM)
-Returns: nothing
-*/
-
-static void
-command_sigterm_handler(int sig)
-{
-had_command_sigterm = sig;
-}
-
-
-
-
-#ifdef SUPPORT_PROXY
-/*************************************************
-* Restore socket timeout to previous value *
-*************************************************/
-/* If the previous value was successfully retrieved, restore
-it before returning control to the non-proxy routines
-
-Arguments: fd - File descriptor for input
- get_ok - Successfully retrieved previous values
- tvtmp - Time struct with previous values
- vslen - Length of time struct
-Returns: none
-*/
-static void
-restore_socket_timeout(int fd, int get_ok, struct timeval * tvtmp, socklen_t vslen)
-{
-if (get_ok == 0)
- (void) setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, CS tvtmp, vslen);
-}
-
-/*************************************************
-* Check if host is required proxy host *
-*************************************************/
-/* The function determines if inbound host will be a regular smtp host
-or if it is configured that it must use Proxy Protocol. A local
-connection cannot.
-
-Arguments: none
-Returns: bool
-*/
-
-static BOOL
-check_proxy_protocol_host()
-{
-int rc;
-
-if ( sender_host_address
- && (rc = verify_check_this_host(CUSS &hosts_proxy, NULL, NULL,
- sender_host_address, NULL)) == OK)
- {
- DEBUG(D_receive)
- debug_printf("Detected proxy protocol configured host\n");
- proxy_session = TRUE;
- }
-return proxy_session;
-}
-
-
-/*************************************************
-* Read data until newline or end of buffer *
-*************************************************/
-/* While SMTP is server-speaks-first, TLS is client-speaks-first, so we can't
-read an entire buffer and assume there will be nothing past a proxy protocol
-header. Our approach normally is to use stdio, but again that relies upon
-"STARTTLS\r\n" and a server response before the client starts TLS handshake, or
-reading _nothing_ before client TLS handshake. So we don't want to use the
-usual buffering reads which may read enough to block TLS starting.
-
-So unfortunately we're down to "read one byte at a time, with a syscall each,
-and expect a little overhead", for all proxy-opened connections which are v1,
-just to handle the TLS-on-connect case. Since SSL functions wrap the
-underlying fd, we can't assume that we can feed them any already-read content.
-
-We need to know where to read to, the max capacity, and we'll read until we
-get a CR and one more character. Let the caller scream if it's CR+!LF.
-
-Return the amount read.
-*/
-
-static int
-swallow_until_crlf(int fd, uschar *base, int already, int capacity)
-{
-uschar *to = base + already;
-uschar *cr;
-int have = 0;
-int ret;
-int last = 0;
-
-/* For "PROXY UNKNOWN\r\n" we, at time of writing, expect to have read
-up through the \r; for the _normal_ case, we haven't yet seen the \r. */
-
-cr = memchr(base, '\r', already);
-if (cr != NULL)
- {
- if ((cr - base) < already - 1)
- {
- /* \r and presumed \n already within what we have; probably not
- actually proxy protocol, but abort cleanly. */
- return 0;
- }
- /* \r is last character read, just need one more. */
- last = 1;