Monday, January 31, 2022

[SOLVED] Tomcat 8.5.42 permission denied when deleting files in webapp

Issue

I am currently migrating from Jdk7/Tomcat7 to JDK8/Tomcat8.5.42 on Debian 8.5. When installing a new version of my application I use a bash script which uses the tomcat user to make the installation, this script stoppes the tomcat, remove old app.war and its exploded app folder. With Tomcat 7 I haven't any permission issue during those operations but with the new version when deleting the app folder I have rm: cannot remove ... Permission denied error.

This is the ../webapps/

4.0K drwxrwxr-x  3 tomcat tomcat 4.0K Jul  2 16:48 .
4.0K drwxrwxr-x 12 tomcat tomcat 4.0K Jul  2 16:48 ..
4.0K drwxr-x---  7 tomcat tomcat 4.0K Jul  2 15:37 app

I don't know if it matters but user launching the script belongs to the tomcat group. Also note that the app folder is created by Tomcat since it's the result from app.war.

How can I configure Tomcat to give the right rights to all users belonging to the tomcat group so they can delete webapps content. Also I don't have a root access, so I would like one shot solution.

Thanks for your help.


Solution

Try to start tomcat with umask 007 instead of 027.

See https://en.wikipedia.org/wiki/Umask for futher reading about umask.

Found the hint here: https://grokbase.com/t/tomcat/users/035wyqr5rd/file-permissions-in-war-files

You have multiple options to set umask for a user: How to set umask for a system-user?



Answered By - Selaron
Answer Checked By - Pedro (WPSolving Volunteer)