Skip to content

Commit f456a4f

Browse files
committed
[pfsense_setup] added sshguard_whitelist option (fixes #129)
1 parent ae3145d commit f456a4f

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- pfsense_setup - added sshguard_whitelist option (https://github.com/pfsensible/core/issues/129).

plugins/modules/pfsense_setup.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@
153153
description: Show hostname on login banner
154154
required: false
155155
type: bool
156+
sshguard_whitelist:
157+
description: Addresses (in CIDR notation) listed will bypass login protection.
158+
required: false
159+
type: list
160+
elements: str
161+
version_added: 0.7.2
156162
"""
157163

158164
EXAMPLES = """
@@ -229,6 +235,7 @@
229235
roworderdragging=dict(required=False, type='bool'),
230236
logincss=dict(required=False, type='str'),
231237
loginshowhost=dict(required=False, type='bool'),
238+
sshguard_whitelist=dict(required=False, type='list', elements='str'),
232239
)
233240

234241

@@ -242,6 +249,14 @@ def p2o_dnslocalhost(self, name, params, obj):
242249
obj[name] = 'local'
243250

244251

252+
def p2o_network_list_to_space_separated(self, name, params, obj):
253+
if params[name] is not None:
254+
for net in params[name]:
255+
if not (self.pfsense.is_ipv4_network(net, strict=False) or self.pfsense.is_ipv6_network(net, strict=False)):
256+
self.module.fail_json(msg=f"Address {net} is not a valid network")
257+
obj[name] = ' '.join(params[name])
258+
259+
245260
def p2o_webguicss(self, name, params, obj):
246261
if params[name] is not None:
247262
# Add .css suffix if not present
@@ -262,6 +277,7 @@ def validate_webguicss(self, webguicss):
262277

263278
SETUP_ARG_ROUTE = dict(
264279
dnslocalhost=dict(parse=p2o_dnslocalhost),
280+
sshguard_whitelist=dict(parse=p2o_network_list_to_space_separated),
265281
webguicert=dict(parse=p2o_cert, validate=validate_cert),
266282
webguicss=dict(parse=p2o_webguicss, validate=validate_webguicss),
267283
)
@@ -526,6 +542,13 @@ def _update(self):
526542

527543
cmd += '$retval |= filter_configure();\n'
528544

545+
restart_sshguard = False
546+
for param in ['sshguard_whitelist']:
547+
if self.obj.get(param) != self.diff['before'].get(param):
548+
restart_sshguard = True
549+
if restart_sshguard:
550+
cmd += 'system_sshguard_stop();$retval |= system_syslogd_start(true);\n'
551+
529552
restart_webgui = False
530553
for param in ['ssl-certref']:
531554
if self.obj['webgui'].get(param) != self.diff['before']['webgui'].get(param):

0 commit comments

Comments
 (0)