Bug 37781 - Permission error causes malformed server.xml to be saved.
Summary: Permission error causes malformed server.xml to be saved.
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Webapps:Administration (show other bugs)
Version: 5.5.9
Hardware: Other Linux
: P2 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-04 20:33 UTC by George Sexton
Modified: 2006-04-18 22:55 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description George Sexton 2005-12-04 20:33:01 UTC
If:

1)you have a context, and the META-INF directory is not writable by the user
tomcat runs as
2)you use the Admin application to change the server configuration 
3)you use the commit changes button

The save will abort, leaving a malformed server.xml and the user will be told
that "changes were saved successfully" (or something similar). In essence, the
write aborts on the host, and closing tags for engines, services, as well as
other hosts are not written.

I think the user needs to be informed that the save failed. In the best case,
write of the server.xml should be atomic so that a malformed server.xml is not
written.

Here is the error log from when it happens:

2005-12-01 14:00:36,843 INFO http-8080-Processor14
org.apache.catalina.storeconfig.StandardContextSF - Store Context  separate with
backup (at file /home/chd/ROOT/META-INF/context.xml.2005-12-01.14-00-36 )
 2005-12-01 14:00:36,844 ERROR http-8080-Processor14
org.apache.catalina.storeconfig.StoreConfig - java.io.FileNotFoundException:
/home/chd/ROOT/META-INF/context.xml.new (Permission denied)
 2005-12-01 14:00:36,844 INFO http-8080-Processor14
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin] - action:
Debugging -- changes saved to conf/server.xml
 2005-12-01 14:03:26,667 INFO http-8080-Processor6
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin] - action:
Entered TreeControlTestAction:perform()
 2005-12-01 14:03:26,667 INFO http-8080-Processor6
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin] - action:
tree param is null
 2005-12-01 14:03:26,667 INFO http-8080-Processor6
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin] - action:
Select event on Catalina:type=Host,host=calendar.chc1.org
 2005-12-01 14:03:39,512 INFO http-8080-Processor14
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin] - action:
Entered TreeControlTestAction:perform()
 2005-12-01 14:03:39,512 INFO http-8080-Processor14
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin] - action:
tree param is null
 2005-12-01 14:03:39,512 INFO http-8080-Processor14
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin] - action:
Select event on Catalina:type=Service,serviceName=Catalina
 2005-12-01 14:06:02,231 INFO http-8080-Processor9
Comment 1 Yoav Shapira 2006-04-14 14:58:45 UTC
Good point, George.  I've added a patch in time for 5.5.17 that checks the
destination context config file is not null, indeed a file (as opposed to a
directory), and writeable by Tomcat.  If these checks pass, all is well,
otherwise a diagnostic message is written to the log and an exception thrown
before any file saving is done, so no corrupt server.xml will be written.
Comment 2 Peter Rossbach 2006-04-14 17:50:04 UTC
I have checkin a better version, for 5.5.17

But a bug with referenced war files outsite Host appBase exists. Currently context docBase from those
apps point to extract webapps/app directory. StoreConfig can't detect the orginal war file and 
redeployment crashed!
Comment 3 Yoav Shapira 2006-04-18 21:50:42 UTC
George, does the limited fix included in 5.5.17 help you at all?
Comment 4 George Sexton 2006-04-18 22:20:56 UTC
I actually deploy as an unpacked file so the WAR limitation doesn't affect me.

Truthfully, since I'm also using the Manager application to auto deploy new
hosts, I ended up writing my own server.xml file as part of my startup script.
It just seemed a lot easier to generate the server.xml as part of the startup
script rather than re-working the admin application to save the XML file.

Right now I'm running something like 280 virtual hosts on one Tomcat instance.
The Admin application just doesn't scale that big so I've pretty much abandoned it.
Comment 5 Peter Rossbach 2006-04-19 05:55:49 UTC
I have fix the StoreConfig external war file bug!

You can use the StoreConfig via ANT JMX operations without Admin app.