Re: Cygwin/SASL
I was able to get mutt working this morning. To make it work, I had to
change getnameinfo to sasl_getnameinfo (probably a cygwin-ism).
I'm attaching my patch for anyone else trying to compile mutt with smtp
and sasl for cygwin. Basically, the final problem I had (independent of
sasl) is that mutt could not determine a FQDN for my laptop, and then
sent an:
EHLO @
Which my exim server rejected as being syntactically invalid. In my
patch I special-case this by supplying 'unknown' as the FQDN. For what
its worth, part of the problem here is that the cygwin box does not have
a /etc/resolv.conf, and therefore no backup way to get the domain name.
-Chip
On Tue, Apr 24, 2007 at 11:00:17PM -0700, Charles Killian wrote:
> Has anyone been able to get Mutt to compile under Cygwin with SASL
> enabled?
>
> When I tried, first I got errors about macros which aren't defined by
> netdb.h on Cygwin, such as EAI_AGAIN. So I copied those from a linux
> netdb.h. Then it compiled everything, but on link I get this error:
>
> mutt/mutt_sasl.c:150: undefined reference to `_getnameinfo'
>
> Which I have no idea how to resolve.
>
> Alternately, I tried including w32tcpip.h, which is part of winsock2 on
> cygwin, but this opened a separate can of worms, so I stopped that line
> of work.
>
> For full reference, my prepare line was:
> ./prepare --enable-imap --with-ssl --enable-hcache --with-sasl --enable-smtp
>
> configure completes just fine.
>
> Thanks -
> Chip
>
> --
> ====
> Chip Killian
> http://www.cs.ucsd.edu/~ckillian/
> UCSD Graduate Student, Computer Science
--
====
Chip Killian
http://www.cs.ucsd.edu/~ckillian/
UCSD Graduate Student, Computer Science
diff -r b80be0bc7c03 init.c
diff -r b80be0bc7c03 mutt_sasl.c
--- a/mutt_sasl.c Tue Apr 03 13:19:11 2007 -0700
+++ b/mutt_sasl.c Wed Apr 25 09:40:18 2007 -0700
@@ -22,6 +22,45 @@
# include "config.h"
#endif
+/* Error values for `getaddrinfo' function. */
+# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
+# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
+# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
+# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
+# define EAI_NODATA -5 /* No address associated with NAME. */
+# define EAI_FAMILY -6 /* `ai_family' not supported. */
+# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
+# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
+# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
+# define EAI_MEMORY -10 /* Memory allocation failure. */
+# define EAI_SYSTEM -11 /* System error returned in `errno'. */
+# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
+# ifdef __USE_GNU
+# define EAI_INPROGRESS -100 /* Processing request in progress. */
+# define EAI_CANCELED -101 /* Request canceled. */
+# define EAI_NOTCANCELED -102 /* Request not canceled. */
+# define EAI_ALLDONE -103 /* All requests done. */
+# define EAI_INTR -104 /* Interrupted by a signal. */
+# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
+# endif
+
+# define NI_MAXHOST 1025
+# define NI_MAXSERV 32
+
+# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
+# define NI_NUMERICSERV 2 /* Don't convert port number to name. */
+# define NI_NOFQDN 4 /* Only return nodename portion. */
+# define NI_NAMEREQD 8 /* Don't return numeric addresses. */
+# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
+# ifdef __USE_GNU
+# define NI_IDN 32 /* Convert name from IDN format. */
+# define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode
+ code points. */
+# define NI_IDN_USE_STD3_ASCII_RULES 128 /* Validate strings according to
+ STD3 rules. */
+# endif
+
+
#include "mutt.h"
#include "account.h"
#include "mutt_sasl.h"
@@ -108,7 +147,7 @@ static int iptostring(const struct socka
if(!addr || !out) return SASL_BADPARAM;
- ret=getnameinfo(addr, addrlen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf),
+ ret=sasl_getnameinfo(addr, addrlen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf),
NI_NUMERICHOST |
#ifdef NI_WITHSCOPEID
NI_WITHSCOPEID |
diff -r b80be0bc7c03 smtp.c
--- a/smtp.c Tue Apr 03 13:19:11 2007 -0700
+++ b/smtp.c Wed Apr 25 10:22:15 2007 -0700
@@ -339,7 +339,11 @@ static int smtp_helo (CONNECTION* conn)
#endif
}
- snprintf (buf, sizeof (buf), "%s %s\r\n", Esmtp ? "EHLO" : "HELO", Fqdn);
+ if (Fqdn[0] == '@') {
+ snprintf (buf, sizeof (buf), "%s %s\r\n", Esmtp ? "EHLO" : "HELO",
"unknown");
+ } else {
+ snprintf (buf, sizeof (buf), "%s %s\r\n", Esmtp ? "EHLO" : "HELO", Fqdn);
+ }
/* XXX there should probably be a wrapper in mutt_socket.c that
* repeatedly calls conn->write until all data is sent. This
* currently doesn't check for a short write.