doveadm mailbox command fails if backend has an IPv6 address

Andreas Jobs andreas.jobs at ruhr-uni-bochum.de
Mon Jan 15 23:28:29 EET 2018


Hi,

some of my maintenance scripts weren't working as expected and I finally
found that this only happens if the user was mapped to a backend server
reachable via IPv6:

On a director:
doveadm mailbox status -u username messages Junk

returns

Junk messages=203  (if backend is connected via IPv4)
or
Lookup of host ipv6addr:542 failed: ... (if backend is connected via IPv6)

doveadm_tcp_connect_port tried a net_gethostbyname with "ipv6addr:542"
as hostname. 

I've attached a quick-and-dirty-patch (for 2.2.33.2) that fixes this (at
least for me).


Regards,

Andreas
-- 
! Andreas Jobs                                  Network Operation Center !
!                                               Ruhr-Universitaet Bochum !
! One Day I Will Find This Peer Guy and Then I Will Reset HIS Connection !
-------------- next part --------------
--- dovecot-2.2.33.2/src/doveadm/doveadm-mail-server.c.orig	2017-10-05 19:09:55.000000000 +0200
+++ dovecot-2.2.33.2/src/doveadm/doveadm-mail-server.c	2018-01-15 21:59:08.897161000 +0100
@@ -249,7 +249,10 @@
 			}
 			ret = -1;
 		} else {
-			*host_r = t_strdup_printf("%s:%u", proxy_host, proxy_port);
+			if (is_ipv6_address(proxy_host) && *proxy_host != '[')
+				*host_r = t_strdup_printf("[%s]:%u", proxy_host, proxy_port);
+			else
+				*host_r = t_strdup_printf("%s:%u", proxy_host, proxy_port);
 		}
 	}
 	pool_unref(&pool);


More information about the dovecot mailing list