On Wed, Jan 15, 2014 at 11:48:35 -0500, Chris Nehren wrote:
> On Wed, Jan 15, 2014 at 10:34:41 -0500, Chris Nehren wrote:
> > Ah, thank you for reminding me to report on this. I tried the
> > isync_1_1_branch branch and things build successfully. Thank you!
> 
> The code builds, but when I try it I receive what looks like an
> API usage error:
> 
> IMAP error: Cannot resolve server 'mail.pobox.com': Invalid value
> for ai_flags
> 
> I don't have time to dig into this right now but will try to take
> a look this evening.

I've done some digging into this and have learned that the
culprit on FreeBSD is the AI_V4MAPPED flag. FreeBSD never really
supported this, and it was removed about five years ago. One page
I found on the 'net suggests it was removed due to security
reasons, but I've been unable to substantiate that claim.

In any case, I've patched isync on the isync_1_1_branch branch to
build on FreeBSD by removing the AI_V4MAPPED flag when building
on FreeBSD. Attached is the commit containing this patch. The
commit contains some more information and links to various bits
of detail regarding discussion of this change.

-- 
Chris Nehren
commit 33a091696bf859b329ed2f86835dfdd81fe96702
Author: Chris Nehren <[email protected]>
Date:   Sat Feb 1 15:05:19 2014 -0500

    Fix getaddrinfo() usage on FreeBSD
    
    FreeBSD never really supported AI_V4MAPPED | AI_ADDRCONFIG in
    getaddrinfo(); see e.g.
    http://lists.freebsd.org/pipermail/freebsd-hackers/2008-February/023242.html
    and http://svnweb.freebsd.org/base?view=revision&revision=175955
    for discussion about its incomplete status and its removal.
    Therefore, on FreeBSD, only specify AI_ADDRCONFIG, see e.g.
    https://github.com/zeromq/libzmq/pull/293/files for precedent on
    this.

diff --git a/src/socket.c b/src/socket.c
index 044bd5f..e1834e2 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -349,7 +349,15 @@ socket_connect( conn_t *sock, void (*cb)( int ok, void *aux ) )
 		memset( &hints, 0, sizeof(hints) );
 		hints.ai_family = AF_UNSPEC;
 		hints.ai_socktype = SOCK_STREAM;
+/* 
+   FreeBSD never actually supported this, and in later versions it's
+   an error to specify it.
+*/
+#ifdef __FreeBSD__
+    hints.ai_flags = AI_ADDRCONFIG;
+#else
 		hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;
+#endif
 		infon( "Resolving %s... ", conf->host );
 		if ((gaierr = getaddrinfo( conf->host, NULL, &hints, &sock->addrs ))) {
 			error( "IMAP error: Cannot resolve server '%s': %s\n", conf->host, gai_strerror( gaierr ) );
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to