Here is the diff excluding the site folder.
Tomorrow I will also commit further packaging/site fixes (*.xml and
*.properties changes in the root) and backport JAMES-584.
Stefano
Index: src/java/org/apache/james/core/MimeMessageInputStreamSource.java
===================================================================
--- src/java/org/apache/james/core/MimeMessageInputStreamSource.java (.../tags/build_2_3_0_RC1) (revision 428484)
+++ src/java/org/apache/james/core/MimeMessageInputStreamSource.java (.../branches/v2.3) (revision 428484)
@@ -80,6 +80,22 @@
sourceId = file.getCanonicalPath();
} catch (IOException ioe) {
+ // We had an IOException preparing the temporary file, so
+ // don't just leave it around to garbage collect later.
+ // It isn't as if we are going to use it after we throw
+ // the MessagingException.
+ if (fout != null) try {
+ fout.close();
+ fout = null;
+ } catch (IOException _) {
+ // Ignored - logging unavailable to log this error.
+ }
+
+ if (file != null) {
+ file.delete();
+ file = null;
+ }
+
throw new MessagingException("Unable to retrieve the data: " + ioe.getMessage(), ioe);
} finally {
try {
@@ -149,11 +165,9 @@
* formal mechanism for cleanup through use of the dispose() method.
* @throws Throwable
*
- */
public void finalize() throws Throwable {
dispose();
super.finalize();
}
-
-
+ */
}
Index: src/java/org/apache/james/smtpserver/MailCmdHandler.java
===================================================================
--- src/java/org/apache/james/smtpserver/MailCmdHandler.java (.../tags/build_2_3_0_RC1) (revision 428484)
+++ src/java/org/apache/james/smtpserver/MailCmdHandler.java (.../branches/v2.3) (revision 428484)
@@ -197,7 +197,8 @@
}
}
- if (checkValidSenderDomain == true) {
+ // check only if senderAddress is not null
+ if (checkValidSenderDomain == true && senderAddress != null) {
/**
* don't check if the ip address is allowed to relay. Only check if it is set in the config.
Index: src/java/org/apache/james/smtpserver/SMTPHandler.java
===================================================================
--- src/java/org/apache/james/smtpserver/SMTPHandler.java (.../tags/build_2_3_0_RC1) (revision 428484)
+++ src/java/org/apache/james/smtpserver/SMTPHandler.java (.../branches/v2.3) (revision 428484)
@@ -400,36 +400,37 @@
//handle messages
if(mode == MESSAGE_RECEIVED_MODE) {
- getLogger().info("executing message handlers");
- List messageHandlers = handlerChain.getMessageHandlers();
- int count = messageHandlers.size();
- for(int i =0; i < count; i++) {
- ((MessageHandler)messageHandlers.get(i)).onMessage(this);
- //if the response is received, stop processing of command handlers
- if(mode == MESSAGE_ABORT_MODE) {
- break;
+ try {
+ getLogger().debug("executing message handlers");
+ List messageHandlers = handlerChain.getMessageHandlers();
+ int count = messageHandlers.size();
+ for(int i =0; i < count; i++) {
+ ((MessageHandler)messageHandlers.get(i)).onMessage(this);
+ //if the response is received, stop processing of command handlers
+ if(mode == MESSAGE_ABORT_MODE) {
+ break;
+ }
}
- }
- }
-
- //do the clean up
- if(mail != null) {
- if (mail instanceof Disposable) {
- ((Disposable) mail).dispose();
- }
+ } finally {
+ //do the clean up
+ if(mail != null) {
+ if (mail instanceof Disposable) {
+ ((Disposable) mail).dispose();
+ }
- // remember the ehlo mode
- Object currentHeloMode = state.get(CURRENT_HELO_MODE);
+ // remember the ehlo mode
+ Object currentHeloMode = state.get(CURRENT_HELO_MODE);
- mail = null;
- resetState();
+ mail = null;
+ resetState();
- // start again with the old helo mode
- if (currentHeloMode != null) {
- state.put(CURRENT_HELO_MODE,currentHeloMode);
+ // start again with the old helo mode
+ if (currentHeloMode != null) {
+ state.put(CURRENT_HELO_MODE,currentHeloMode);
+ }
+ }
}
}
-
}
theWatchdog.stop();
getLogger().debug("Closing socket.");
Index: src/java/org/apache/james/smtpserver/DNSRBLHandler.java
===================================================================
--- src/java/org/apache/james/smtpserver/DNSRBLHandler.java (.../tags/build_2_3_0_RC1) (revision 428484)
+++ src/java/org/apache/james/smtpserver/DNSRBLHandler.java (.../branches/v2.3) (revision 428484)
@@ -119,14 +119,26 @@
if (whitelist != null) {
String[] rblList = whitelist;
for (int i = 0 ; i < rblList.length ; i++) try {
- org.apache.james.dnsserver.DNSServer.getByName(reversedOctets + rblList[i]);
+ java.net.InetAddress addr = org.apache.james.dnsserver.DNSServer.getByName(reversedOctets + rblList[i]);
if (getLogger().isInfoEnabled()) {
getLogger().info("Connection from " + ipAddress + " whitelisted by " + rblList[i]);
}
+
+ /* Ihis code may be helpful if admins need to debug why they are getting weird
+ behavior from the blocklists. Also, it might help them to know what IP is
+ returned, since zones often use that to indicate interesting information.
+
+ The next version of this code already handles the associated TXT record,
+ so this code is just temporary for this release.
+ */
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Whitelist addr = " + addr.toString());
+ }
+
return false;
} catch (java.net.UnknownHostException uhe) {
- if (getLogger().isInfoEnabled()) {
- getLogger().info("unknown host exception thrown:" + rblList[i]);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("unknown host exception thrown:" + reversedOctets + rblList[i]);
}
}
}
@@ -134,15 +146,27 @@
if (blacklist != null) {
String[] rblList = blacklist;
for (int i = 0 ; i < rblList.length ; i++) try {
- org.apache.james.dnsserver.DNSServer.getByName(reversedOctets + rblList[i]);
+ java.net.InetAddress addr = org.apache.james.dnsserver.DNSServer.getByName(reversedOctets + rblList[i]);
if (getLogger().isInfoEnabled()) {
getLogger().info("Connection from " + ipAddress + " restricted by " + rblList[i] + " to SMTP AUTH/postmaster/abuse.");
}
+
+ /* Ihis code may be helpful if admins need to debug why they are getting weird
+ behavior from the blocklists. Also, it might help them to know what IP is
+ returned, since zones often use that to indicate interesting information.
+
+ The next version of this code already handles the associated TXT record,
+ so this code is just temporary for this release.
+ */
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Blacklist addr = " + addr.toString());
+ }
+
return true;
} catch (java.net.UnknownHostException uhe) {
// if it is unknown, it isn't blocked
- if (getLogger().isInfoEnabled()) {
- getLogger().info("unknown host exception thrown:" + rblList[i]);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("unknown host exception thrown:" + reversedOctets + rblList[i]);
}
}
}
Index: src/java/org/apache/james/smtpserver/SendMailHandler.java
===================================================================
--- src/java/org/apache/james/smtpserver/SendMailHandler.java (.../tags/build_2_3_0_RC1) (revision 428484)
+++ src/java/org/apache/james/smtpserver/SendMailHandler.java (.../branches/v2.3) (revision 428484)
@@ -51,7 +51,7 @@
* @see org.apache.james.smtpserver#onMessage(SMTPSession)
*/
public void onMessage(SMTPSession session) {
- getLogger().info("sending mail");
+ getLogger().debug("sending mail");
Mail mail = session.getMail();
Index: src/java/org/apache/james/smtpserver/DataCmdHandler.java
===================================================================
--- src/java/org/apache/james/smtpserver/DataCmdHandler.java (.../tags/build_2_3_0_RC1) (revision 428484)
+++ src/java/org/apache/james/smtpserver/DataCmdHandler.java (.../branches/v2.3) (revision 428484)
@@ -278,6 +278,23 @@
mail.setAttribute(SMTP_AUTH_USER_ATTRIBUTE_NAME, session.getUser());
}
session.setMail(mail);
+ } catch (MessagingException me) {
+ // if we get here, it means that we received a
+ // MessagingException, which would happen BEFORE we call
+ // session.setMail, so the mail object is still strictly
+ // local to us, and we really should clean it up before
+ // re-throwing the MessagingException for our call chain
+ // to process.
+ //
+ // So why has this worked at all so far? Initial
+ // conjecture is that it has depended upon finalize to
+ // call dispose. Not in the MailImpl, which doesn't have
+ // one, but even further down in the MimeMessageInputStreamSource.
+
+ if (mail != null) {
+ mail.dispose();
+ }
+ throw me;
} finally {
if (recipientCollection != null) {
recipientCollection.clear();
Index: src/conf/james-smtphandlerchain.xml
===================================================================
--- src/conf/james-smtphandlerchain.xml (.../tags/build_2_3_0_RC1) (revision 428484)
+++ src/conf/james-smtphandlerchain.xml (.../branches/v2.3) (revision 428484)
@@ -4,14 +4,38 @@
<handlerchain>
<!-- The connect handler configuration -->
+
+ <!-- STOP - before you uncomment out the DNS RBL handler,
+ please take a moment to review each block list. We
+ have included some that various JAMES committers use,
+ but you must decide which, if any, are appropriate
+ for your environment. The mail servers hosting
+ @apache.org mailing lists, for example, use a
+ slightly different list than we have included below.
+ And it is likely that most JAMES committes also have
+ slightly different sets of lists. The SpamAssassin
+ user's list would be one good place to discuss the
+ measured quality of various block lists.
+
+ NOTA BENE: the domain names, below, are terminated
+ with '.' to ensure that they are absolute names in
+ DNS lookups. Under some circumstances, names that
+ are not explicitly absolute could be treated as
+ relative names, leading to incorrect results. This
+ has been observed on *nix and MS-Windows platforms
+ by users of multiple mail servers, and is not JAMES
+ specific. If you are unsure what this means for you,
+ please speak with your local system/network admins.
+ -->
<!--
<handler class="org.apache.james.smtpserver.DNSRBLHandler">
<rblservers>
- <whitelist> query.bondedsender.org </whitelist>
- <blacklist> sbl-xbl.spamhaus.org </blacklist>
- <blacklist> list.dsbl.org </blacklist>
- <blacklist> dul.dnsbl.sorbs.net </blacklist>
- <blacklist> relays.ordb.org </blacklist>
+ <whitelist> query.bondedsender.org. </whitelist>
+
+ <blacklist> sbl-xbl.spamhaus.org. </blacklist>
+ <blacklist> dul.dnsbl.sorbs.net. </blacklist>
+ <blacklist> list.dsbl.org. </blacklist>
+ <blacklist> relays.ordb.org. </blacklist>
</rblservers>
</handler>
-->
@@ -19,6 +43,7 @@
<!-- The command handler configuration -->
<handler command="HELO" class="org.apache.james.smtpserver.HeloCmdHandler">
<!-- If is set to true helo is only accepted if it can be resolved -->
+ <!-- WARNING: This check will reject on invalid HELO even if the user is authenticated-->
<!--
<checkResolvableHelo> false </checkResolvableHelo>
-->
@@ -30,7 +55,8 @@
-->
</handler>
<handler command="EHLO" class="org.apache.james.smtpserver.EhloCmdHandler">
- <!-- If is set to true ehlo is only accepted if it can be resolved -->
+ <!-- If is set to true EHLO is only accepted if it can be resolved -->
+ <!-- WARNING: This check will reject on invalid EHLO even if the user is authenticated-->
<!--
<checkResolvableEhlo> false </checkResolvableEhlo>
-->
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]