Skip to content

Commit 7ce568e

Browse files
committed
Reinstating $failsafe_ssh
See: example42#34 Resolves example42#34
1 parent f785aa2 commit 7ce568e

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

Diff for: manifests/init.pp

+11-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
# [*enable_v6*]
5252
# Use this module with IPv6. Defaults to false.
5353
#
54+
# [*failsafe_ssh*]
55+
# Bool. Insert a rule allowing iptables at all cost. This is to prevent accidental
56+
# lockouts when implementing this module. You may want to disable this, and add
57+
# the desired rules yourself (allowing to implement specific white- and blacklists,
58+
# as well as blocking bruteforce attacks).
59+
#
5460
# [*template*]
5561
# The template file to use when config=file
5662
#
@@ -149,6 +155,7 @@
149155
$default_order = 5000,
150156
$enable_v4 = $iptables::params::enable_v4,
151157
$enable_v6 = $iptables::params::enable_v6,
158+
$failsafe_ssh = true,
152159
$template = '',
153160
$mode = 'concat',
154161
$version = 'present',
@@ -266,8 +273,11 @@
266273

267274
include iptables::ruleset::default_action
268275
include iptables::ruleset::loopback
276+
277+
if any2bool($failsafe_ssh) {
278+
include iptables::ruleset::failsafe_ssh
279+
}
269280

270-
# Todo: For now this always evaluates to false, no service is getting restarted
271281
if ! $bool_service_override_restart {
272282
service { 'iptables':
273283
ensure => $iptables::manage_service_ensure,

Diff for: manifests/ruleset/failsafe_ssh.pp

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
class iptables::ruleset::failsafe_ssh (
3+
$chains = [ 'INPUT', 'OUTPUT' ],
4+
$target = 'ACCEPT',
5+
$order = 11,
6+
$port = 22,
7+
$log = false,
8+
$log_prefix = $iptables::log_prefix,
9+
$log_limit_burst = $iptables::log_limit_burst,
10+
$log_limit = $iptables::log_limit,
11+
$log_level = $iptables::log_level,
12+
) {
13+
14+
$discard = iptables_declare_multiple('iptables::rule',
15+
$chains, 'example42-failsafe-ssh-###name###',
16+
{
17+
table => 'filter',
18+
chain => '###name###',
19+
target => $target,
20+
protocol => 'tcp',
21+
port => $port,
22+
order => $order,
23+
log => $log,
24+
log_prefix => $log_prefix,
25+
log_limit_burst => $log_limit_burst,
26+
log_limit => $log_limit,
27+
log_level => $log_level
28+
})
29+
30+
}

0 commit comments

Comments
 (0)