[evolution-patches] 69109, no reverse dns, can't send smtp mail




this should fix it in a portable way.

made this a week ago but forgot to mail it out, derr.

--
Michael Zucchi <notzed ximian com>
"Free Software, putting the Free back in Free Market."
Novell's Evolution and Free Software Developer
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2251.2.21
diff -u -p -r1.2251.2.21 ChangeLog
--- camel/ChangeLog	10 Nov 2004 03:56:02 -0000	1.2251.2.21
+++ camel/ChangeLog	10 Nov 2004 07:01:19 -0000
@@ -1,3 +1,13 @@
+2004-11-10  Not Zed  <NotZed Ximian com>
+
+	** See bug #69109.
+	
+	* camel-service.c (cs_getnameinfo): honour the NI_NAMEREQD flag.
+
+	* providers/smtp/camel-smtp-transport.c (smtp_helo): change the
+	nameinfo flags a bit so we know when we got a numeric name and
+	need to wrap it in [].
+
 2004-11-09  Not Zed  <NotZed Ximian com>
 
 	* providers/imap/camel-imap-folder.c (imap_get_message): before
Index: camel/camel-service.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-service.c,v
retrieving revision 1.90.14.4
diff -u -p -r1.90.14.4 camel-service.c
--- camel/camel-service.c	18 Oct 2004 15:24:12 -0000	1.90.14.4
+++ camel/camel-service.c	10 Nov 2004 07:01:19 -0000
@@ -969,13 +969,15 @@ cs_getnameinfo(void *data)
 
 	if (msg->host) {
 		g_free(msg->host);
+		msg->host = NULL;
 		if (msg->result == 0 && h.h_name && h.h_name[0]) {
 			msg->host = g_strdup(h.h_name);
-		} else {
+		} else if ((msg->flags & NI_NAMEREQD) == 0) {
 			unsigned char *in = (unsigned char *)&sin->sin_addr;
 			
 			/* sin_addr is always network order which is big-endian */
 			msg->host = g_strdup_printf("%u.%u.%u.%u", in[0], in[1], in[2], in[3]);
+			msg->result = 0;
 		}
 	}
 
Index: camel/providers/smtp/camel-smtp-transport.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/smtp/camel-smtp-transport.c,v
retrieving revision 1.157.14.4
diff -u -p -r1.157.14.4 camel-smtp-transport.c
--- camel/providers/smtp/camel-smtp-transport.c	13 Oct 2004 01:28:04 -0000	1.157.14.4
+++ camel/providers/smtp/camel-smtp-transport.c	10 Nov 2004 07:01:20 -0000
@@ -885,6 +885,7 @@ smtp_helo (CamelSmtpTransport *transport
 	/* say hello to the server */
 	char *name = NULL, *cmdbuf = NULL, *respbuf = NULL;
 	const char *token;
+	int numeric = FALSE;
 	
 	/* these are flags that we set, so unset them in case we
 	   are being called a second time (ie, after a STARTTLS) */
@@ -900,15 +901,17 @@ smtp_helo (CamelSmtpTransport *transport
 	
 	camel_operation_start_transient (NULL, _("SMTP Greeting"));
 
-	/* this can't really fail with the flags we're using, it should fallback to numerical */
-	if (camel_getnameinfo(transport->localaddr, transport->localaddrlen, &name, NULL, 0, NULL) != 0)
-		name = g_strdup("localhost.localdomain");
+	/* force name resolution first, fallback to numerical, we need to know when it falls back */
+	if (camel_getnameinfo(transport->localaddr, transport->localaddrlen, &name, NULL, NI_NAMEREQD, NULL) != 0) {
+		if (camel_getnameinfo(transport->localaddr, transport->localaddrlen, &name, NULL, NI_NUMERICHOST, NULL) != 0)
+			name = g_strdup("localhost.localdomain");
+		else
+			numeric = TRUE;
+	}
 	
 	/* hiya server! how are you today? */
-	if (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP)
-		cmdbuf = g_strdup_printf ("EHLO %s\r\n", name);
-	else
-		cmdbuf = g_strdup_printf ("HELO %s\r\n", name);
+	token = (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) ? "EHLO" : "HELO";
+	cmdbuf = g_strdup_printf(numeric ? "%s [%s]\r\n" : "%s %s\r\n", token, name);
 	g_free (name);
 	
 	d(fprintf (stderr, "sending : %s", cmdbuf));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]