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

Sle15 sp1 merge #124

Merged
merged 13 commits into from
Apr 29, 2019
7 changes: 7 additions & 0 deletions package/yast2-firewall.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Apr 26 12:30:53 UTC 2019 - jreidinger <jreidinger@suse.com>

- change proposal naming and add option to set cpu mitigations
(bsc#1128707)
- 4.2.0

-------------------------------------------------------------------
Tue Mar 26 23:44:33 UTC 2019 - knut.anderssen@suse.com

Expand Down
4 changes: 3 additions & 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.11
Version: 4.2.0
Copy link
Member

Choose a reason for hiding this comment

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

This is the very same change as in the SP1 branch, right? Then we can keep the SP1 version, it should be changed only when doing TW or SP2 change not present in SP1...

Copy link
Member Author

Choose a reason for hiding this comment

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

but I modify spec, so spec is not same and I think in that case if htere is differ, we need to have different version, not?

Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand All @@ -38,6 +38,8 @@ Requires: yast2 >= 4.1.67

# ButtonBox widget
Conflicts: yast2-ycp-ui-bindings < 2.17.3
# CpiMitigations
Conflicts: yast2-bootloader < 4.2.1
Copy link
Member Author

Choose a reason for hiding this comment

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

this is different to SP1 version as in TW bootloader version is higher.


Provides: yast2-config-firewall
Obsoletes: yast2-config-firewall
Expand Down
56 changes: 50 additions & 6 deletions src/lib/y2firewall/clients/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# find current contact information at www.suse.com.

require "yast"
require "erb"
require "y2firewall/firewalld/api"
require "y2firewall/proposal_settings"
require "y2firewall/dialogs/proposal"
Expand All @@ -45,7 +46,8 @@ class Proposal < ::Installation::ProposalClient
LINK_ENABLE_SSHD = "firewall--enable_sshd".freeze,
LINK_DISABLE_SSHD = "firewall--disable_sshd".freeze,
LINK_OPEN_VNC = "firewall--open_vnc".freeze,
LINK_CLOSE_VNC = "firewall--close_vnc".freeze
LINK_CLOSE_VNC = "firewall--close_vnc".freeze,
LINK_CPU_MITIGATIONS = "firewall--cpu_mitigations".freeze
].freeze

LINK_FIREWALL_DIALOG = "firewall".freeze
Expand All @@ -60,11 +62,12 @@ def initialize
end

def description
# TODO: temporary dgettext only to avoid new translation
{
# Proposal title
"rich_text_title" => _("Firewall and SSH"),
"rich_text_title" => Yast::Builtins.dgettext("security", "Security"),
# Menu entry label
"menu_title" => _("&Firewall and SSH"),
"menu_title" => Yast::Builtins.dgettext("ncurses-pkg", "&Security"),
"id" => LINK_FIREWALL_DIALOG
}
end
Expand Down Expand Up @@ -106,15 +109,56 @@ def write
# Obtain and call the corresponding method for the clicked link.
def call_proposal_action_for(link)
action = link.gsub("firewall--", "")
@settings.public_send("#{action}!")
if action == "cpu_mitigations"
bootloader_dialog
else
@settings.public_send("#{action}!")
end
end

# Array with the available proposal descriptions.
#
# @return [Array<String>] services and ports descriptions
def proposals
# Filter proposals with content and sort them
[firewall_proposal, sshd_proposal, ssh_port_proposal, vnc_fw_proposal].compact
# Filter proposals with content
[cpu_mitigations_proposal, firewall_proposal, sshd_proposal,
ssh_port_proposal, vnc_fw_proposal].compact
end

# Returns the cpu mitigation part of the bootloader proposal description
# Returns nil if this part should be skipped
# @return [String] proposal html text
def cpu_mitigations_proposal
require "bootloader/bootloader_factory"
bl = ::Bootloader::BootloaderFactory.current
return nil if bl.name == "none"

mitigations = bl.cpu_mitigations

res = _("CPU Mitigations: ") + "<a href=\"#{LINK_CPU_MITIGATIONS}\">" +
ERB::Util.html_escape(mitigations.to_human_string) + "</a>"
log.info "mitigations output #{res.inspect}"
res
end

def bootloader_dialog
require "bootloader/config_dialog"
Yast.import "Bootloader"

begin
# do it in own dialog window
Yast::Wizard.CreateDialog
dialog = ::Bootloader::ConfigDialog.new(initial_tab: :kernel)
settings = Yast::Bootloader.Export
result = dialog.run
if result != :next
Yast::Bootloader.Import(settings)
else
Yast::Bootloader.proposed_cfg_changed = true
end
ensure
Yast::Wizard.CloseDialog
end
end

# Returns the VNC-port part of the firewall proposal description
Expand Down
9 changes: 7 additions & 2 deletions test/lib/y2firewall/clients/proposal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@
require "y2firewall/clients/proposal"

describe Y2Firewall::Clients::Proposal do
let(:client) { described_class.new }
subject(:client) { described_class.new }
let(:proposal_settings) { Y2Firewall::ProposalSettings.instance }

before do
# skip bootloader proposal to avoid build dependency on it
allow(subject).to receive(:cpu_mitigations_proposal)
end

describe "#initialize" do
it "instantiates a new proposal settings" do
expect(Y2Firewall::ProposalSettings).to receive(:instance)

client
described_class.new
end
end

Expand Down