Bug 43117

Summary: Dangerousness of workDir setting on Context
Product: Tomcat 5 Reporter: Takayuki Kaneko <kanekotky>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 5.5.26   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Takayuki Kaneko 2007-08-14 01:09:44 UTC
Hi, I'd like to point out the dangerousness of workDir setting on Context.

If workDir is an empty string, i.e. workDir=AA, then workDir will be set as
CATALINA_HOME.
Therefore if application will be reloaded, then the files in CATALINA_HOME will
be deleted.

I know this problem is caused by wrong configuration, but it is too dangerous,
anyway.

I propose a patch.

Index: /trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- /trunk/java/org/apache/catalina/core/StandardContext.java	(revision 565643)
+++ /trunk/java/org/apache/catalina/core/StandardContext.java	(working copy)
@@ -5006,7 +5006,7 @@
 
         // Acquire (or calculate) the work directory path
         String workDir = getWorkDir();
-        if (workDir == null) {
+        if (workDir == null || workDir.length() == 0) {
 
             // Retrieve our parent (normally a host) name
             String hostName = null;
Comment 1 Mark Thomas 2008-05-03 12:51:49 UTC
Many thanks for the patch. It has been applied to trunk and proposed for 6.0.x and 5.5.x.
Comment 2 Mark Thomas 2008-05-15 12:40:10 UTC
The patch has been applied to 6.0.x and will be in 6.0.17 onwards.
Comment 3 Mark Thomas 2008-07-30 13:28:07 UTC
This has been fixed in 5.5.x and will be included in 5.5.27 onwards.