Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 4efc477

Browse files
committed
Added :none to one the values that the direction attribute can be set to. When direciton is set to :none, a rule to jump to the newly created chain will not be added to any direction chains.
1 parent 636d7b2 commit 4efc477

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ specified to make the jump conditional. For example:
143143
The rules specified under the `rule` attribute will only be evaluate for packets for which
144144
the rule in `chain_condition` holds.
145145

146+
Sometimes we might want to define a chain that can be only jumped from another chain we define.
147+
By default, all `simple_iptables_rule` chains will be jumped from one of the directions
148+
chains. To prevent jumping to the chain from the direction chains, we can set the direction attribute
149+
to the symbol `:none`. For example, consider a chain used to log
150+
151+
simple_iptables_rule "logging_drop" do
152+
direction :none
153+
rule ['-j LOG --log-level 4 --log-prefix "IPTABLES_DROP: "',
154+
'-j DROP']
155+
jump false
156+
end
157+
158+
We can then jump to this chain from other simple_iptables_rule chains, but a jump to this
159+
chain won't be added to a direction chain's set of rules.
160+
146161

147162
`simple_iptables_policy` Resource
148163
---------------------------------
@@ -338,6 +353,10 @@ Which results in the following iptables configuration:
338353

339354
Changes
340355
=======
356+
* 0.6.6 (Aug 1, 2014)
357+
* Added `:none` to one of the values that the attribute `direction` can be set to.
358+
When set to :none, a rule to jump to the chain created will not be added to any
359+
direction chains.
341360
* 0.6.5 (July 20, 2014)
342361
* Fix one-shot testing code to work with Chef versions prior to 11.12.
343362
* Make one-shot testing error line detection code more robust (#48 - Kim Tore Jensen)

providers/rule.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
if not node["simple_iptables"]["chains"][new_resource.table].include?(new_resource.chain)
1212
node.set["simple_iptables"]["chains"][new_resource.table] = node["simple_iptables"]["chains"][new_resource.table].dup << new_resource.chain unless ["PREROUTING", "INPUT", "FORWARD", "OUTPUT", "POSTROUTING"].include?(new_resource.chain)
13-
unless new_resource.chain == new_resource.direction
13+
unless new_resource.chain == new_resource.direction || new_resource.direction == :none
1414
node.set["simple_iptables"]["rules"][new_resource.table] << {:rule => "-A #{new_resource.direction} #{new_resource.chain_condition} --jump #{new_resource.chain}", :weight => new_resource.weight}
1515
end
1616
end

resources/rule.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
attribute :table, :equal_to => ["filter", "nat", "mangle", "raw"], :default => "filter"
55
attribute :rule, :kind_of => [String, Array], :required => true
66
attribute :jump, :kind_of => [String, FalseClass], :default => "ACCEPT"
7-
attribute :direction, :equal_to => ["INPUT", "FORWARD", "OUTPUT", "PREROUTING", "POSTROUTING"], :default => "INPUT"
7+
attribute :direction, :equal_to => ["INPUT", "FORWARD", "OUTPUT", "PREROUTING", "POSTROUTING", :none], :default => "INPUT"
88
attribute :chain_condition, :kind_of => [String]
99
attribute :weight, :kind_of => Integer, :default => 50
1010

0 commit comments

Comments
 (0)