summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/doc-txt/ChangeLog14
-rw-r--r--src/src/filter.c15
-rw-r--r--src/src/host.c107
3 files changed, 83 insertions, 53 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index b9ddc75d2..a938e2643 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.253 2005/11/10 15:00:46 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.254 2005/11/11 10:02:04 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -52,6 +52,18 @@ PH/05 When a filter generated an autoreply, the entire To: header line was
=> >ano@some.domain,ona@other.domain <original@ddress> ...
+PH/06 When a client host used a correct literal IP address in a HELO or EHLO
+ command, (for example, EHLO [1.2.3.4]) and the client's IP address was
+ not being looked up in the rDNS to get a host name, Exim was showing the
+ IP address twice in Received: lines, even though the IP addresses were
+ identical. For example:
+
+ Received: from [1.2.3.4] (helo=[1.2.3.4])
+
+ However, if the real host name was known, it was omitting the HELO data
+ if it matched the actual IP address. This has been tidied up so that it
+ doesn't show the same IP address twice.
+
Exim version 4.54
-----------------
diff --git a/src/src/filter.c b/src/src/filter.c
index e551abef8..1773a8f2f 100644
--- a/src/src/filter.c
+++ b/src/src/filter.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/filter.c,v 1.6 2005/11/10 15:00:46 ph10 Exp $ */
+/* $Cambridge: exim/src/src/filter.c,v 1.7 2005/11/11 10:02:04 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -2240,9 +2240,10 @@ while (commands != NULL)
}
/* Create the "address" for the autoreply. This is used only for logging,
- as the actual recipients are extraced from the To: line by -t. We use the
+ as the actual recipients are extracted from the To: line by -t. We use the
same logic here to extract the working addresses (there may be more than
- one). */
+ one). Just in case there are a vast number of addresses, stop when the
+ string gets too long. */
tt = to;
while (*tt != 0)
@@ -2268,6 +2269,14 @@ while (commands != NULL)
Ustrlen(recipient));
}
+ /* Check size */
+
+ if (ptr > 256)
+ {
+ log_addr = string_cat(log_addr, &size, &ptr, US", ...", 5);
+ break;
+ }
+
/* Move on past this address */
tt = ss + (*ss? 1:0);
diff --git a/src/src/host.c b/src/src/host.c
index 1e18940e9..f3652c309 100644
--- a/src/src/host.c
+++ b/src/src/host.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/host.c,v 1.16 2005/10/03 09:51:04 ph10 Exp $ */
+/* $Cambridge: exim/src/src/host.c,v 1.17 2005/11/11 10:02:04 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -535,8 +535,9 @@ as follows:
(a) No sender_host_name or sender_helo_name: "[ip address]"
(b) Just sender_host_name: "host_name [ip address]"
-(c) Just sender_helo_name: "(helo_name) [ip address]"
-(d) The two are identical: "host_name [ip address]"
+(c) Just sender_helo_name: "(helo_name) [ip address]" unless helo is IP
+ in which case: "[ip address}"
+(d) The two are identical: "host_name [ip address]" includes helo = IP
(e) The two are different: "host_name (helo_name) [ip address]"
If log_incoming_port is set, the sending host's port number is added to the IP
@@ -557,7 +558,9 @@ Returns: nothing
void
host_build_sender_fullhost(void)
{
+BOOL show_helo = TRUE;
uschar *address;
+int len;
int old_pool = store_pool;
if (sender_host_address == NULL) return;
@@ -573,6 +576,43 @@ address = string_sprintf("[%s]:%d", sender_host_address, sender_host_port);
if ((log_extra_selector & LX_incoming_port) == 0 || sender_host_port <= 0)
*(Ustrrchr(address, ':')) = 0;
+/* If there's no EHLO/HELO data, we can't show it. */
+
+if (sender_helo_name == NULL) show_helo = FALSE;
+
+/* If HELO/EHLO was followed by an IP literal, it's messy because of two
+features of IPv6. Firstly, there's the "IPv6:" prefix (Exim is liberal and
+doesn't require this, for historical reasons). Secondly, IPv6 addresses may not
+be given in canonical form, so we have to canonicize them before comparing. As
+it happens, the code works for both IPv4 and IPv6. */
+
+else if (sender_helo_name[0] == '[' &&
+ sender_helo_name[(len=Ustrlen(sender_helo_name))-1] == ']')
+ {
+ int offset = 1;
+ uschar *helo_ip;
+
+ if (strncmpic(sender_helo_name + 1, US"IPv6:", 5) == 0) offset += 5;
+ if (strncmpic(sender_helo_name + 1, US"IPv4:", 5) == 0) offset += 5;
+
+ helo_ip = string_copyn(sender_helo_name + offset, len - offset - 1);
+
+ if (string_is_ip_address(helo_ip, NULL) != 0)
+ {
+ int x[4], y[4];
+ int sizex, sizey;
+ uschar ipx[48], ipy[48]; /* large enough for full IPv6 */
+
+ sizex = host_aton(helo_ip, x);
+ sizey = host_aton(sender_host_address, y);
+
+ (void)host_nmtoa(sizex, x, -1, ipx, ':');
+ (void)host_nmtoa(sizey, y, -1, ipy, ':');
+
+ if (strcmpic(ipx, ipy) == 0) show_helo = FALSE;
+ }
+ }
+
/* Host name is not verified */
if (sender_host_name == NULL)
@@ -588,7 +628,7 @@ if (sender_host_name == NULL)
sender_rcvhost = string_cat(NULL, &size, &ptr, address, adlen);
- if (sender_ident != NULL || sender_helo_name != NULL || portptr != NULL)
+ if (sender_ident != NULL || show_helo || portptr != NULL)
{
int firstptr;
sender_rcvhost = string_cat(sender_rcvhost, &size, &ptr, US" (", 2);
@@ -598,7 +638,7 @@ if (sender_host_name == NULL)
sender_rcvhost = string_append(sender_rcvhost, &size, &ptr, 2, US"port=",
portptr + 1);
- if (sender_helo_name != NULL)
+ if (show_helo)
sender_rcvhost = string_append(sender_rcvhost, &size, &ptr, 2,
(firstptr == ptr)? US"helo=" : US" helo=", sender_helo_name);
@@ -617,54 +657,15 @@ if (sender_host_name == NULL)
store_reset(sender_rcvhost + ptr + 1);
}
-/* Host name is known and verified. */
+/* Host name is known and verified. Unless we've already found that the HELO
+data matches the IP address, compare it with the name. */
else
{
- int len;
- BOOL no_helo = FALSE;
-
- /* Comparing a HELO name to a host name is easy */
+ if (show_helo && strcmpic(sender_host_name, sender_helo_name) == 0)
+ show_helo = FALSE;
- if (sender_helo_name == NULL ||
- strcmpic(sender_host_name, sender_helo_name) == 0)
- no_helo = TRUE;
-
- /* If HELO/EHLO was followed by an IP literal, it's much more messy because
- of two features of IPv6. Firstly, there's the "IPv6:" prefix (Exim is liberal
- and doesn't require this, for historical reasons). Secondly, an IPv6 address
- may not be given in canonical form, so we have to canonicize it before
- comparing. As it happens, the code works for both IPv4 and IPv6. */
-
- else if (sender_helo_name[0] == '[' &&
- sender_helo_name[(len=Ustrlen(sender_helo_name))-1] == ']')
- {
- uschar *helo_ip;
- int offset = 1;
-
- if (strncmpic(sender_helo_name+1, US"IPv6:",5) == 0) offset += 5;
- helo_ip = string_copyn(sender_helo_name + offset, len - offset - 1);
-
- if (string_is_ip_address(helo_ip, NULL) != 0)
- {
- int x[4];
- int size;
- size = host_aton(helo_ip, x);
- helo_ip = store_get(48); /* large enough for full IPv6 */
- (void)host_nmtoa(size, x, -1, helo_ip, ':');
- if (strcmpic(helo_ip, sender_host_address) == 0) no_helo = TRUE;
- }
- }
-
- if (no_helo)
- {
- sender_fullhost = string_sprintf("%s %s", sender_host_name, address);
- sender_rcvhost = (sender_ident == NULL)?
- string_sprintf("%s (%s)", sender_host_name, address) :
- string_sprintf("%s (%s ident=%s)", sender_host_name, address,
- sender_ident);
- }
- else
+ if (show_helo)
{
sender_fullhost = string_sprintf("%s (%s) %s", sender_host_name,
sender_helo_name, address);
@@ -674,6 +675,14 @@ else
string_sprintf("%s\n\t(%s helo=%s ident=%s)", sender_host_name,
address, sender_helo_name, sender_ident);
}
+ else
+ {
+ sender_fullhost = string_sprintf("%s %s", sender_host_name, address);
+ sender_rcvhost = (sender_ident == NULL)?
+ string_sprintf("%s (%s)", sender_host_name, address) :
+ string_sprintf("%s (%s ident=%s)", sender_host_name, address,
+ sender_ident);
+ }
}
store_pool = old_pool;