Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/puppet/type/iptables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ module Puppet

newparam(:jump) do
desc "holds value of iptables --jump target
Possible values are: 'ACCEPT', 'DROP', 'REJECT', 'DNAT', 'SNAT', 'LOG', 'MASQUERADE', 'REDIRECT'.
Possible values are: 'ACCEPT', 'DROP', 'REJECT', 'DNAT', 'SNAT', 'LOG', 'MASQUERADE', 'REDIRECT', 'NOTRACK'.
Default value is 'ACCEPT'. While this is not the accepted norm, this is the more commonly used jump target.
Users should ensure they do an explicit DROP for all packets after all the ACCEPT rules are specified."
newvalues(:ACCEPT, :DROP, :REJECT, :DNAT, :SNAT, :LOG, :MASQUERADE, :REDIRECT)
newvalues(:ACCEPT, :DROP, :REJECT, :DNAT, :SNAT, :LOG, :MASQUERADE, :REDIRECT, :NOTRACK)
defaultto "ACCEPT"
end

Expand Down Expand Up @@ -292,7 +292,7 @@ def load_current_rules(numbered = false)

name = self.matched(l.scan(/--comment (\S+)/))

limit = self.matched(l.scan(/--limit (\S+)/))
limit = self.matched(l.scan(/-m --limit (\S+)/))
limit = "" unless limit

burst = self.matched(l.scan(/--limit-burst (\S+)/))
Expand Down Expand Up @@ -362,7 +362,7 @@ def matched(data)
nil
end

# Load a file and using the passed in rules hash load the
# Load a file and using the passed in rules hash load the
# rules contained therein.
def load_rules_from_file(rules, file_name, action)
if File.exist?(file_name)
Expand Down Expand Up @@ -468,7 +468,7 @@ def finalize
# Run iptables save to persist rules. The behaviour is to do nothing
# if we no nothing of the operating system.
persist_cmd = case Facter.value(:operatingsystem).downcase
when "fedora", "redhat", "centos"
when "fedora", "redhat", "centos", "scientific"
then "/sbin/service iptables save"
when "ubuntu", "debian"
then "/sbin/iptables-save > /etc/iptables.rules"
Expand Down Expand Up @@ -814,7 +814,7 @@ def initialize(args)
end

if value(:uid_owner).to_s != ""
strings[:uid_owner] = " -m owner --uid-owner " + value(:uid_owner).to_s
strings[:uid_owner] = " -m owner --uid-owner " + value(:uid_owner).to_s
end

if value(:limit).to_s != ""
Expand Down Expand Up @@ -900,13 +900,18 @@ def initialize(args)
if value(:redirect).to_s != ""
strings[:redirect] = " --to-ports " + value(:redirect).to_s
end
elsif value(:jump).to_s == "NOTRACK"
if value(:table).to_s != "raw"
invalidrule = true
err("NOTRACK only applies to table 'raw'.")
end
end

chain_prio = @@chain_order[value(:chain).to_s]

# Generate a rule entry for each source permutation.
sources.each { |source|

# Build a string of arguments in the required order.
rule_string = "%s" * 21 % [
strings[:table],
Expand All @@ -932,7 +937,7 @@ def initialize(args)
strings[:log_prefix],
strings[:redirect]
]

debug("iptables param: #{rule_string}")
if invalidrule != true
@@rules[table].push({
Expand Down