Home » Questions » Computers [ Ask a new question ]

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

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

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:

Asked by: Guest | Views: 491
Total answers/comments: 2
Guest [Entry]

"I ended up adding the following to my .bashrc configuration script:

# Mimic old behavior of `sudo` on OS X Snow Leopard
sudo() {
old=$(umask)
umask 0022
command sudo ""$@""
umask $old
}"
Guest [Entry]

"how about:

sudo22() {
local UMASK=`umask`;
umask 22;
sudo ""$@"";
umask $UMASK
}"