SpecialFolders.Preferences Permissions Issue

I have been using SpecialFolders.Preferences for storing user preferences for years. But recently some users have started getting permissions issues on OS X 10.9.1 when writing to this folder. I have several 10.9.1 computers but cannot recreate the issue. If the customers log in as root, then the software can write to the preferences. One user went so far as to make sure the permissions for every folder of the folder tree had read/write permissions but even that failed. Any ideas as to why some users can write and other can’t? If Apple made a system level change in 10.9.1, it seems like it should effect everyone the same. But that isn’t the case.

Are you using NSUserDefaults / declares?

No, I am using SpecialFolders.Preferences. No declares as this needs to be a cross platform app.

Non-admin users likely cannot directly write files to SpecialFolder.Preferences on newer versions of OS X.

You can instead choose to use NSUserDefaults (part of macoslib) or use SpecialFolder.ApplicationData to create your own folder in “~Library/User/Application Support” for preferences files and other app-specific data.

I can write to that folder on all of my up-to-date 10.9.1 computers. So it can’t be just going to 10.9.1.

Do you mean “administrator” vs. non-administrator account? Or do you really mean Root? (Enabling the Root user on OS X is very unusual). For tracking down an issue like this, it’d be very important to use terminology carefully.

You should not use special folder.preferences for preferences believe it or not. You should use SpecialFolder.ApplicationData/yourAppName/, I tend to use SpecialFolder.ApplicationData/bundleIdentifier/ however if you are sandboxing your app this location is also legacy. You should read https://developer.apple.com/library/mac/documentation/security/conceptual/AppSandboxDesignGuide/MigratingALegacyApp/MigratingAnAppToASandbox.html

Like Mike says, the preferences folder is a leftover from the pre OS X days, and Apple have always recommended that you don’t write to this folder yourself. Apple recommend the use of CFPReferences or NSUserDefaults.

OS X 10.9, is the first OS version where I’ve seen Apple actually changing the way preferences work, so this doesn’t surprise me. While they recommend using NSUserDefaults/CFPreferences there is an issue whereby a cleaning app can remove the file, but this will break the CFPrefs Damon.

I think your best bet is to move over to using the Application Support folder (as Mike suggests). I would check in the App Support folder first, if there is no prefs file there, check in the preferences folders. Only read from the Prefs folder, but write to the App Support folder.