Method: ChefConfig::PathHelper.writable_sip_path?

Defined in:
lib/chef-config/path_helper.rb

.writable_sip_path?(path) ⇒ Boolean

Determine if the given path is on the exception list for macOS System Integrity Protection.

Returns:

  • (Boolean)


316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/chef-config/path_helper.rb', line 316

def self.writable_sip_path?(path)
  # todo: parse rootless.conf for this?
  sip_exceptions = [
    "/System/Library/Caches", "/System/Library/Extensions",
    "/System/Library/Speech", "/System/Library/User Template",
    "/usr/libexec/cups", "/usr/local", "/usr/share/man"
  ]
  sip_exceptions.each do |exception_path|
    return true if path.start_with?(exception_path)
  end
  ChefConfig.logger.error("Cannot write to a SIP path #{path} on macOS!")
  false
end