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

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:

  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. In order to override the behaviour of sudo's umask and use the default directly (i.e., not the union of the user and default sudo mask), one can add the following:

Defaults umask_override
mipadi

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
}

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How do I tell CMake to specify multiple linker script files to GCC?

분류에서Dev

How do I give files and directories created by FTP the correct permissions for Apache to read and write them?

분류에서Dev

How do I tell if a Windows 8.1 Product Keys is an OEM key?

분류에서Dev

How do I run a sudo command needing password input in the background?

분류에서Dev

how do i write EPS and postScript programs?

분류에서Dev

Java: How do I write a generic method?

분류에서Dev

How do I write applets for Cinnamon?

분류에서Dev

How do you tell apt to use files in /etc/apt/sources.list.d

분류에서Dev

How do I tell Firefox to only keep persistent cookies from sites I want?

분류에서Dev

How do I tell what's happening when I postback my view?

분류에서Dev

How do I save changed files?

분류에서Dev

How do I remove cached .deb files?

분류에서Dev

How do I tell apt-get install to stop trying to setup openssh-server?

분류에서Dev

A moose around method modifier applies to several attributes, how do I tell which attribute is being modified?

분류에서Dev

C++/CLI how do I tell if a handle isn't pointing to any object

분류에서Dev

How do I tell my internal IP to send to my external IP?

분류에서Dev

How do you sudo with xonsh?

분류에서Dev

How do I read and write image file locally for Flutter Web?

분류에서Dev

How do I write all lines from less to a file?

분류에서Dev

how do i write certain commands and call them into a page in php

분류에서Dev

How do I write an Android Application Record (AAR) using phonegap?

분류에서Dev

How can I tell if a machine has PAE?

분류에서Dev

How can I tell a function enters kernel or not

분류에서Dev

How do I add a new user with specific configuration files?

분류에서Dev

How do I export customized Libreoffice config files?

분류에서Dev

How do I execute symbolic linked files in node.js?

분류에서Dev

In Xcode how do I get files to open in the same window

분류에서Dev

How do I zip up multiple files on command line?

분류에서Dev

How do i copy files from one directory to another directory?

Related 관련 기사

  1. 1

    How do I tell CMake to specify multiple linker script files to GCC?

  2. 2

    How do I give files and directories created by FTP the correct permissions for Apache to read and write them?

  3. 3

    How do I tell if a Windows 8.1 Product Keys is an OEM key?

  4. 4

    How do I run a sudo command needing password input in the background?

  5. 5

    how do i write EPS and postScript programs?

  6. 6

    Java: How do I write a generic method?

  7. 7

    How do I write applets for Cinnamon?

  8. 8

    How do you tell apt to use files in /etc/apt/sources.list.d

  9. 9

    How do I tell Firefox to only keep persistent cookies from sites I want?

  10. 10

    How do I tell what's happening when I postback my view?

  11. 11

    How do I save changed files?

  12. 12

    How do I remove cached .deb files?

  13. 13

    How do I tell apt-get install to stop trying to setup openssh-server?

  14. 14

    A moose around method modifier applies to several attributes, how do I tell which attribute is being modified?

  15. 15

    C++/CLI how do I tell if a handle isn't pointing to any object

  16. 16

    How do I tell my internal IP to send to my external IP?

  17. 17

    How do you sudo with xonsh?

  18. 18

    How do I read and write image file locally for Flutter Web?

  19. 19

    How do I write all lines from less to a file?

  20. 20

    how do i write certain commands and call them into a page in php

  21. 21

    How do I write an Android Application Record (AAR) using phonegap?

  22. 22

    How can I tell if a machine has PAE?

  23. 23

    How can I tell a function enters kernel or not

  24. 24

    How do I add a new user with specific configuration files?

  25. 25

    How do I export customized Libreoffice config files?

  26. 26

    How do I execute symbolic linked files in node.js?

  27. 27

    In Xcode how do I get files to open in the same window

  28. 28

    How do I zip up multiple files on command line?

  29. 29

    How do i copy files from one directory to another directory?

뜨겁다태그

보관