Skip to content

Commit

Permalink
Fixed setting firewall.
Browse files Browse the repository at this point in the history
ProtectByFirewall method allways sets modified flag for firewall module.
So when called unconditionally it causes rewriting of network
configuration even when not needed (no zone changed).
  • Loading branch information
mchf committed Jun 6, 2016
1 parent 4623657 commit e84e621
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/modules/SuSEFirewall4Network.rb
Expand Up @@ -218,26 +218,29 @@ def AnyInterfacesHandledByFirewall
# @return [Boolean] if successful
def ProtectByFirewall(interface, zone, protect_status)
# Adding protection
if protect_status == true
Builtins.y2milestone(
"Enabling firewall because of '%1' interface",
interface
)
SuSEFirewall.AddInterfaceIntoZone(interface, zone)
if protect_status
log.info("Enabling firewall because of '#{interface}' interface")

if !SuSEFirewall.GetInterfacesInZone(zone).include?(interface)
SuSEFirewall.AddInterfaceIntoZone(interface, zone)
end

SuSEFirewall.SetEnableService(true)
SuSEFirewall.SetStartService(true)
# Removing protection
# Removing protection
else
# removing from all known zones
Builtins.foreach(SuSEFirewall.GetKnownFirewallZones) do |remove_from_zone|
zones = SuSEFirewall.GetKnownFirewallZones.select do |zone|
SuSEFirewall.GetInterfacesInZone(zone).include?(interface)
end
zones.each do |remove_from_zone|
SuSEFirewall.RemoveInterfaceFromZone(interface, remove_from_zone)
end
# if there are no other interfaces in configuration, stop firewall
# and remove it from boot process
if !AnyInterfacesHandledByFirewall()
Builtins.y2milestone(
"Disabling firewall, no interfaces are protected."
)
log.info("Disabling firewall, no interfaces are protected."
)
SuSEFirewall.SetEnableService(false)
SuSEFirewall.SetStartService(false)
end
Expand Down

0 comments on commit e84e621

Please sign in to comment.