in chef/cookbooks/uber_helpers/libraries/node_utils.rb [788:842]
def network_extension_enabled(extension_identifier, type)
extension_enabled = false
unless macos?
Chef::Log.warn('node.network_extension_enabled? called on non-OS X!')
return false, true
end
extension_enabled = false
extension_error = false
gnes_path = '/usr/local/bin/gnes'
if ::File.exist?(gnes_path)
cmd = shell_out("#{gnes_path} -identifier #{extension_identifier} -type #{type} -stdout-json")
if cmd.exitstatus.zero?
begin
cmd_json = Chef::JSONCompat.parse(cmd.stdout.to_s)
extension_enabled = cmd_json.nil? ? false : cmd_json['enabled']
rescue Chef::Exceptions::JSON::ParseError, FFI_Yajl::ParseError
extension_error = true
Chef::Log.warn('node.network_extension_enabled threw an error')
end
else
extension_error = true
Chef::Log.warn('node.network_extension_enabled could not find extension with requested type')
end
else
Chef::Log.info('node.network_extension_enabled could not find gnes binary - reverting to legacy check')
unless node.at_least?(node.chef_version, '17.7.22')
Chef::Log.warn('node.network_extension_enabled? requires chef v17.7.22 and higher when using legacy check')
return false, true
end
begin
network_extensions = CF::Preferences.get('$objects', 'com.apple.networkextension')
rescue TypeError
network_extensions = []
extension_error = true
Chef::Log.warn('node.network_extension_enabled threw an error')
end
network_extensions.each_with_index do |value, index|
if network_extensions[index - 1] == extension_identifier && !value.instance_of?(String)
extension_enabled = value['Enabled']
break
end
end
end
return extension_enabled, extension_error
end