linux umask for sudo and apache

user1834095 picture user1834095 · Apr 2, 2014 · Viewed 7.5k times · Source

I want to make 002 the system-wide umask for all users (in Ubuntu). I managed to do so for all regular users using the instructions provided by @ephemient (From this post, thanks for that!). However I got 2 more problems.

Firstly, when sudoing, the root user seems to follow it's own settings, making files with the permissions 644 (instead of 664).

Secondly, the apache user (www-data) also seems to follow it's own settings (the same used by root?), making files with the permissions 644 (instead of 664). I don't like to put umask 002 in /etc/apache2/envvars, I'd rather change the setting assigning the 002 umask to apache in the first place.

How can I tackle those last 2 issues?

Answer

user1834095 picture user1834095 · Apr 10, 2014

I solved my own problems.

For the sudo permissions, I executed sudo visudo and added the line Defaults umask = 0002 to the end.

For the Apache user, I added the line umask 0002 to the end of the /etc/apache2/envvars (I couldn't find any better solution).