Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 e.g. 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 launchctlsays:

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 (e.g. 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

like image 701
Ray Avatar asked Mar 18 '23 09:03

Ray


1 Answers

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

like image 70
Petr Matas Avatar answered Mar 28 '23 07:03

Petr Matas