How do I tell sudo to write files with a umask of 0022?

Posted by mipadi on Super User See other posts from Super User or by mipadi
Published on 2009-12-07T16:19:05Z Indexed on 2011/06/21 0:24 UTC
Read the original article Hit count: 532

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:

  1. The port command is invoked via sudo.
  2. My .bashrc file specifies a umask of 0077.
  3. 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.

© Super User or respective owner

Related posts about osx

Related posts about osx-snow-leopard