Skip to content

Commit

Permalink
Merge pull request #17 from yast/master-bsc-1151649
Browse files Browse the repository at this point in the history
Using SysctlConfig class: Handle sysctl entries in different directories
  • Loading branch information
schubi2 committed Feb 26, 2020
2 parents 666af73 + 1020cc0 commit 2e993aa
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
7 changes: 7 additions & 0 deletions package/yast2-vpn.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Feb 26 10:27:01 CET 2020 - schubi@suse.de

- Using SysctlConfig class: Handle sysctl entries in different
directories (bsc#1151649).
- 4.2.4

-------------------------------------------------------------------
Fri Oct 4 14:26:08 UTC 2019 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
10 changes: 5 additions & 5 deletions package/yast2-vpn.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@


Name: yast2-vpn
Version: 4.2.3
Version: 4.2.4
Release: 0
Url: https://github.com/yast/yast-vpn
Source0: %{name}-%{version}.tar.bz2
Summary: A YaST module for configuring VPN gateway and clients
License: GPL-2.0
Group: System/YaST

# CFA::Sysctl
BuildRequires: yast2 >= 4.2.25
# CFA::SysctlConfig
BuildRequires: yast2 >= 4.2.67
BuildRequires: yast2-devtools >= 4.2.2
BuildRequires: update-desktop-files
BuildRequires: yast2-ruby-bindings
Expand All @@ -35,8 +35,8 @@ BuildRequires: rubygem(%{rb_default_ruby_abi}:yast-rake)

PreReq: %fillup_prereq

# CFA::Sysctl
Requires: yast2 >= 4.2.25
# CFA::SysctlConfig
Requires: yast2 >= 4.2.67
Requires: yast2-ruby-bindings

BuildArch: noarch
Expand Down
44 changes: 26 additions & 18 deletions src/modules/IPSecConf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Authors: Howard Guo <hguo@suse.com>

require "yast"
require "cfa/sysctl"
require "cfa/sysctl_config"

Yast.import "Package"
Yast.import "Service"
Expand Down Expand Up @@ -182,27 +182,35 @@ def Write
Service.Stop("strongswan")
end
# Configure IP forwarding
sysctl_modified = false
sysctlconfig_modified = false
if @ipsec_conns.any? { |name, conf|
leftsubnet = conf["leftsubnet"]
!leftsubnet.nil? && leftsubnet.include?(".")
}
sysctl_file.forward_ipv4 = true
sysctl_file.ipv4_forwarding_all = true
sysctl_file.ipv4_forwarding_default = true
sysctl_modified = true
sysctlconfig_file.forward_ipv4 = true
sysctlconfig_file.ipv4_forwarding_all = true
sysctlconfig_file.ipv4_forwarding_default = true
sysctlconfig_modified = true
end
if @ipsec_conns.any? { |name, conf|
leftsubnet = conf["leftsubnet"]
!leftsubnet.nil? && leftsubnet.include?(":")
}
sysctl_file.ipv6_forwarding_all = true
sysctl_file.ipv6_forwarding_default = true
sysctl_modified = true
sysctlconfig_file.ipv6_forwarding_all = true
sysctlconfig_file.ipv6_forwarding_default = true
sysctlconfig_modified = true
end
if sysctl_modified
sysctl_file.save
sysctl_apply = SCR.Execute(Yast::Path.new(".target.bash_output"), "/sbin/sysctl -p/etc/sysctl.conf 2>&1")
if sysctlconfig_modified
sysctlconfig_file.save unless sysctlconfig_file.conflict?
# --system : Load settings from all system configuration files.
# /boot/sysctl.conf-<kernelversion>
# /run/sysctl.d/*.conf
# /etc/sysctl.d/*.conf
# /usr/local/lib/sysctl.d/*.conf
# /usr/lib/sysctl.d/*.conf
# /lib/sysctl.d/*.conf
# /etc/sysctl.conf
sysctl_apply = SCR.Execute(Yast::Path.new(".target.bash_output"), "/sbin/sysctl --system 2>&1")
if !sysctl_apply["exit"].zero?
Report.LongError(_("Failed to apply IP forwarding settings using sysctl:") + sysctl_apply["stdout"])
successful = false
Expand Down Expand Up @@ -549,12 +557,12 @@ def uninstall_customrules
#
# @note It memoizes the value until {#main} is called.
#
# @return [Yast2::CFA::Sysctl]
def sysctl_file
return @sysctl_file if @sysctl_file
@sysctl_file = CFA::Sysctl.new
@sysctl_file.load
@sysctl_file
# @return [Yast2::CFA::SysctlConfig]
def sysctlconfig_file
return @sysctlconfig_file if @sysctlconfig_file
@sysctlconfig_file = CFA::SysctlConfig.new
@sysctlconfig_file.load
@sysctlconfig_file
end
end
IPSecConf = IPSecConfModule.new
Expand Down

0 comments on commit 2e993aa

Please sign in to comment.