9

The catalina.out file is getting created with "-rw-r-----" permissions (i.e 640 permissions). I want to give read permission to "others" too but that is not happening.

Tried setting umask as 022 in setenv.sh and in other places but this did not help.

Also tried touching files manually using the same tomcat user and they are getting created with "-rw-rw-r--" (i.e 664 permissions). So not sure why tomcat is behaving this way.

Also don't want to manually change the permissions using chmod etc as this is a hack and needs to be repeated in case of file deletion.

janeshs
  • 793
  • 2
  • 12
  • 26

2 Answers2

12

Solved the problem by adding an environment variable called "UMASK" (all capitals) as follows. This env variable should be set before invoking catalina.sh.

export UMASK="0022"

To give some background, the catalina.sh script looks for UMASK environment variable (Optional). If this variable is not present in the environment, Tomcat uses default UMASK of 0027, else it uses the override value for umask.

janeshs
  • 793
  • 2
  • 12
  • 26
0

I am guessing you have already tried these solutions:

  1. setting umask in .profile/.bash_profile.
  2. Setting umask in etc/init.d/tomcat6 if it is installed.
  3. verified umask to be existing and restarted the process to check the file permission.

Try giving special permission to the log directory for the required user. Refer this link for complete configuration.

Community
  • 1
  • 1
Dextro67
  • 195
  • 9
  • [Dextro67](http://stackoverflow.com/users/3886428/dextro67) - I have already tried the 1st and 3rd options and they do not work. The 2nd option is not applicable in my case as tomcat is not a service in my installation. The last (4th) option is not relevant as I don't use logrotate. – janeshs Feb 24 '17 at 12:36
  • As already mentioned in my question, the umask is honoured when I manually create any file (using "touch" command) as "tomcat" user. But it is not honoured when tomcat (which is running as the same "tomcat" user) creates log files. Strange!! – janeshs Feb 24 '17 at 12:45
  • @janeshs Did you find out why Tomcat process did not honour the OS umask value? – Dextro67 Feb 27 '17 at 05:14
  • 1
    [@dextro67](http://stackoverflow.com/users/3886428/dextro67) - Yes, I verified the reason why Tomcat does not honour the OS umask value. Basically it forcefully overrides the OS umask if the custom environment variable UMASK (all caps) is not set. See the override code in catalina.sh below: `# Set UMASK unless it has been overridden if [ -z "$UMASK" ]; then UMASK="0027" fi umask $UMASK` – janeshs Mar 13 '17 at 08:39
  • If your going to set any env variables for tomcat you should be doing it in `./bin/setenv.sh` – LJ in NJ May 22 '18 at 12:37