Bug 44312 - Warn when overwritting docBase of the default Host, with docBase of an alias with the same name..
Summary: Warn when overwritting docBase of the default Host, with docBase of an alias ...
Status: REOPENED
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 6.0.14
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-28 08:31 UTC by Jan Bielik
Modified: 2014-06-23 18:39 UTC (History)
1 user (show)



Attachments
2014-06-23_tc6_44312.patch (44.62 KB, patch)
2014-06-23 18:39 UTC, Konstantin Kolinko
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Bielik 2008-01-28 08:31:40 UTC
On a system running tomcat 6.0.14 we encountered the problem, that the specified
docBase of the default Host of an Engine is being overwritten, when an Alias
with the same name (as the default Host) is defined on a different Host of the
same Engine.

The user should be warned if the docBase of the default Host is being changed to
the one of an Alias.

When using tomcat 6.0.13 this problem didn't occur; means that the docBase of
the default Host remained the same for an equal configuration.

Are there any future plans on providing such a warning?

Best regards, Jan
Comment 1 Mark Thomas 2008-01-28 12:27:49 UTC
There are so many ways to do bad things with the configuration files I am not
sure we could reasonably catch them all or should even try.

That said, if you want to provide a patch it will be considered. Keep in mind
that the more invasive the patch, the less likely it is to be considered.
Comment 2 Ralf Hauser 2008-01-28 21:01:58 UTC
I guess this only thing needed is to utter a "SEVERE" warning when
org.apache.tomcat.util.http.mapper.Mapper.Context.extensionWrappers are created
that overwrite a pre-existing one...
Comment 3 Mark Thomas 2012-07-02 09:52:54 UTC
No patch has been provided for consideration.
Comment 4 Konstantin Kolinko 2014-06-19 23:12:15 UTC
Reopening.

From looking into this, I think messing up host and alias names can really be a surprise for a sloppy admin.

In the Mapper class the hosts and aliases are in the same list. Duplicates are silently prevented by Mapper.insertMap() with the "first come, first served" behaviour. The results may be surprising.


I have a patch for this.

A test case:
Configure the following hosts in server.xml:

[[[
      <Host name="localhost"  appBase="webapps">
        <!-- Alias equal to the name of its own Host is OK. -->
        <Alias>localhost</Alias>
      </Host>
      <Host name="second"  appBase="secondwebapps">
        <Alias>localhost</Alias>
      </Host>
      <Host name="third"  appBase="thirdwebapps">
        <Alias>fourth</Alias>
      </Host>
      <Host name="fourth"  appBase="fourthwebapps">
        <Alias>localhost</Alias>
        <Alias>second</Alias>
      </Host>
]]]

There is also a bug in Mapper.removeHost(name):
If host with such name is not registered in the mapper, it results in NPE at  "if (newHosts[i].object == host)" line.
(The find() method returns the closest match. To check that the correct item was found, one has to compare names).
Comment 5 Konstantin Kolinko 2014-06-20 01:09:36 UTC
Fixed in Tomcat 8 by r1604066 and will be in 8.0.10 onwards.
Comment 6 Konstantin Kolinko 2014-06-23 17:44:33 UTC
(In reply to Konstantin Kolinko from comment #4)

> There is also a bug in Mapper.removeHost(name):
> If host with such name is not registered in the mapper, it results in NPE
> at  "if (newHosts[i].object == host)" line.

For a record:
The bug in removeHost(), removeHostAlias() that was fixed here is more serious than just an NPE.

The bug is that those methods may remove a wrong host.

They remove whatever host is located at hosts[pos], but the find() method does not return the exact name match, but closest name.
Comment 7 Konstantin Kolinko 2014-06-23 18:02:10 UTC
Fixed in Tomcat 7 by r1604895  and will be in 7.0.55 onwards.
Comment 8 Konstantin Kolinko 2014-06-23 18:39:39 UTC
Created attachment 31744 [details]
2014-06-23_tc6_44312.patch

Patch that will be proposed for Tomcat 6.

TestMapper includes test case for bug 56653 (testContextListConcurrencyBug56653)