Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provision: reload the firewall only once #1846

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
remove now unused 'changed' stuff
  • Loading branch information
OniriCorpe committed May 21, 2024
commit 33cb89918f835f2b1a4cccd69fbf14a596452ad6
10 changes: 2 additions & 8 deletions src/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,11 @@ def firewall_allow(
"ipv6",
]

changed = False

for p in protocols:
# Iterate over IP versions to add port
for i in ipvs:
if port not in firewall[i][p]:
firewall[i][p].append(port)
changed = True
else:
ipv = "IPv%s" % i[3]
logger.warning(m18n.n("port_already_opened", port=port, ip_version=ipv))
Expand All @@ -97,7 +94,7 @@ def firewall_allow(

# Update and reload firewall
_update_firewall_file(firewall)
if (not no_reload) or (changed):
if not no_reload:
return firewall_reload()


Expand Down Expand Up @@ -152,14 +149,11 @@ def firewall_disallow(
elif upnp_only:
ipvs = []

changed = False

for p in protocols:
# Iterate over IP versions to remove port
for i in ipvs:
if port in firewall[i][p]:
firewall[i][p].remove(port)
changed = True
else:
ipv = "IPv%s" % i[3]
logger.warning(m18n.n("port_already_closed", port=port, ip_version=ipv))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh actually we probably want to have an option to disable this warning, otherwise everytime a port is not to be "exposed" (= the vast majority of the apps ?), yunohost will display a warning during install/upgrade/... when provision ports

Similar stuff for port_already_open too

Expand All @@ -172,7 +166,7 @@ def firewall_disallow(

# Update and reload firewall
_update_firewall_file(firewall)
if (not no_reload) or (changed):
if not no_reload:
return firewall_reload()


Expand Down
Loading