How do I tell sudo to write files with a umask of 0022?
- by mipadi
I recently upgrading to Snow Leopard. I have noticed that some files written by MacPorts are installed with the wrong permission -- they are written with a umask of 0077. I think I have narrowed down the problem:
The port command is invoked via sudo.
My .bashrc file specifies a umask of 0077.
On older versions of OS X (10.5 and below), sudo used the umask of the root user (which was 0022); however, now it uses my umask of 0077.
Is there anyway to have sudo use the old behavior? Right now, it's kind of annoying because I have to use sudo to run simple commands like port installed, port outdated, etc.
(The problem is described in more detail in this MacPorts ticket.)
Edit
I discovered the umask option for sudo, and in /etc/sudoers I added the following line:
Defaults umask=0022
However, this did not function as desired, because the real umask used by sudo is the union of the user mask with this default mask.