This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new ea660de4f2 Fix BZ 68035 - allow deployment from appBase or xmlBase ea660de4f2 is described below commit ea660de4f2ca1e5c38bced88c95b304fed335856 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 096c6438ba..e0c087b587 100644 --- a/java/org/apache/catalina/manager/ManagerServlet.java +++ b/java/org/apache/catalina/manager/ManagerServlet.java @@ -933,25 +933,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 f64374e2f2..a39a4281b5 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -210,6 +210,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