]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
MODULES-1612 - sync socket
authorMorgan Haskel <morgan@puppetlabs.com>
Wed, 31 Dec 2014 00:19:10 +0000 (16:19 -0800)
committerMorgan Haskel <morgan@puppetlabs.com>
Wed, 31 Dec 2014 00:31:35 +0000 (16:31 -0800)
README.markdown
lib/puppet/provider/firewall/ip6tables.rb
spec/acceptance/firewall_spec.rb

index 362a74e4385bef13f1f51dd886ac42faaaa74df5..265d6efdbcbf276c2c366430a10dab22726fa895 100644 (file)
@@ -339,7 +339,7 @@ This type enables you to manage firewall rules within Puppet.
 
  * `ip6tables`: Ip6tables type provider
     * Required binaries: `ip6tables-save`, `ip6tables`.
-    * Supported features: `connection_limiting`, `dnat`, `hop_limiting`, `icmp_match`, `interface_match`, `iptables`, `isfirstfrag`, `ishasmorefrags`, `islastfrag`, `log_level`, `log_prefix`, `mark`, `owner`, `pkttype`, `rate_limiting`, `recent_limiting`, `reject_type`, `snat`, `state_match`, `tcp_flags`.
+    * Supported features: `connection_limiting`, `dnat`, `hop_limiting`, `icmp_match`, `interface_match`, `iptables`, `isfirstfrag`, `ishasmorefrags`, `islastfrag`, `log_level`, `log_prefix`, `mark`, `owner`, `pkttype`, `rate_limiting`, `recent_limiting`, `reject_type`, `snat`, `socket`, `state_match`, `tcp_flags`.
 
 * `iptables`: Iptables type provider
     * Required binaries: `iptables-save`, `iptables`.
index 6b5d8f9638d288d25f219746c42c507df4be282f..77156ec0a3f7e49790a5f1480f38e4a7f09043ab 100644 (file)
@@ -21,6 +21,7 @@ Puppet::Type.type(:firewall).provide :ip6tables, :parent => :iptables, :source =
   has_feature :ishasmorefrags
   has_feature :islastfrag
   has_feature :isfirstfrag
+  has_feature :socket
   has_feature :address_type
   has_feature :iprange
 
@@ -85,6 +86,7 @@ Puppet::Type.type(:firewall).provide :ip6tables, :parent => :iptables, :source =
     :rseconds         => "--seconds",
     :rsource          => "--rsource",
     :rttl             => "--rttl",
+    :socket           => "-m socket",
     :source           => "-s",
     :sport            => ["-m multiport --sports", "--sport"],
     :src_range        => '-m iprange --src-range',
@@ -104,7 +106,16 @@ Puppet::Type.type(:firewall).provide :ip6tables, :parent => :iptables, :source =
 
   # These are known booleans that do not take a value, but we want to munge
   # to true if they exist.
-  @known_booleans = [:ishasmorefrags, :islastfrag, :isfirstfrag, :rsource, :rdest, :reap, :rttl]
+  @known_booleans = [
+    :ishasmorefrags,
+    :islastfrag,
+    :isfirstfrag,
+    :rsource,
+    :rdest,
+    :reap,
+    :rttl,
+    :socket
+  ]
 
   # Create property methods dynamically
   (@resource_map.keys << :chain << :table << :action).each do |property|
@@ -143,9 +154,9 @@ Puppet::Type.type(:firewall).provide :ip6tables, :parent => :iptables, :source =
   @resource_list = [:table, :source, :destination, :iniface, :outiface,
     :proto, :ishasmorefrags, :islastfrag, :isfirstfrag, :src_range, :dst_range,
     :tcp_flags, :gid, :uid, :mac_source, :sport, :dport, :port, :dst_type,
-    :src_type, :pkttype, :name, :state, :ctstate, :icmp, :hop_limit, :limit,
-    :burst, :recent, :rseconds, :reap, :rhitcount, :rttl, :rname, :rsource,
-    :rdest, :jump, :todest, :tosource, :toports, :log_level, :log_prefix,
-    :reject, :connlimit_above, :connlimit_mask, :connmark]
+    :src_type, :socket, :pkttype, :name, :state, :ctstate, :icmp, :hop_limit,
+    :limit, :burst, :recent, :rseconds, :reap, :rhitcount, :rttl, :rname,
+    :rsource, :rdest, :jump, :todest, :tosource, :toports, :log_level,
+    :log_prefix, :reject, :connlimit_above, :connlimit_mask, :connmark]
 
 end
index cf920028491c5160aee5e14637aa8630dba50e86..703560f024b965a54cb2df1d80984dabacab86c5 100644 (file)
@@ -1250,6 +1250,61 @@ describe 'firewall type', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfami
       end
     end
 
+    # ip6tables has limited `-m socket` support
+    if default['platform'] !~ /el-5/ and default['platform'] !~ /ubuntu-1004/ and default['platform'] !~ /debian-6/ and default['platform'] !~ /sles/
+      describe 'socket' do
+        context 'true' do
+          it 'applies' do
+            pp = <<-EOS
+          class { '::firewall': }
+          firewall { '605 - test':
+            ensure   => present,
+            proto    => tcp,
+            port     => '605',
+            action   => accept,
+            chain    => 'INPUT',
+            socket   => true,
+            provider => 'ip6tables',
+          }
+            EOS
+
+            apply_manifest(pp, :catch_failures => true)
+          end
+
+          it 'should contain the rule' do
+            shell('ip6tables-save') do |r|
+              expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 605 -m socket -m comment --comment "605 - test" -j ACCEPT/)
+            end
+          end
+        end
+
+        context 'false' do
+          it 'applies' do
+            pp = <<-EOS
+          class { '::firewall': }
+          firewall { '606 - test':
+            ensure   => present,
+            proto    => tcp,
+            port     => '606',
+            action   => accept,
+            chain    => 'INPUT',
+            socket   => false,
+            provider => 'ip6tables',
+          }
+            EOS
+
+            apply_manifest(pp, :catch_failures => true)
+          end
+
+          it 'should contain the rule' do
+            shell('ip6tables-save') do |r|
+              expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 606 -m comment --comment "606 - test" -j ACCEPT/)
+            end
+          end
+        end
+      end
+    end
+
     # ip6tables only support addrtype on a limited set of platforms
     if default['platform'] =~ /el-7/ or default['platform'] =~ /debian-7/ or default['platform'] =~ /ubuntu-1404/
       ['dst_type', 'src_type'].each do |type|