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

Replace SuSEFirewall2 by firewalld #26

Merged
merged 2 commits into from
Feb 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions package/yast2-ftp-server.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Jan 29 19:35:29 UTC 2018 - knut.anderssen@suse.com

- SuSEFirewall2 replaced by firewalld (fate#323460)
- 4.0.0

-------------------------------------------------------------------
Mon Jul 10 14:20:16 CEST 2017 - schubi@suse.de

Expand Down
9 changes: 5 additions & 4 deletions package/yast2-ftp-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@


Name: yast2-ftp-server
Version: 3.3.0
Version: 4.0.0
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: %{name}-%{version}.tar.bz2

# Wizard::SetDesktopTitleAndIcon
Requires: yast2 >= 2.21.22
# SuSEFirewall2 replace by firewalld (fate#323460)
Requires: yast2 >= 4.0.39
Requires: yast2-inetd
BuildRequires: update-desktop-files
BuildRequires: yast2
# SuSEFirewall2 replace by firewalld (fate#323460)
BuildRequires: yast2 >= 4.0.39
BuildRequires: yast2-devtools >= 3.1.10
BuildRequires: rubygem(%rb_default_ruby_abi:rspec)
BuildRequires: rubygem(%rb_default_ruby_abi:yast-rake)
Expand Down
26 changes: 8 additions & 18 deletions src/include/ftp-server/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ def initialize_ftp_server_dialogs(include_target)
Yast.include include_target, "ftp-server/helps.rb"
Yast.include include_target, "ftp-server/wid_functions.rb"





# map for description of widget later in CWNTree
# widget_descr (vsftpd)
#
Expand Down Expand Up @@ -1513,19 +1509,15 @@ def perfor_settings
deep_copy(result)
end


# Init function where are added firewall
#
# @return [Hash{String => Object}] map for firewall settings


def FirewallSettingsPure
result = {}

Ops.set(result, "services", ["service:pure-ftpd"])
Ops.set(result, "display_details", true)

deep_copy(result)
{
"services" => ["pure-ftpd"],
"display_details" => true
}
end

# Init function where are added firewall
Expand All @@ -1534,12 +1526,10 @@ def FirewallSettingsPure


def FirewallSettingsVs
result = {}

Ops.set(result, "services", ["service:vsftpd"])
Ops.set(result, "display_details", true)

deep_copy(result)
{
"services" => ["vsftpd"],
"display_details" => true
}
end


Expand Down
59 changes: 27 additions & 32 deletions src/modules/FtpServer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def main
Yast.import "Package"
Yast.import "CommandLine"
Yast.import "Users"
Yast.import "SuSEFirewall"
Yast.import "SuSEFirewallServices"
Yast.import "PortAliases"

# Data was modified?
Expand Down Expand Up @@ -241,6 +239,10 @@ def main
@write_only = false
end

def firewalld
@firewalld ||= Y2Firewall::Firewalld.instance
end

# Read current pure-ftpd configuration
#
# @return [Boolean] successfull
Expand Down Expand Up @@ -472,7 +474,7 @@ def ReadSettings
end
#read firewall settings
progress_orig = Progress.set(false)
SuSEFirewall.Read
firewalld.read
Progress.set(progress_orig)
#read existing upload directory for vsftpd
result = ReadVSFTPDUpload() if @vsftpd_edit
Expand Down Expand Up @@ -539,36 +541,29 @@ def WriteFirewallSettings
port_range = ""
active_port = ""

if SuSEFirewall.IsStarted
if Ops.get(@EDIT_SETTINGS, "PassiveMode") == "YES"
port_range = Ops.add(
Ops.add(Ops.get(@EDIT_SETTINGS, "PasMinPort"), ":"),
Ops.get(@EDIT_SETTINGS, "PasMaxPort")
)
else
active_port = PortAliases.IsKnownPortName("ftp-data") ? "ftp-data" : "20"
end

suse_config = {
"tcp_ports" => [
PortAliases.IsKnownPortName("ftp") ? "ftp" : "21",
active_port != "" ? active_port : port_range
]
}
return true if !firewalld.running?

if @vsftpd_edit
return SuSEFirewallServices.SetNeededPortsAndProtocols(
"service:vsftpd",
suse_config
)
else
return SuSEFirewallServices.SetNeededPortsAndProtocols(
"service:pure-ftpd",
suse_config
)
end
if Ops.get(@EDIT_SETTINGS, "PassiveMode") == "YES"
port_range = Ops.add(
Ops.add(Ops.get(@EDIT_SETTINGS, "PasMinPort"), ":"),
Ops.get(@EDIT_SETTINGS, "PasMaxPort")
Copy link
Member

Choose a reason for hiding this comment

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

can it be nil? if yes, then result can be a bit strange in this add

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't be nil. When it is left blank in the Input then it its filled with 1024.

)
else
return true
active_port = PortAliases.IsKnownPortName("ftp-data") ? "ftp-data" : "20"
end

tcp_ports = [
PortAliases.IsKnownPortName("ftp") ? "ftp" : "21",
active_port != "" ? active_port : port_range
]

service = @vsftpd_edit ? "pure-ftpd" : "vsftpd"

begin
return Y2Firewall::Firewalld::Service.modify_ports(name: service, tcp_ports: tcp_ports)
rescue Y2Firewall::Firewalld::Service::NotFound
y2error("Firewalld 'cluster' service is not available.")
return false
end
end

Expand Down Expand Up @@ -630,7 +625,7 @@ def WriteSettings
if result
# write configuration to the firewall
progress_orig = Progress.set(false)
result = SuSEFirewall.Write
result = firewalld.write
Progress.set(progress_orig)
end
result
Expand Down