def self.set_named_security_info(path, type, args)
owner = args[:owner]
group = args[:group]
dacl = args[:dacl]
sacl = args[:sacl]
owner = owner.pointer if owner && owner.respond_to?(:pointer)
group = group.pointer if group && group.respond_to?(:pointer)
dacl = dacl.pointer if dacl && dacl.respond_to?(:pointer)
sacl = sacl.pointer if sacl && sacl.respond_to?(:pointer)
security_information = 0
security_information |= OWNER_SECURITY_INFORMATION if args.has_key?(:owner)
security_information |= GROUP_SECURITY_INFORMATION if args.has_key?(:group)
security_information |= DACL_SECURITY_INFORMATION if args.has_key?(:dacl)
security_information |= SACL_SECURITY_INFORMATION if args.has_key?(:sacl)
if args.has_key?(:dacl_inherits)
security_information |= (args[:dacl_inherits] ? UNPROTECTED_DACL_SECURITY_INFORMATION : PROTECTED_DACL_SECURITY_INFORMATION)
end
if args.has_key?(:sacl_inherits)
security_information |= (args[:sacl_inherits] ? UNPROTECTED_SACL_SECURITY_INFORMATION : PROTECTED_SACL_SECURITY_INFORMATION)
end
hr = SetNamedSecurityInfoW(path.to_wstring, type, security_information, owner, group, dacl, sacl)
if hr != ERROR_SUCCESS
Chef::ReservedNames::Win32::Error.raise!
end
end