This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new a81bcf07d8 Fix BZ 68035 - allow deployment from appBase or xmlBase
a81bcf07d8 is described below

commit a81bcf07d8f9b2f88b7a672b8e03a6d7bf10025e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 6 19:40:13 2023 +0000

    Fix BZ 68035 - allow deployment from appBase or xmlBase
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=68035
---
 .../apache/catalina/manager/ManagerServlet.java    | 32 ++++++++++++++--------
 webapps/docs/changelog.xml                         | 10 +++++++
 2 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/manager/ManagerServlet.java 
b/java/org/apache/catalina/manager/ManagerServlet.java
index c09dbe5647..ea89e4439f 100644
--- a/java/org/apache/catalina/manager/ManagerServlet.java
+++ b/java/org/apache/catalina/manager/ManagerServlet.java
@@ -932,25 +932,33 @@ public class ManagerServlet extends HttpServlet 
implements ContainerServlet {
                             
writer.println(smClient.getString("managerServlet.mkdirFail", configBase));
                             return;
                         }
-                        File localConfig = new File(configBase, baseName + 
".xml");
-                        if (localConfig.isFile() && !localConfig.delete()) {
-                            
writer.println(smClient.getString("managerServlet.deleteFail", localConfig));
-                            return;
+                        File localConfigFile = new File(configBase, baseName + 
".xml");
+                        File configFile = new File(config);
+                        // Skip delete and copy if source == destination
+                        if 
(!configFile.getCanonicalPath().equals(localConfigFile.getCanonicalPath())) {
+                            if (localConfigFile.isFile() && 
!localConfigFile.delete()) {
+                                
writer.println(smClient.getString("managerServlet.deleteFail", 
localConfigFile));
+                                return;
+                            }
+                            ExpandWar.copy(configFile, localConfigFile);
                         }
-                        ExpandWar.copy(new File(config), localConfig);
                     }
                     if (war != null) {
-                        File localWar;
+                        File localWarFile;
                         if (war.endsWith(".war")) {
-                            localWar = new File(host.getAppBaseFile(), 
baseName + ".war");
+                            localWarFile = new File(host.getAppBaseFile(), 
baseName + ".war");
                         } else {
-                            localWar = new File(host.getAppBaseFile(), 
baseName);
+                            localWarFile = new File(host.getAppBaseFile(), 
baseName);
                         }
-                        if (localWar.exists() && !ExpandWar.delete(localWar)) {
-                            
writer.println(smClient.getString("managerServlet.deleteFail", localWar));
-                            return;
+                        File warFile = new File(war);
+                        // Skip delete and copy if source == destination
+                        if 
(!warFile.getCanonicalPath().equals(localWarFile.getCanonicalPath())) {
+                            if (localWarFile.exists() && 
!ExpandWar.delete(localWarFile)) {
+                                
writer.println(smClient.getString("managerServlet.deleteFail", localWarFile));
+                                return;
+                            }
+                            ExpandWar.copy(warFile, localWarFile);
                         }
-                        ExpandWar.copy(new File(war), localWar);
                     }
                 } finally {
                     removeServiced(name);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ef17aee76b..8df7bf0490 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -189,6 +189,16 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Web applications">
+    <changelog>
+      <fix>
+        <bug>68035</bug>: Correct a regression in the fix for <bug>56248</bug>
+        that prevented deployment via the Manager of a WAR or directory that 
was
+        already present in the <code>appBase</code> or a context file that was
+        already present in the <code>xmlBase</code>. (markt)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Other">
     <changelog>
       <add>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to