https://issues.apache.org/bugzilla/show_bug.cgi?id=47626
Summary: File of directory which referred by symbolic link was
deleted.
Product: Tomcat 6
Version: 6.0.20
Platform: All
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
AssignedTo: [email protected]
ReportedBy: [email protected]
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 (
https://svn.apache.org/viewcvs.cgi?view=rev&rev=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 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=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
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]