Preferences, permissions and problem-solving

Since its first beta-release, Mac OS X has suffered from ill-defined and pervasive problems thought to result from corruption of files used by the system.

Repairing permissions Mark 1

Until the introduction of System Integrity Protection (SIP) in 10.11 El Capitan, these generally resulted from files within the system acquiring incorrect permissions. To address this, Disk Utility had a feature whereby it could check and repair permissions of all major parts of the system, based on information contained in BoM files for system updates and installations. Repairing permissions in this way became one of the main panaceas in those older versions.

Although chiefly intended to provide better security protection, one of the benefits of SIP was that it largely prevented system files from gaining incorrect permissions, and the feature to repair them was removed from Disk Utility. In any case, because of SIP it was no longer possible for Disk Utility to change the permissions of files protected by SIP.

Repairing permissions Mark 2

When macOS 10.12 Sierra was released, a different problem appeared, in which permissions apparently became set incorrectly not in system files generally, but in the user’s Home folder, and specifically in ~/Library/Preferences. To address this Apple added a new verb to the already complex command tool diskutil, resetUserPermissions, and described how to use this in a support note. It’s perhaps no coincidence that this new problem appeared at about the same time that cfprefsd took on the management of those preference files.

At that time, the following problems were attributed by Apple to incorrect permissions in ~/Library/Preferences:

  • changes to preference settings, particularly those for System Preferences, do not ‘stick’;
  • changes made to the Dock do not ‘stick’;
  • you are asked to authenticate when trying to move or alter some folders in your Home folder;
  • when trying to save, you are told that the file is locked, or that you don’t have permission;
  • Preview, TextEdit, and App Store apps (which are sandboxed) may crash when opened;
  • alerts appear warning that the startup disk has no more space available for app memory;
  • Safari or SafariDAVClient use large amounts of resources (memory);
  • the Mac runs very slowly;
  • iTunes cannot sync a device;
  • there are problems with Photos or iPhoto libraries, including inability to import into the library, or forgetting the library each time the app is opened.

Most if not all of those could be attributable to problems arising from bugs in cfprefsd.

Fixing preference problems

Three years ago, Apple changed its recommendations to include running a new tool repairHomePermissions in Recovery mode, then re-installing macOS. Shortly afterwards, in June 2020 when Big Sur was in beta, Apple withdrew that support note and all reference to repairing permissions, although the tool is still available in Recovery mode even on Apple silicon Macs.

Regardless of support notes, there are still occasions when preference files and their permissions can cause problems. These fall into two categories:

  • a corrupt or damaged preference file can cause an app or other code to crash, usually when it’s being launched;
  • incorrect permissions on one or more preference files can prevent them working, and cause ill-defined and pervasive problems, as before.

Although these are now much less common, and the SSV ensures that system files can’t become corrupted as they did in the days before SIP, it’s important to know how to deal with them.

Delete a corrupt preference file

On most occasions, a preference file can be deleted in the normal way, either in Finder or Terminal, and it won’t return, as it won’t currently be managed by cfprefsd. The alternative is to use defaults:
defaults delete com.mycompany.appname
deletes all the key-value pairs within the preference file for com.mycompany.appname, leaving just the empty property list. This has the advantage that it can be used when cfprefsd is managing that file’s contents, so should always be reliable. Provided the app handles preferences correctly using UserDefaults, it should be able to repopulate the empty property list the next time that app is launched.

Check and repair permissions on preference files

Other than the Recovery tool repairHomePermissions, macOS provides no assistance for ensuring that preference and other files have correct permissions. Three years ago, I proposed a method that can include use of my free utility PermissionScanner to identify which files might need their permissions corrected. This still works in Ventura, and provided that it’s used with care can resolve these problems.

RepairPermissions2

The significant caution here is when working with files inside ~/Library/Containers, ~/Library/Group Containers,~/Library/Daemon Containers and similar managed folders. Because these form sandboxes, macOS manages them differently and tampering with their contents is likely to have unintended effects.

Summary

  • Repairing permissions on system files ceased with SIP in El Capitan.
  • Repairing permissions on Home folder preference files is no longer recommended by Apple, since Big Sur.
  • Safe and robust deletion of contents of a preference file can be performed using defaults delete.
  • Check and repair of preference and other files can be assisted by PermissionScanner.
  • Don’t tamper with files inside ~/Library/Containers, ~/Library/Group Containers and similar folders.
  • Repairing permissions is no longer the panacea it was before Big Sur.