Deploy war. Make symbolic link in the generated directory. Symbolic link refer to the directory. Undeploy war. As a result, file of directory which referred by symbolic link was deleted. The following are the reproduction methods. 1.Deploy the sample.war in $TOMCAT_HOME/webapps/ 2.Make symbolic link in the generated directory. Symbolic link refer to the directory. [****@**** sample]# ln -s /tmp/sampledir/ sampleln [****@**** sample]# ls WEB-INF sampleln jsp [****@**** sample]# cd sampleln/ [****@**** sampleln]# ls samplefile.txt 3.Undeploy sample.war. 4.webapps/sample/ directory is delete. 5.File of directory which referred by symbolic link was deleted. [****@**** webapps]# cd /tmp/sampledir/ [****@**** sampledir]# ls The file of that directory must not delete! I made two patches. This patch added the conditional expression that it was a directory and was not the symbolic link. Index: java/org/apache/catalina/startup/ExpandWar.java =================================================================== --- java/org/apache/catalina/startup/ExpandWar.java (revision 798806) +++ java/org/apache/catalina/startup/ExpandWar.java (working copy) @@ -281,11 +281,17 @@ } for (int i = 0; i < files.length; i++) { File file = new File(dir, files[i]); - if (file.isDirectory()) { - deleteDir(file); - } else { - file.delete(); - } + try { + if (file.isDirectory() + && file.getCanonicalPath().equals(file.getAbsolutePath())) { + // Directory that is not symbolic link + deleteDir(file); + } else { + file.delete(); + } + } catch (IOException e) { + log.error(sm.getString("expandWar.canonicalizing",file.getAbsolutePath()), e); + } } return dir.delete(); This patch is LocalStrings Index: java/org/apache/catalina/startup/LocalStrings.properties =================================================================== --- java/org/apache/catalina/startup/LocalStrings.properties (revision 798806) +++ java/org/apache/catalina/startup/LocalStrings.properties (working copy) @@ -59,6 +59,7 @@ engineConfig.start=EngineConfig: Processing START engineConfig.stop=EngineConfig: Processing STOP expandWar.copy=Error copying {0} to {1} +expandWar.canonicalizing=Error delete file or directory [{0}] hostConfig.appBase=Application base directory {0} does not exist hostConfig.canonicalizing=Error delete redeploy resources from context [{0}] hostConfig.cce=Lifecycle event data object {0} is not a Host Best regards
Created attachment 24085 [details] add new patch I'm so sorry.My patch is broken. I provide new patch.
Created attachment 24086 [details] LocalStrings patch add new LocalStrings.patch
I am thinking this is WONTFIX. If a user starts generating symlinks AND relying on autodeploy - bad things will eventually happen.
Agree with Tim.
Note that Tomcat 7 includes alias support that provides a safe way of doing this sort of thing.