Merge pull request #454 from rekup/fix/firewalld

fix firewalld protocol

SUMMARY
This PR resolves an issue where opening a port (e.g. 25/tcp) resulted in opening all ports for the specified protocol (e.g. tcp)
Fixes #451
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
ansible.posix.firewalld
ADDITIONAL INFORMATION
Many thanks to @nerrehmit and every one else who helped troubleshooting this!
This commit is contained in:
softwarefactory-project-zuul[bot] 2023-05-04 15:25:13 +00:00 committed by GitHub
commit 202609e425
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- firewall - Fix issue where opening a specific port resulted in opening the whole protocol of the specified port

View file

@ -856,15 +856,16 @@ def main():
zone = module.params['zone'] zone = module.params['zone']
target = module.params['target'] target = module.params['target']
port = None
if module.params['port'] is not None: if module.params['port'] is not None:
if '/' in module.params['port']: if '/' in module.params['port']:
port, protocol = module.params['port'].strip().split('/') port, port_protocol = module.params['port'].strip().split('/')
else: else:
protocol = None port_protocol = None
if not protocol: if not port_protocol:
module.fail_json(msg='improper port format (missing protocol?)') module.fail_json(msg='improper port format (missing protocol?)')
else: else:
port = None port_protocol = None
port_forward_toaddr = '' port_forward_toaddr = ''
port_forward = None port_forward = None
@ -981,7 +982,7 @@ def main():
transaction = PortTransaction( transaction = PortTransaction(
module, module,
action_args=(port, protocol, timeout), action_args=(port, port_protocol, timeout),
zone=zone, zone=zone,
desired_state=desired_state, desired_state=desired_state,
permanent=permanent, permanent=permanent,
@ -993,7 +994,7 @@ def main():
if changed is True: if changed is True:
msgs.append( msgs.append(
"Changed port %s to %s" % ( "Changed port %s to %s" % (
"%s/%s" % (port, protocol), desired_state "%s/%s" % (port, port_protocol), desired_state
) )
) )