X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/1e1ddfac79fbcd052f199500a6493c7f79cb8462..a85c067ba6c6940512cf57ec213277a370d87e70:/src/src/auths/dovecot.c diff --git a/src/src/auths/dovecot.c b/src/src/auths/dovecot.c index 3331cb856..ed56ab8cd 100644 --- a/src/src/auths/dovecot.c +++ b/src/src/auths/dovecot.c @@ -1,6 +1,7 @@ /* + * Copyright (c) The Exim Maintainers 2006 - 2022 * Copyright (c) 2004 Andrey Panin - * Copyright (c) 2006-2020 The Exim Maintainers + * SPDX-License-Identifier: GPL-2.0-or-later * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -275,11 +276,20 @@ if (cctx.sock < 0) # ifndef DISABLE_TLS if (ob->server_tls) { - uschar * s; + union sockaddr_46 interface_sock; + EXIM_SOCKLEN_T size = sizeof(interface_sock); smtp_connect_args conn_args = { .host = &host }; - tls_support tls_dummy = {.sni=NULL}; + tls_support tls_dummy = { .sni = NULL }; uschar * errstr; + if (getsockname(cctx->sock, (struct sockaddr *) &interface_sock, &size) == 0) + conn_args.sending_ip_address = host_ntoa(-1, &interface_sock, NULL, NULL); + else + { + *errmsg = string_sprintf("getsockname failed: %s", strerror(errno)); + goto bad; + } + if (!tls_client_start(&cctx, &conn_args, NULL, &tls_dummy, &errstr)) { auth_defer_msg = string_sprintf("TLS connect failed: %s", errstr);