简体   繁体   中英

Set umask in OS X Yosemite

I'd like to change my umask on my Mac. Before Yosemite I used the file /etc/launchd-user.conf file and just added the command umask 0077 .

The aim is to get proper file permissions when saving a file in any every GUI program eg Finder, Notes & Firefox. To add the umask in /etc/profile or ~/.profile don't solve the problem.

In Yosemite the files /etc/launchd.conf and /etc/launchd-user.conf aren't executed anymore. The man launchctl says:

The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations.

I tried different example using LaunchAgents. Which this I'm able to set environment variables (eg ENVIRONMENT_RC ) but the umask is never set.

/etc/environment

#!/bin/sh

umask 0077

launchctl setenv ENVIRONMENT_RC "yes"     # Debugging

/Library/LaunchAgents/environment.user.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>environment.user</string>
    <key>ProgramArguments</key>
    <array>
            <string>/bin/sh</string>
            <string>/etc/environment</string>
    </array>
    <key>KeepAlive</key>
    <false/>
    <key>RunAtLoad</key>
    <true/>
    <key>WatchPaths</key>
    <array>
        <string>/etc/environment</string>
    </array>
</dict>
</plist>

Any ideas to set the umask in OS X Yosemite?

Thanks,
Reto

There is a final solution in OS X Yosemite 10.10.3:

instead of /etc/launchctl-user.conf use: launchctl config user umask 002 (example umask for setting 775 permissions)

instead of system wide /etc/launchctl.conf use: launchctl config system umask 002 (example umask for setting 775 permissions)

Apple published the how-to for "Yosemite umask problem" update five days ago (Apr 8, 2015) here: https://support.apple.com/en-us/HT201684

Status report

Unfortunately there was no valid answer so far about this question. But never mind. The Apple Support have not a clue, either. They said the umask is not set anylonger in OS X. What a shame!

The umask subcommand from launchctl is gone but there is still a possibility to set the key word "Umask" in .plist files (eg used in /System/Library/LaunchDaemons/com.apple.configd.plist):

...
<plist version="1.0">
<dict>
...
    <key>Umask</key>
    <integer>18</integer>
</dict>
</plist>

My plan is to add this parameter to the LaunchAgent file which starts the first process in the user's context.

I keep you informed...

Regards,
Reto

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM