]> git.openstreetmap.org Git - chef.git/blob - cookbooks/networking/libraries/interfaces.rb
Avoid using tainted data to construct file names in exim configuration
[chef.git] / cookbooks / networking / libraries / interfaces.rb
1 class Chef
2   class Node
3     def interfaces(options = {}, &block)
4       interfaces = []
5
6       networking = construct_attributes[:networking] || {}
7       networking_interfaces = networking[:interfaces] || {}
8
9       networking_interfaces.each_value  do |interface|
10         next unless options[:role].nil? || interface[:role].to_s == options[:role].to_s
11         next unless options[:family].nil? || interface[:family].to_s == options[:family].to_s
12
13         if block.nil?
14           interfaces << interface
15         else
16           yield interface
17         end
18       end
19
20       interfaces
21     end
22   end
23 end