Skip to content

Commit

Permalink
Merge 9f71c74 into 78c1beb
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jan 10, 2019
2 parents 78c1beb + 9f71c74 commit 6b9af8c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 15 deletions.
7 changes: 7 additions & 0 deletions package/yast2-firewall.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Jan 10 12:53:49 UTC 2019 - Josef Reidinger <jreidinger@suse.com>

- Ensure that custom zones use unique name (fate#324662)
- Explicitly mention that masquerade is IPv4 only (fate#324662)
- 4.1.6

-------------------------------------------------------------------
Tue Jan 8 13:22:25 CET 2019 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-firewall.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-firewall
Version: 4.1.5
Version: 4.1.6
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
7 changes: 5 additions & 2 deletions src/lib/y2firewall/dialogs/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ class Zone < CWM::Popup
# @param zone [Y2Firewall::Firewalld::Zone] holder for configuration or
# existing zone
# @param new_zone [Boolean] if it creates new zone or edit existing
def initialize(zone, new_zone = false)
# @param existing_names [Array<String>] names have to be unique, so pass existing ones
# which cannot be used.
def initialize(zone, new_zone: false, existing_names: [])
textdomain "firewall"
@zone = zone
@new_zone = new_zone
@existing_names = existing_names
end

def title
Expand All @@ -43,7 +46,7 @@ def contents
MinWidth(70,
VBox(
# do not allow to change name for already created zone
Left(NameWidget.new(@zone, disabled: !@new_zone)),
Left(NameWidget.new(@zone, disabled: !@new_zone, existing_names: @existing_names)),
VSpacing(1),
Left(ShortWidget.new(@zone)),
VSpacing(1),
Expand Down
3 changes: 2 additions & 1 deletion src/lib/y2firewall/widgets/pages/zones.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def label

def handle
zone = Y2Firewall::Firewalld::Zone.new(name: "draft")
result = Dialogs::Zone.run(zone, true)
result = Dialogs::Zone.run(zone, new_zone: true,
existing_names: firewall.zones.map(&:name))
if result == :ok
zone.relations.map { |r| zone.send("#{r}=", []) }
firewall.zones << zone
Expand Down
38 changes: 28 additions & 10 deletions src/lib/y2firewall/widgets/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ module Dialogs
class NameWidget < CWM::InputField
include Yast::I18n

def initialize(zone, disabled: false)
def initialize(zone, disabled: false, existing_names: [])
textdomain "textdomain"
@zone = zone
@disabled = disabled
@existing_names = existing_names
end

def init
self.value = @zone.name
self.value = @zone.name || ""
@disabled ? disable : enable
end

Expand All @@ -44,11 +45,17 @@ def label
end

def validate
return true if value.to_s.match?(/^\w+$/)

Yast::Report.Error(_("Please, provide a valid alphanumeric name for the zone"))
focus
false
if !value.to_s.match?(/^\w+$/)
Yast::Report.Error(_("Please, provide a valid alphanumeric name for the zone"))
focus
false
elsif @existing_names.include?(value.to_s)
Yast::Report.Error(_("Name is already used. Please choose different name."))
focus
false
else
true
end
end

def store
Expand All @@ -71,7 +78,7 @@ def initialize(zone)
end

def init
self.value = @zone.short
self.value = @zone.short || ""
end

def label
Expand Down Expand Up @@ -108,7 +115,7 @@ def initialize(zone)
end

def init
self.value = @zone.description
self.value = @zone.description || ""
end

def label
Expand Down Expand Up @@ -167,7 +174,7 @@ def initialize(zone)
end

def label
_("Masquerade")
_("IPv4 Masquerade")
end

def init
Expand All @@ -177,6 +184,17 @@ def init
def store
@zone.masquerade = value
end

def help
format(_(
"<b>%s</b> sets masquerade for given zone. Option is for IPv4 only." \
"For IPv6 command line tool firewall-cmd and rich rules needs to be used." \
"IP Masquerade, also called IPMASQ or MASQ, allows one or more computers in " \
"a network without assigned IP addresses to communicate using server’s" \
"assigned IP address."
),
label)
end
end
end
end
2 changes: 1 addition & 1 deletion test/lib/y2firewall/dialogs/zone_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
include_examples "CWM::Dialog"

let(:zone) { Y2Firewall::Firewalld::Zone.new(name: "test") }
subject { described_class.new(zone, false) }
subject { described_class.new(zone) }
end
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def stub_module(name, fake_class = nil)

# some tests have translatable messages
ENV["LANG"] = "en_US.UTF-8"
ENV["LC_ALL"] = "en_US.UTF-8"

if ENV["COVERAGE"]
require "simplecov"
Expand Down

0 comments on commit 6b9af8c

Please sign in to comment.