7

The title says it all. I need Tomcat's webdav servlet to create files with rw-rw-r-- rights, but it keeps creating it as rw-r--r--. I tried to set up umask in /etc/profile, but it didn't help (although manualy created new files has desired permission settings). According to /etc/passwd the user that runs Tomcat has /etc/false as shell and has no bashrc in his home directory. The host os is Debian.

3 Answers 3

5

While this is completely a hack, open up tomcat/bin/startup.sh and set 'umask 0002' in it. You could also do this in catalina.sh, you get the idea - you could even find right where java launches in catalina.sh (search for "catalina.out") and put it directly above that logic block to ensure it's effective when java is let loose on your poor CPU.

2
  • 1
    I have found out that the umask is actually set in the init.d script (that's why setting it in /etc/profile didn't help). So I simply changed that line in /etc/init.d/tomcat6 script and it worked. Jun 30, 2010 at 14:44
  • 1
    Yah - the issue is that there's no standard for Tomcat/JBoss SysV startup, everyone rolls their own. Glad you found out for your situation and did the right thing.
    – user15590
    Jul 5, 2010 at 7:00
2

You can create an environment file for tomcat:

In /usr/shared/tomcat8/binwhere 8 is your appropriate tomcat version, create setenv.sh file containing:

#!/bin/bash umask 0002

1
  • Does not work not for tomcat 9. With tomcat 9 you need UMASK=0002 in setenv.sh Jul 4, 2023 at 18:58
0

I use custom scripts for starting and stopping tomcat, from which I set variables before calling the standard scripts.

Something like this:


#!/bin/sh

CATALINA_HOME=/usr/local/tomcat

CATALINA_BASE=/web/tomcat/catalina-base/myapp

JAVA_HOME=/usr/local/java

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_BASE/lib

JAVA_OPTS="-Xms1024m -Xmx1024m"

UMASK=0002

export JAVA_HOME CATALINA_HOME CATALINA_BASE JAVA_OPTS LD_LIBRARY_PATH UMASK

$CATALINA_HOME/bin/startup.sh &

exit $?

.................

The variable UMASK does the work you are looking for.

Hope this helps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .