On 10/15/20 10:13 PM, Aki Tuomi wrote:
I'm asking how/where to 'tell', via config, Dovecot's smtp-CLIENT, that's making to connection to the submission_relay_host, to use _only_ IPv4.
There is currently no (other) way to do this than using /etc/hosts or specifying IPv4 address for the relay host.
just a quick look, but looks like the culprit here is the submission code call to "net_addr2ip()"
src/submission/main.c (c)
...
193 static void main_stdio_run(const char *username) { struct mail_storage_service_input input; buffer_t *input_buf; const char *value, *error, *input_base64;
i_zero(&input);
input.module = input.service = "submission";
input.username = username != NULL ? username : getenv("USER");
if (input.username == NULL && IS_STANDALONE())
input.username = getlogin();
if (input.username == NULL)
i_fatal("USER environment missing");
if ((value = getenv("IP")) != NULL)
!!! (void)net_addr2ip(value, &input.remote_ip); if ((value = getenv("LOCAL_IP")) != NULL) (void)net_addr2ip(value, &input.local_ip);
input_base64 = getenv("CLIENT_INPUT");
input_buf = input_base64 == NULL ? NULL :
t_base64_decode_str(input_base64);
if (client_create_from_input(&input, STDIN_FILENO, STDOUT_FILENO,
input_buf, &error) < 0)
i_fatal("%s", error);
}
...
which includes ipv6-first code,
./src/lib/net.c
...
932 int net_addr2ip(const char *addr, struct ip_addr *ip) { int ret;
if (net_addr2ip_inet4_fast(addr, ip))
return 0;
if (strchr(addr, ':') != NULL) {
!!! /* IPv6 */ T_BEGIN { if (addr[0] == '[') { /* allow [ipv6 addr] */ size_t len = strlen(addr); if (addr[len-1] == ']') addr = t_strndup(addr+1, len-2); } ret = inet_pton(AF_INET6, addr, &ip->u.ip6); } T_END; if (ret == 0) return -1; ip->family = AF_INET6; } else { /* IPv4 */ if (inet_aton(addr, &ip->u.ip4) == 0) return -1; ip->family = AF_INET; } return 0; } ...
adding a config param, e.g.,
submission_relay_ip_family = {any:inet6:inet4}
and wrapping the "src/lib/net.c" stanza, above, in 'if' conditionals based on its value should, iiuc, sufficiently instruct Dovecot to relay-submit over the intended AF.
and stop causing the 'failed connect' error noise in logs.