On 12/14/06, Norman <[EMAIL PROTECTED]> wrote:
Hi Bernd,
yes you are right. it can happen . But how we should protect about
that? If we use "localhost" as domain hardcoded in the handlers it is
bad too. Because if someone remove localhost from servernames ( which
most will do) the email will bounced.
I whould also be happy if james whould not start if no defaultdomain is
specified., but that whould break backward compatiblitly. IMHO not a big
problem cause its only one line to add to james block. So if we add a
explanation to UPGRADE.TXT it whould be no big deal
Any thoughts ?
the current solution "silently" tries to deal with the lack of domain
name by providing some default behavior. the other extreme would be to
not process any mails lacking a domain as soon as virtual hosting is
switched on. or, not to process any mail if the default domain is
NULL.
all approaches have their shortcomings.
maybe it would help to add a hint to the domain list configuration
that in case virtual hosting is used und no default is specified, the
first entry from this list is used for virtual hosting and changes in
this setup would result in re-mapping non-domain accounts.
Bernd
bye
Norman
Bernd Fondermann schrieb:
> let's say you have [EMAIL PROTECTED] and [EMAIL PROTECTED]
> hosted within the same James instance and the admin changes the domain
> list from {"nsa.gov", "callcenter.com"} to {"callcenter.com",
> "nsa.gov"} because he thinks sorting is cool.
>
> after restart, "agent-help" is mapped to "[EMAIL PROTECTED]",
> when before it was "[EMAIL PROTECTED]" in the following line and if
> default domain is not specified:
>
> recipient = recipient + "@" +
> session.getConfigurationData().getMailServer().getDefaultDomain();
>
> could this happen, or is it way off?
>
> Bernd
>
> On 12/14/06, Norman <[EMAIL PROTECTED]> wrote:
>>
>> Hi Bernd,
>> can you explain what exact should be the problem with the changes, at
>> the moment i not understand what's the problems..
>>
>> thx
>> Norman
>>
>> -----------------------------
>>
>>
<http://www.nabble.com/Re%3A-svn-commit%3A-r480586---in--james-server-trunk-src%3A-conf--java-org-apache-james--java-org-apache-james-services--java-org-apache-james-smtpserver-core-filter--java-org-apache-james-transport-mailets--test-org-apache-james-imapserver-mock--test-org--tf2807004.html#a7831563>
>>
>>
>>
>> Hi Norman,
>>
>> does this actually work? if the mail server configuration is changed
>> from one hostname to the other or the list of domain names is
>> reordered, doesn't this mean all accounts become invalidated or users
>> have access to the mail of others?
>>
>> also, I find expressions like
>> if(((ManageableDomainList) domains).addDomain(defaultDomain) !=
>> false)
>> to be very hard to read, especially the "!= false" clause.
>>
>> Bernd
>>
>> On 11/29/06, [EMAIL PROTECTED]
>> <http://www.nabble.com/user/SendEmail.jtp?type=post&post=7831563&i=0>
>> <[EMAIL PROTECTED]
>> <http://www.nabble.com/user/SendEmail.jtp?type=post&post=7831563&i=1>>
>> wrote:
>> > Author: norman
>> > Date: Wed Nov 29 06:49:51 2006
>> > New Revision: 480586
>> >
>> > URL: http://svn.apache.org/viewvc?view=rev&rev=480586
>> <http://svn.apache.org/viewvc?view=rev&rev=480586>
>> > Log:
>> > Allow to specify a defaultDomain which get added to a recipient if no
>> localpart is given
>> > Correct the classes to use the right defaultDomain
>> >
>> > Modified:
>> > james/server/trunk/src/conf/james-config.xml
>> > james/server/trunk/src/java/org/apache/james/James.java
>> >
>> james/server/trunk/src/java/org/apache/james/services/MailServer.java
>> >
>>
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java
>>
>>
>> >
>>
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java
>>
>>
>> >
>>
james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
>>
>>
>> >
>>
james/server/trunk/src/test/org/apache/james/imapserver/mock/MockMailServer.java
>>
>>
>> >
>>
james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java
>>
>>
>> >
>> > Modified: james/server/trunk/src/conf/james-config.xml
>> > URL:
>>
http://svn.apache.org/viewvc/james/server/trunk/src/conf/james-config.xml?view=diff&rev=480586&r1=480585&r2=480586
>>
>>
<http://svn.apache.org/viewvc/james/server/trunk/src/conf/james-config.xml?view=diff&rev=480586&r1=480585&r2=480586>
>>
>>
>> >
>>
==============================================================================
>>
>>
>> > --- james/server/trunk/src/conf/james-config.xml (original)
>> > +++ james/server/trunk/src/conf/james-config.xml Wed Nov 29
>> 06:49:51 2006
>> > @@ -93,8 +93,14 @@
>> > </inboxRepository>
>> > -->
>> >
>> > - <!-- Set to true to support virtualHosting -->
>> > + <!-- Set to true to support virtualHosting. If virtualHosting
>> support is enabled the server will accept thread every user independ
>> on -->
>> > + <!-- domain level. -->
>> > <enableVirtualHosting> false </enableVirtualHosting>
>> > +
>> > + <!-- Set the default domain which will be used if an email is
>> send to a recipient without a domain part -->
>> > + <!-- If not defaultdomain is set the first domain of the
>> DomainList get used -->
>> > + <defaultDomain> localhost </defaultDomain>
>> > +
>> > </James>
>> >
>> > <!-- Experimental IMAP support -->
>> >
>> > Modified: james/server/trunk/src/java/org/apache/james/James.java
>> > URL:
>>
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/James.java?view=diff&rev=480586&r1=480585&r2=480586
>>
>>
<http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/James.java?view=diff&rev=480586&r1=480585&r2=480586>
>>
>>
>> >
>>
==============================================================================
>>
>>
>> > --- james/server/trunk/src/java/org/apache/james/James.java (original)
>> > +++ james/server/trunk/src/java/org/apache/james/James.java Wed Nov 29
>> 06:49:51 2006
>> > @@ -75,6 +75,7 @@
>> > import java.util.HashSet;
>> > import java.util.Hashtable;
>> > import java.util.Iterator;
>> > +import java.util.List;
>> > import java.util.Locale;
>> > import java.util.Map;
>> > import java.util.Vector;
>> > @@ -175,6 +176,8 @@
>> > private DomainList domains;
>> >
>> > private boolean virtualHosting = false;
>> > +
>> > + private String defaultDomain = null;
>> >
>> >
>> > /**
>> > @@ -258,6 +261,13 @@
>> > }
>> >
>> > getLogger().info("VirtualHosting supported: " +
>> virtualHosting);
>> > +
>> > + Configuration defaultDomainConfig =
>> conf.getChild("defaultDomain");
>> > + if (defaultDomainConfig != null ) {
>> > + defaultDomain = defaultDomainConfig.getValue(null);
>> > + }
>> > +
>> > + getLogger().info("Defaultdomain: " + defaultDomain);
>> >
>> > // Add this to comp
>> > compMgr.put( MailServer.ROLE, this);
>> > @@ -340,12 +350,20 @@
>> > }
>> >
>> > private void initializeServernamesAndPostmaster() throws
>> ConfigurationException, ParseException {
>> > -
>> > + String defaultDomain = getDefaultDomain();
>> > + if (domains.containsDomain(defaultDomain) == false) {
>> > + if (domains instanceof ManageableDomainList) {
>> > + if(((ManageableDomainList)
>> domains).addDomain(defaultDomain) != false) {
>> > + throw new ConfigurationException("Configured
>> defaultdomain could not get added to DomainList");
>> > + }
>> > + } else {
>> > + throw new ConfigurationException("Configured
>> defaultDomain not exist in DomainList");
>> > + }
>> > + }
>> > serverNames = domains.getDomains();
>> >
>> > if (serverNames == null || serverNames.size() == 0) throw new
>> ConfigurationException("No domainnames configured");
>> >
>> > - String defaultDomain = (String)
>> serverNames.iterator().next();
>> > // used by RemoteDelivery for HELO
>> > attributes.put(Constants.DEFAULT_DOMAIN, defaultDomain);
>> >
>> > @@ -914,5 +932,21 @@
>> > */
>> > public boolean supportVirtualHosting() {
>> > return virtualHosting;
>> > + }
>> > +
>> > + /**
>> > + * @see org.apache.james.services.MailServer#getDefaultDomain()
>> > + */
>> > + public String getDefaultDomain() {
>> > + if (defaultDomain == null) {
>> > + List domainList = domains.getDomains();
>> > + if (domainList == null || domainList.isEmpty()) {
>> > + return "localhost";
>> > + } else {
>> > + return (String) domainList.get(0);
>> > + }
>> > + } else {
>> > + return defaultDomain;
>> > + }
>> > }
>> > }
>> >
>> > Modified:
>> james/server/trunk/src/java/org/apache/james/services/MailServer.java
>> > URL:
>>
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/MailServer.java?view=diff&rev=480586&r1=480585&r2=480586
>>
>>
<http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/MailServer.java?view=diff&rev=480586&r1=480585&r2=480586>
>>
>>
>> >
>>
==============================================================================
>>
>>
>> > ---
>> james/server/trunk/src/java/org/apache/james/services/MailServer.java
>> (original)
>> > +++
>> james/server/trunk/src/java/org/apache/james/services/MailServer.java
>> Wed Nov 29 06:49:51 2006
>> > @@ -143,4 +143,12 @@
>> > * @return true or false
>> > */
>> > boolean supportVirtualHosting();
>> > +
>> > + /**
>> > + * Return the default domain which will get used to deliver mail
>> to if only the localpart
>> > + * was given on rcpt to.
>> > + *
>> > + * @return the defaultdomain
>> > + */
>> > + String getDefaultDomain();
>> > }
>> >
>> > Modified:
>>
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java
>>
>>
>> > URL:
>>
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java?view=diff&rev=480586&r1=480585&r2=480586
>>
>>
<http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java?view=diff&rev=480586&r1=480585&r2=480586>
>>
>>
>> >
>>
==============================================================================
>>
>>
>> > ---
>>
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java
>>
>> (original)
>> > +++
>>
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java
>>
>> Wed Nov 29 06:49:51 2006
>> > @@ -159,7 +159,7 @@
>> > } else {
>> >
>> > if (sender.indexOf("@") < 0) {
>> > - sender = sender + "@localhost";
>> > + sender = sender + "@" +
>> session.getConfigurationData().getMailServer().getDefaultDomain();
>> > }
>> >
>> > try {
>> >
>> > Modified:
>>
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java
>>
>>
>> > URL:
>>
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java?view=diff&rev=480586&r1=480585&r2=480586
>>
>>
<http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java?view=diff&rev=480586&r1=480585&r2=480586>
>>
>>
>> >
>>
==============================================================================
>>
>>
>> > ---
>>
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java
>>
>> (original)
>> > +++
>>
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java
>>
>> Wed Nov 29 06:49:51 2006
>> > @@ -118,7 +118,8 @@
>> > }
>> >
>> > if (recipient.indexOf("@") < 0) {
>> > - recipient = recipient + "@localhost";
>> > + // set the default domain
>> > + recipient = recipient + "@" +
>> session.getConfigurationData().getMailServer().getDefaultDomain();
>> > }
>> >
>> > try {
>> >
>> > Modified:
>>
james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
>>
>>
>> > URL:
>>
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java?view=diff&rev=480586&r1=480585&r2=480586
>>
>>
<http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java?view=diff&rev=480586&r1=480585&r2=480586>
>>
>>
>> >
>>
==============================================================================
>>
>>
>> > ---
>>
james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
>>
>> (original)
>> > +++
>>
james/server/trunk/src/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
>>
>> Wed Nov 29 06:49:51 2006
>> > @@ -107,7 +107,7 @@
>> > }
>> >
>> > try {
>> > - MailAddress target =
>> (targetAddress.indexOf('@') < 0) ? new MailAddress(targetAddress,
>> "localhost")
>> > + MailAddress target =
>> (targetAddress.indexOf('@') < 0) ? new MailAddress(targetAddress,
>> (String) getMailetContext().getAttribute(Constants.DEFAULT_DOMAIN))
>> > : new MailAddress(targetAddress);
>> >
>> > //Mark this source address as an address
>> to remove from the recipient list
>> >
>> > Modified:
>>
james/server/trunk/src/test/org/apache/james/imapserver/mock/MockMailServer.java
>>
>>
>> > URL:
>>
http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/imapserver/mock/MockMailServer.java?view=diff&rev=480586&r1=480585&r2=480586
>>
>>
<http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/imapserver/mock/MockMailServer.java?view=diff&rev=480586&r1=480585&r2=480586>
>>
>>
>> >
>>
==============================================================================
>>
>>
>> > ---
>>
james/server/trunk/src/test/org/apache/james/imapserver/mock/MockMailServer.java
>>
>> (original)
>> > +++
>>
james/server/trunk/src/test/org/apache/james/imapserver/mock/MockMailServer.java
>>
>> Wed Nov 29 06:49:51 2006
>> > @@ -65,4 +65,8 @@
>> > return false;
>> > }
>> >
>> > + public String getDefaultDomain() {
>> > + return "localhost";
>> > + }
>> > +
>> > }
>> >
>> > Modified:
>>
james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java
>>
>>
>> > URL:
>>
http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java?view=diff&rev=480586&r1=480585&r2=480586
>>
>>
<http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java?view=diff&rev=480586&r1=480585&r2=480586>
>>
>>
>> >
>>
==============================================================================
>>
>>
>> > ---
>>
james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java
>>
>> (original)
>> > +++
>>
james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java
>>
>> Wed Nov 29 06:49:51 2006
>> > @@ -195,6 +195,10 @@
>> > public boolean supportVirtualHosting() {
>> > return virtualHosting;
>> > }
>> > +
>> > + public String getDefaultDomain() {
>> > + return "localhost";
>> > + }
>> > }
>> >
>> >
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> <http://www.nabble.com/user/SendEmail.jtp?type=post&post=7831563&i=2>
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> <http://www.nabble.com/user/SendEmail.jtp?type=post&post=7831563&i=3>
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> <http://www.nabble.com/user/SendEmail.jtp?type=post&post=7831563&i=4>
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> <http://www.nabble.com/user/SendEmail.jtp?type=post&post=7831563&i=5>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]