Skip to content

Commit

Permalink
split ssh port open and ssh service enablement also in proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Apr 1, 2014
1 parent e82501a commit 0a8e609
Showing 1 changed file with 48 additions and 9 deletions.
57 changes: 48 additions & 9 deletions src/clients/firewall_stage1_proposal.rb
Expand Up @@ -45,8 +45,10 @@ def main

@LINK_ENABLE_FIREWALL = "firewall--enable_firewall_in_proposal"
@LINK_DISABLE_FIREWALL = "firewall--disable_firewall_in_proposal"
@LINK_ENABLE_SSH = "firewall--enable_ssh_in_proposal"
@LINK_DISABLE_SSH = "firewall--disable_ssh_in_proposal"
@LINK_ENABLE_SSH = "firewall--enable_ssh_port_in_proposal"
@LINK_DISABLE_SSH = "firewall--disable_ssh_port_in_proposal"
@LINK_ENABLE_SSHD = "firewall--enable_sshd_in_proposal"
@LINK_DISABLE_SSHD = "firewall--disable_sshd_in_proposal"
@LINK_ENABLE_VNC = "firewall--enable_vnc_in_proposal"
@LINK_DISABLE_VNC = "firewall--disable_vnc_in_proposal"
@LINK_FIREWALL_DIALOG = "firewall_stage1"
Expand All @@ -55,9 +57,10 @@ def main
if !SuSEFirewallProposal.GetProposalInitialized
# variables from control file
Builtins.y2milestone(
"Default firewall values: enable_firewall=%1, enable_ssh=%2",
"Default firewall values: enable_firewall=%1, enable_ssh=%2 enable_sshd=%3",
ProductFeatures.GetBooleanFeature("globals", "enable_firewall"),
ProductFeatures.GetBooleanFeature("globals", "firewall_enable_ssh")
ProductFeatures.GetBooleanFeature("globals", "firewall_enable_ssh"),
ProductFeatures.GetBooleanFeature("globals", "enable_sshd")
)

SuSEFirewall4Network.SetEnabled1stStage(
Expand All @@ -67,10 +70,14 @@ def main
#we're installing over SSH, propose opening SSH port (bnc#535206)
if Linuxrc.usessh
SuSEFirewall4Network.SetSshEnabled1stStage(true)
SuSEFirewall4Network.SetSshdEnabled(true)
else
SuSEFirewall4Network.SetSshEnabled1stStage(
ProductFeatures.GetBooleanFeature("globals", "firewall_enable_ssh")
)
SuSEFirewall4Network.SetSshdEnabled1stStage(
ProductFeatures.GetBooleanFeature("globals", "enable_sshd")
)
end

#we're installing over VNC, propose opening VNC port (bnc#734264)
Expand Down Expand Up @@ -109,17 +116,28 @@ def main

ssh_proposal = SuSEFirewall4Network.EnabledSsh1stStage ?
_(
"SSH service will be enabled, SSH port will be open (<a href=\"%s\">disable and close</a>)"
"SSH port will be open (<a href=\"%s\">close</a>)"
) % @LINK_DISABLE_SSH
:
_(
"SSH service will be disabled, SSH port will be blocked (<a href=\"%s\">enable and open</a>)"
"SSH port will be blocked (<a href=\"%s\">open</a>)"
) % @LINK_ENABLE_SSH

sshd_proposal = SuSEFirewall4Network.EnabledSsh ?
_(
"SSH service will be enabled (<a href=\"%s\">disable</a>)"
) % @LINK_DISABLE_SSHD
:
_(
"SSH service will be disabled (<a href=\"%s\">enable</a>)"
) % @LINK_ENABLE_SSHD




@output = "<ul>\n<li>#{firewall_proposal}</li>\n" +
"<li>#{ssh_proposal}</li>\n" +
"<li>#{sshd_proposal}</li>\n" +
vnc_proposal_element +
"</ul>\n"

Expand All @@ -131,6 +149,8 @@ def main
@LINK_DISABLE_FIREWALL,
@LINK_ENABLE_SSH,
@LINK_DISABLE_SSH,
@LINK_ENABLE_SSHD,
@LINK_DISABLE_SSHD,
@LINK_ENABLE_VNC,
@LINK_DISABLE_VNC
]
Expand Down Expand Up @@ -158,11 +178,17 @@ def main
)
elsif @chosen_link == @LINK_ENABLE_SSH
Builtins.y2milestone("Enabling SSH")
PackagesProposal.AddResolvables(@PROPOSAL_ID, :package, ["openssh"])
SuSEFirewall4Network.SetSshEnabled1stStage(true)
elsif @chosen_link == @LINK_DISABLE_SSH
Builtins.y2milestone("Disabling SSH")
SuSEFirewall4Network.SetSshEnabled1stStage(false)
elsif @chosen_link == @LINK_ENABLE_SSHD
Builtins.y2milestone("Enabling SSHD")
PackagesProposal.AddResolvables(@PROPOSAL_ID, :package, ["openssh"])
SuSEFirewall4Network.SetSshdEnabled(true)
elsif @chosen_link == @LINK_DISABLE_SSHD
Builtins.y2milestone("Disabling SSHD")
SuSEFirewall4Network.SetSshdEnabled(false)
PackagesProposal.RemoveResolvables(
@PROPOSAL_ID,
:package,
Expand Down Expand Up @@ -231,10 +257,19 @@ def FirewallDialogSimple
CheckBox(
Id("open_ssh_port"),
# TRANSLATORS: check-box label
_("Open SSH Port and Enable SSH Service"),
_("Open SSH Port"),
SuSEFirewall4Network.EnabledSsh1stStage
)
),
Left(
CheckBox(
Id("enable_sshd"),
# TRANSLATORS: check-box label
_("Enable SSH Service"),
SuSEFirewall4Network.EnabledSshd
)
),

Linuxrc.vnc ? vnc_support : Empty()
)
)
Expand All @@ -253,7 +288,7 @@ def FirewallDialogSimple
) +
_(
"<p>With enabled firewall, you can decide whether to open firewall port for SSH\n" +
"service and allow remote SSH logins. This will also enable SSH service (i.e. it\n" +
"service and allow remote SSH logins. Independentlu you can also enable SSH service (i.e. it\n" +
"will be started on computer boot).</p>"
) +
(Linuxrc.vnc ?
Expand Down Expand Up @@ -315,6 +350,10 @@ def FirewallDialogSimple
SuSEFirewall4Network.SetSshEnabled1stStage(open_ssh_port)
SuSEFirewall4Network.SetVncEnabled1stStage(open_vnc_port)
end

SuSEFirewall4Network.SetSshdEnabled(
UI::QueryWidget(Id("enable_sshd"), :Value)
)
end

# anything but enabling the firewall closes this dialog
Expand Down

0 comments on commit 0a8e609

Please sign in to comment.