You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2007/04/18 10:39:47 UTC
svn commit: r529916 -
/james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
Author: norman
Date: Wed Apr 18 01:39:43 2007
New Revision: 529916
URL: http://svn.apache.org/viewvc?view=rev&rev=529916
Log:
Fix use of index=-1 im Fetchmail. See JAMES-787
Modified:
james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
Modified: james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java?view=diff&rev=529916&r1=529915&r2=529916
==============================================================================
--- james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java (original)
+++ james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java Wed Apr 18 01:39:43 2007
@@ -1500,6 +1500,9 @@
protected String getRemoteAddress()
throws MessagingException, UnknownHostException
{
+ // No need for parsing the header for the remoteipaddress. Just return 127.0.0.1
+ if (getRemoteReceivedHeaderIndex() == -1) return "127.0.0.1";
+
String remoteAddress;
if (null == (remoteAddress = getRemoteAddressBasic()))
{
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r529916 - /james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
Posted by Stefano Bagnara <ap...@bago.org>.
Norman Maurer ha scritto:
> Yes i have a localhost mapping...
> I think the problem is here:
> try
> {
> mail = createMail(createMessage(), intendedRecipient);
> }
> catch (ParseException ex)
> {
> handleParseException(ex);
> return;
> }
> catch (UnknownHostException ex)
> {
> handleUnknownHostException(ex);
> return;
> }
>
> The createMail(...) call getAddress(), getAdress() throws the
> Unknownhostexception because it can't parse the ipaddress. Then we call
> handleUnknowHostException(..) and just ignore the message.
If getRemoteAddress is returning an UnknownHostException then we should
search the bug there: why on your system it returns UnknownHostException?
As I wrote in the previous mail I think that a key to understand what's
going on is to know what exactly happen here:
-----
try
{
InetAddress addr1 = java.net.InetAddress.getLocalHost();
// These shenanigans are required to get the fully qualified
// hostname prior to JDK 1.4 in which getCanonicalHostName()
// does the job for us
InetAddress addr2 =
java.net.InetAddress.getByName(addr1.getHostAddress());
InetAddress addr3 =
java.net.InetAddress.getByName(addr2.getHostName());
domainBuffer.append(addr3.getHostName());
}
catch (UnknownHostException ue)
{
domainBuffer.append("[127.0.0.1]");
}
-----
As you can see the getDomain catches the UnknownHostException and
returns [127.0.0.1] if it happens, so either the getRemoteAddress is not
handling correctly the "[127.0.0.1]" input or the getByNames sequence
above is returning something that the getRemoteAddress will not resolve.
We need to know what is happening to understand what's wrong.
Stefano
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r529916 - /james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
Posted by Norman Maurer <no...@apache.org>.
Stefano Bagnara schrieb:
> Norman Maurer ha scritto:
>> Stefano Bagnara schrieb:
>>> Norman,
>>>
>>> this is v2.3, a branch in RC state!!
>>> bugfixes should be applied to trunk and *then* we should discuss
>>> wether to backport to v2.3, IMHO.
>> Ups... You 100 % right... shame on me. For sure i should commit to trunk
>> first. I will revert it in branch and start apply the changes in trunk
>> again, after we discuss it!
>
> Thank you :-)
>
>>> About the issue and the patch, looking at the code it seems that it
>>> should have already worked, so probably if we have a bug it is related
>>> to DNS and not to fetchmail. In the current fetchmail code there are
>>> almost 30 lines of code to manage the -1 scenario, so it seems a bit
>>> weird to simply add a couple of lines to avoid their execution.
>>> Maybe Steve can help understanding what's going on...
>>>
>>> Have you debugged the problem? Where exactly the unkownhost happens?
>>
>> Well, I think its unneeded to parse the the header and try to resolve
>> the ip/domain if index -1 is used. Its a waste of ressource. The
>> problem appeared here with exchange server message which not had an ip
>> address in the Received header. For me it should not fail to fetch this
>> emails if index -1 is used because the comment tells me that it will use
>> 127.0.0.1 and localhost everytime. So why parse it ?
>>
>> See https://issues.apache.org/jira/browse/JAMES-787
>
> Well, I understood the problem you described and your concern, but
> also in JAMES-787 there is no stacktrace or other debugging
> information I can use to understand that we don't break anything with
> this fix.
>
> If you look at the computeRemoteAddress and computeRemoteDomain I
> previously quoted you will see that computeRemoteDomain if
> getRemoteReceivedHeaderIndex is -1 does not do computation but simply
> as k to the host what is localhost or the localhost address.
> I guess this is because Steve didn't want to add "127.0.0.1" or
> "localhost" *magic* words to the code but preferred to rely on
> underlying OS informations.
>
> I would like to know what this code returned on your machine:
> -----
> try
> {
> InetAddress addr1 = java.net.InetAddress.getLocalHost();
> // These shenanigans are required to get the fully qualified
> // hostname prior to JDK 1.4 in which getCanonicalHostName()
> // does the job for us
> InetAddress addr2 =
> java.net.InetAddress.getByName(addr1.getHostAddress());
> InetAddress addr3 =
> java.net.InetAddress.getByName(addr2.getHostName());
> domainBuffer.append(addr3.getHostName());
> }
> catch (UnknownHostException ue)
> {
> domainBuffer.append("[127.0.0.1]");
> }
> -----
>
> the computeRemoteAddress gives a result based on the code above.. so
> if we understand what's wrong there we may probably fix the issue.
>
> and remember we have an open bug overlapping this code:
> https://issues.apache.org/jira/browse/JAMES-302
>
> Maybe that you are simply hitting JAMES-302 again (does your host file
> contains 127.0.0.1 <-> localhost mapping ?).
>
> About JAMES-302 we decided to move that out from v2.3 roadmap a while
> ago, but if we find a correct and simple fix we could evaluate
> reinclusion in v2.3 (even if I'm not sure we should delay 2.3.1 for
> this).
>
> Stefano
Yes i have a localhost mapping...
I think the problem is here:
try
{
mail = createMail(createMessage(), intendedRecipient);
}
catch (ParseException ex)
{
handleParseException(ex);
return;
}
catch (UnknownHostException ex)
{
handleUnknownHostException(ex);
return;
}
The createMail(...) call getAddress(), getAdress() throws the
Unknownhostexception because it can't parse the ipaddress. Then we call
handleUnknowHostException(..) and just ignore the message.
bye
Norman
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r529916 - /james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
Posted by Stefano Bagnara <ap...@bago.org>.
Norman Maurer ha scritto:
> Stefano Bagnara schrieb:
>> Norman,
>>
>> this is v2.3, a branch in RC state!!
>> bugfixes should be applied to trunk and *then* we should discuss
>> wether to backport to v2.3, IMHO.
> Ups... You 100 % right... shame on me. For sure i should commit to trunk
> first. I will revert it in branch and start apply the changes in trunk
> again, after we discuss it!
Thank you :-)
>> About the issue and the patch, looking at the code it seems that it
>> should have already worked, so probably if we have a bug it is related
>> to DNS and not to fetchmail. In the current fetchmail code there are
>> almost 30 lines of code to manage the -1 scenario, so it seems a bit
>> weird to simply add a couple of lines to avoid their execution.
>> Maybe Steve can help understanding what's going on...
>>
>> Have you debugged the problem? Where exactly the unkownhost happens?
>
> Well, I think its unneeded to parse the the header and try to resolve
> the ip/domain if index -1 is used. Its a waste of ressource. The
> problem appeared here with exchange server message which not had an ip
> address in the Received header. For me it should not fail to fetch this
> emails if index -1 is used because the comment tells me that it will use
> 127.0.0.1 and localhost everytime. So why parse it ?
>
> See https://issues.apache.org/jira/browse/JAMES-787
Well, I understood the problem you described and your concern, but also
in JAMES-787 there is no stacktrace or other debugging information I can
use to understand that we don't break anything with this fix.
If you look at the computeRemoteAddress and computeRemoteDomain I
previously quoted you will see that computeRemoteDomain if
getRemoteReceivedHeaderIndex is -1 does not do computation but simply as
k to the host what is localhost or the localhost address.
I guess this is because Steve didn't want to add "127.0.0.1" or
"localhost" *magic* words to the code but preferred to rely on
underlying OS informations.
I would like to know what this code returned on your machine:
-----
try
{
InetAddress addr1 = java.net.InetAddress.getLocalHost();
// These shenanigans are required to get the fully qualified
// hostname prior to JDK 1.4 in which getCanonicalHostName()
// does the job for us
InetAddress addr2 =
java.net.InetAddress.getByName(addr1.getHostAddress());
InetAddress addr3 =
java.net.InetAddress.getByName(addr2.getHostName());
domainBuffer.append(addr3.getHostName());
}
catch (UnknownHostException ue)
{
domainBuffer.append("[127.0.0.1]");
}
-----
the computeRemoteAddress gives a result based on the code above.. so if
we understand what's wrong there we may probably fix the issue.
and remember we have an open bug overlapping this code:
https://issues.apache.org/jira/browse/JAMES-302
Maybe that you are simply hitting JAMES-302 again (does your host file
contains 127.0.0.1 <-> localhost mapping ?).
About JAMES-302 we decided to move that out from v2.3 roadmap a while
ago, but if we find a correct and simple fix we could evaluate
reinclusion in v2.3 (even if I'm not sure we should delay 2.3.1 for this).
Stefano
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r529916 - /james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
Posted by Norman Maurer <no...@apache.org>.
Stefano Bagnara schrieb:
> Norman,
>
> this is v2.3, a branch in RC state!!
> bugfixes should be applied to trunk and *then* we should discuss
> wether to backport to v2.3, IMHO.
Ups... You 100 % right... shame on me. For sure i should commit to trunk
first. I will revert it in branch and start apply the changes in trunk
again, after we discuss it!
>
> Then you used tabs instead of spaces, but this is another issue ;-)
Strange.. I have to check my eclipse
>
> About the issue and the patch, looking at the code it seems that it
> should have already worked, so probably if we have a bug it is related
> to DNS and not to fetchmail. In the current fetchmail code there are
> almost 30 lines of code to manage the -1 scenario, so it seems a bit
> weird to simply add a couple of lines to avoid their execution.
> Maybe Steve can help understanding what's going on...
>
> Have you debugged the problem? Where exactly the unkownhost happens?
Well, I think its unneeded to parse the the header and try to resolve
the ip/domain if index -1 is used. Its a waste of ressource. The
problem appeared here with exchange server message which not had an ip
address in the Received header. For me it should not fail to fetch this
emails if index -1 is used because the comment tells me that it will use
127.0.0.1 and localhost everytime. So why parse it ?
See https://issues.apache.org/jira/browse/JAMES-787
bye
Norman
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r529916 - /james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
Posted by Stefano Bagnara <ap...@bago.org>.
Norman,
this is v2.3, a branch in RC state!!
bugfixes should be applied to trunk and *then* we should discuss wether
to backport to v2.3, IMHO.
Then you used tabs instead of spaces, but this is another issue ;-)
About the issue and the patch, looking at the code it seems that it
should have already worked, so probably if we have a bug it is related
to DNS and not to fetchmail. In the current fetchmail code there are
almost 30 lines of code to manage the -1 scenario, so it seems a bit
weird to simply add a couple of lines to avoid their execution.
Maybe Steve can help understanding what's going on...
Have you debugged the problem? Where exactly the unkownhost happens?
----
protected String computeRemoteAddress()
throws MessagingException, UnknownHostException
{
String domain = getRemoteDomain();
String address = null;
String validatedAddress = null;
int ipAddressStart = domain.indexOf('[');
int ipAddressEnd = -1;
if (ipAddressStart > -1)
ipAddressEnd = domain.indexOf(']', ipAddressStart);
if (ipAddressEnd > -1)
address = domain.substring(ipAddressStart + 1, ipAddressEnd);
else
{
int hostNameEnd = domain.indexOf(' ');
if (hostNameEnd == -1)
hostNameEnd = domain.length();
address = domain.substring(0, hostNameEnd);
}
validatedAddress =
org.apache.james.dnsserver.DNSServer.getByName(address).getHostAddress();
return validatedAddress;
}
-----
getRemoteDomain returns what computeRemoteDomain calculated and when the
getRemoteReceivedHeaderIndex is -1 it does this:
-----
// If a domain was not found, the default is the local host and
// if we cannot resolve this, the local address 127.0.0.1
// Note that earlier versions of this code simply used 'localhost'
// which works fine with java.net but is not resolved by dnsjava
// which was introduced in v2.2.0. See Jira issue JAMES-302.
if (domainBuffer.length() == 0)
{
try
{
InetAddress addr1 = java.net.InetAddress.getLocalHost();
// These shenanigans are required to get the fully qualified
// hostname prior to JDK 1.4 in which getCanonicalHostName()
// does the job for us
InetAddress addr2 =
java.net.InetAddress.getByName(addr1.getHostAddress());
InetAddress addr3 =
java.net.InetAddress.getByName(addr2.getHostName());
domainBuffer.append(addr3.getHostName());
}
catch (UnknownHostException ue)
{
domainBuffer.append("[127.0.0.1]");
}
}
return domainBuffer.toString().trim();
-----
Thank you,
Stefano
norman@apache.org ha scritto:
> Author: norman
> Date: Wed Apr 18 01:39:43 2007
> New Revision: 529916
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=529916
> Log:
> Fix use of index=-1 im Fetchmail. See JAMES-787
>
> Modified:
> james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
>
> Modified: james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
> URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java?view=diff&rev=529916&r1=529915&r2=529916
> ==============================================================================
> --- james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java (original)
> +++ james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java Wed Apr 18 01:39:43 2007
> @@ -1500,6 +1500,9 @@
> protected String getRemoteAddress()
> throws MessagingException, UnknownHostException
> {
> + // No need for parsing the header for the remoteipaddress. Just return 127.0.0.1
> + if (getRemoteReceivedHeaderIndex() == -1) return "127.0.0.1";
> +
> String remoteAddress;
> if (null == (remoteAddress = getRemoteAddressBasic()))
> {
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org