Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/pyinfra/operations/selinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def port(protocol: Protocol | str, port_num: int, se_type: str | None = None, pr
current = host.get_fact(SEPort, protocol=protocol, port=port_num)
else:
port_info = host.get_fact(SEPorts)
current = port_info.get(protocol, {}).get(str(port_num), "")
current = port_info.get(protocol, {}).get(port_num, "")

if present:
option = "-a" if current == "" else ("-m" if current != se_type else "")
Expand All @@ -187,4 +187,4 @@ def port(protocol: Protocol | str, port_num: int, se_type: str | None = None, pr
if not direct_get:
if protocol not in port_info:
port_info[protocol] = {}
port_info[protocol][str(port_num)] = new_type
port_info[protocol][port_num] = new_type
19 changes: 0 additions & 19 deletions tests/operations/selinux.port/add_different.json

This file was deleted.

14 changes: 14 additions & 0 deletions tests/operations/selinux.port/add_different.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
args:
- tcp
- 22
- ssh_port_t
kwargs:
present: true
facts:
selinux.SEPorts:
tcp:
22: xray_port_t
server.Which:
command=sepolicy: null
commands:
- semanage port -m -t ssh_port_t -p tcp 22
17 changes: 0 additions & 17 deletions tests/operations/selinux.port/add_not_existing.json

This file was deleted.

14 changes: 14 additions & 0 deletions tests/operations/selinux.port/add_not_existing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
args:
- tcp
- 22
- ssh_port_t
kwargs:
present: true
facts:
selinux.SEPorts:
tcp:
22: ""
server.Which:
command=sepolicy: null
commands:
- semanage port -a -t ssh_port_t -p tcp 22
15 changes: 0 additions & 15 deletions tests/operations/selinux.port/add_not_existing_protocol.json

This file was deleted.

14 changes: 14 additions & 0 deletions tests/operations/selinux.port/add_not_existing_protocol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
args:
- tcp
- 22
- ssh_port_t
kwargs:
present: true
facts:
selinux.SEPorts:
udp:
53: dns_port_t
server.Which:
command=sepolicy: null
commands:
- semanage port -a -t ssh_port_t -p tcp 22
16 changes: 0 additions & 16 deletions tests/operations/selinux.port/add_same.json

This file was deleted.

14 changes: 14 additions & 0 deletions tests/operations/selinux.port/add_same.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
args:
- tcp
- 22
- ssh_port_t
kwargs:
present: true
facts:
selinux.SEPorts:
tcp:
22: ssh_port_t
server.Which:
command=sepolicy: null
commands: []
noop_description: "setype for 'tcp/22' is already 'ssh_port_t'"
17 changes: 0 additions & 17 deletions tests/operations/selinux.port/remove_existing.json

This file was deleted.

14 changes: 14 additions & 0 deletions tests/operations/selinux.port/remove_existing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
args:
- tcp
- 22
- ssh_port_t
kwargs:
present: false
facts:
selinux.SEPorts:
tcp:
22: ssh_port_t
server.Which:
command=sepolicy: null
commands:
- semanage port -d -p tcp 22
16 changes: 0 additions & 16 deletions tests/operations/selinux.port/remove_not_existing.json

This file was deleted.

14 changes: 14 additions & 0 deletions tests/operations/selinux.port/remove_not_existing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
args:
- tcp
- 22
- ssh_port_t
kwargs:
present: false
facts:
selinux.SEPorts:
port=22, protocol=tcp:
22: ""
server.Which:
command=sepolicy: null
commands: []
noop_description: "setype for 'tcp/22' is already unset"
Loading