Skip to content

Commit

Permalink
Merge branch 'SLE-12-SP2' into SLE-12-SP3
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Nov 28, 2017
2 parents b4ce47a + 0e8b13e commit e5fc811
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 51 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.pot
*.log
*.trs
Makefile
/Makefile.am
Makefile.am.common
Expand All @@ -12,6 +15,7 @@ config.*
configure
configure.in
configure.ac
coverage/
install-sh
pluglib-bindings.ami
*/.dep
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:

before_install:
- docker build -t yast-yast2-image .

script:
# the "yast-travis-ruby" script is included in the base yastdevel/ruby image
# see https://github.com/yast/docker-yast-ruby/blob/master/yast-travis-ruby
Expand Down
42 changes: 26 additions & 16 deletions library/network/src/lib/network/susefirewall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def GetStartService
# @param [Boolean] start_service at Write() process
# @see #GetStartService()
def SetStartService(start_service)
if !SuSEFirewallIsInstalled()
if !SuSEFirewallIsSelectedOrInstalled()
Builtins.y2warning("Cannot set SetStartService")
return nil
end
Expand Down Expand Up @@ -97,7 +97,7 @@ def GetEnableService
#
# @param boolean start_service at Write() process
def SetEnableService(enable_service)
if !SuSEFirewallIsInstalled()
if !SuSEFirewallIsSelectedOrInstalled()
Builtins.y2warning("Cannot set SetEnableService")
return nil
end
Expand Down Expand Up @@ -536,21 +536,31 @@ def IsKnownZone(zone)
# installation)
#
# @return [Boolean] whether the selected firewall backend is installed
def SuSEFirewallIsInstalled
# Always recheck the status in inst-sys, user/solver might have change
# the list of packages selected for installation
# bnc#892935: in inst_finish, the package is already installed
def SuSEFirewallIsSelectedOrInstalled
return true if @needed_packages_installed

if Stage.initial
@needed_packages_installed = Pkg.IsSelected(@FIREWALL_PACKAGE) || PackageSystem.Installed(@FIREWALL_PACKAGE)
log.info "Selected for installation/installed -> #{@needed_packages_installed}"
elsif @needed_packages_installed.nil?
if Mode.normal
@needed_packages_installed = PackageSystem.CheckAndInstallPackages([@FIREWALL_PACKAGE])
log.info "CheckAndInstallPackages -> #{@needed_packages_installed}"
else
@needed_packages_installed = PackageSystem.Installed(@FIREWALL_PACKAGE)
log.info "Installed -> #{@needed_packages_installed}"
end
packages_selected = Pkg.IsSelected(@FIREWALL_PACKAGE)
log.info "Selected for installation -> #{packages_selected}"

return true if packages_selected
end

SuSEFirewallIsInstalled()
end

# Returns whether all needed packages are installed
#
# @return [Boolean] whether the selected firewall backend is installed
def SuSEFirewallIsInstalled
return true if @needed_packages_installed

if Mode.normal
@needed_packages_installed = PackageSystem.CheckAndInstallPackages([@FIREWALL_PACKAGE])
log.info "CheckAndInstallPackages -> #{@needed_packages_installed}"
else
@needed_packages_installed = PackageSystem.Installed(@FIREWALL_PACKAGE)
log.info "Installed -> #{@needed_packages_installed}"
end

@needed_packages_installed
Expand Down
3 changes: 1 addition & 2 deletions library/network/src/lib/network/susefirewall2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ def Read
end

# bnc #887406
if !FileUtils.Exists(CONFIG_FILE) || !SuSEFirewallIsInstalled()
if !FileUtils.Exists(CONFIG_FILE) || !SuSEFirewallIsSelectedOrInstalled()
log.warn "No firewall config -> firewall can't be read"
FillUpEmptyConfig()
return false
Expand Down Expand Up @@ -2741,7 +2741,6 @@ def full_init_on_boot(new_state)
publish function: :AddServiceSupportIntoZone, type: "void (string, string)", private: true
publish variable: :check_and_install_package, type: "boolean", private: true
publish function: :SetInstallPackagesIfMissing, type: "void (boolean)"
publish variable: :needed_packages_installed, type: "boolean", private: true
publish function: :SuSEFirewallIsInstalled, type: "boolean ()"
publish variable: :fw_service_can_be_configured, type: "boolean", private: true
publish function: :GetModified, type: "boolean ()"
Expand Down
4 changes: 3 additions & 1 deletion library/network/src/modules/NetworkInterfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,9 @@ def adapt_old_config!
# @param [String] device name
# @param [Hash] ifcfg a map with netconfig (ifcfg) configuration
def add_device(device, ifcfg)
devtype = GetTypeFromIfcfg(ifcfg) || GetType(device)
# if possible use dev type as available in /sys otherwise use ifcfg config
# as a fallback for device type detection
devtype = GetTypeFromIfcfgOrName(device, ifcfg)
@Devices[devtype] ||= {}
@Devices[devtype][device] = ifcfg
end
Expand Down
57 changes: 37 additions & 20 deletions library/network/test/susefirewall_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,65 +18,82 @@ def reset_SuSEFirewallIsInstalled_cache

describe FakeFirewall do

describe "#SuSEFirewallIsInstalled" do
before(:each) do
reset_SuSEFirewallIsInstalled_cache
end

describe "#SuSEFirewallIsSelectedOrInstalled" do
context "while in inst-sys" do
it "returns whether SuSEfirewall2 is selected for installation or already installed" do
expect(Yast::Stage).to receive(:stage).and_return("initial").at_least(:once)

# Value is not cached
expect(Yast::Pkg).to receive(:IsSelected).and_return(true, false, false).exactly(3).times
# Fallback: if not selected, checks whether the package is installed
expect(Yast::PackageSystem).to receive(:Installed).and_return(false, true).twice
expect(subject).to receive(:SuSEFirewallIsInstalled).and_return(false, true).twice

# Selected
expect(subject.SuSEFirewallIsInstalled).to eq(true)
expect(subject.SuSEFirewallIsSelectedOrInstalled).to eq(true)
# Not selected and not installed
expect(subject.SuSEFirewallIsInstalled).to eq(false)
expect(subject.SuSEFirewallIsSelectedOrInstalled).to eq(false)
# Not selected, but installed
expect(subject.SuSEFirewallIsSelectedOrInstalled).to eq(true)
end
end

context "while on a running system or AutoYast config" do
it "returns whether SuSEfirewall2 was or could have been installed" do
expect(Yast::Stage).to receive(:stage).and_return("normal").twice

expect(subject).to receive(:SuSEFirewallIsInstalled).and_return(false, true).twice

expect(subject.SuSEFirewallIsSelectedOrInstalled).to eq(false)
expect(subject.SuSEFirewallIsSelectedOrInstalled).to eq(true)
end
end
end

describe "#SuSEFirewallIsInstalled" do
before(:each) do
reset_SuSEFirewallIsInstalled_cache
end

context "while in inst-sys" do
it "returns whether SuSEfirewall2 is installed or not" do
expect(Yast::Mode).to receive(:mode).and_return("installation").twice

# Checks whether the package is installed
expect(Yast::PackageSystem).to receive(:Installed).and_return(false, true).twice

expect(subject.SuSEFirewallIsInstalled).to eq(false)
expect(subject.SuSEFirewallIsInstalled).to eq(true)
# Value is cached if true
expect(subject.SuSEFirewallIsInstalled).to eq(true)
end
end

context "while on a running system (normal configuration)" do
it "returns whether SuSEfirewall2 was or could have been installed" do
expect(Yast::Stage).to receive(:stage).and_return("normal").at_least(:once)
expect(Yast::Mode).to receive(:mode).and_return("normal").at_least(:once)

# Value is cached
expect(Yast::PackageSystem).to receive(:CheckAndInstallPackages).and_return(true, false).twice

expect(subject.SuSEFirewallIsInstalled).to eq(true)
expect(subject.SuSEFirewallIsInstalled).to eq(true)
# Value is cached if true
expect(subject.SuSEFirewallIsInstalled).to eq(true)

reset_SuSEFirewallIsInstalled_cache

expect(subject.SuSEFirewallIsInstalled).to eq(false)
expect(subject.SuSEFirewallIsInstalled).to eq(false)
expect(subject.SuSEFirewallIsInstalled).to eq(false)
end
end

context "while in AutoYast config" do
it "returns whether SuSEfirewall2 is installed" do
expect(Yast::Stage).to receive(:stage).and_return("normal").at_least(:once)
expect(Yast::Mode).to receive(:mode).and_return("autoinst_config").at_least(:once)

# Value is cached
expect(Yast::PackageSystem).to receive(:Installed).and_return(false, true).twice

expect(subject.SuSEFirewallIsInstalled).to eq(false)
expect(subject.SuSEFirewallIsInstalled).to eq(false)
expect(subject.SuSEFirewallIsInstalled).to eq(false)

reset_SuSEFirewallIsInstalled_cache

expect(subject.SuSEFirewallIsInstalled).to eq(true)
expect(subject.SuSEFirewallIsInstalled).to eq(true)
# Value is cached if true
expect(subject.SuSEFirewallIsInstalled).to eq(true)
end
end
Expand Down
14 changes: 3 additions & 11 deletions library/network/test/susefirewalld_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,19 @@ def reset_FirewallDIsInstalled_cache
end

context "while in inst-sys" do
it "returns whether FirewallD is selected for installation or already installed" do
expect(Yast::Stage).to receive(:stage).and_return("initial").at_least(:once)
it "returns whether FirewallD is installed or not" do
expect(Yast::Mode).to receive(:mode).and_return("installation").at_least(:twice)

# Value is not cached
expect(Yast::Pkg).to receive(:IsSelected).and_return(true, false, false).exactly(3).times
# Fallback: if not selected, checks whether the package is installed
# Checks whether the package is installed
expect(Yast::PackageSystem).to receive(:Installed).and_return(false, true).twice

# Selected
expect(subject.SuSEFirewallIsInstalled).to eq(true)
# Not selected and not installed
expect(subject.SuSEFirewallIsInstalled).to eq(false)
# Not selected, but installed
expect(subject.SuSEFirewallIsInstalled).to eq(true)
end
end

context "while on a running system (normal configuration)" do
it "returns whether FirewallD was or could have been installed" do
expect(Yast::Stage).to receive(:stage).and_return("normal").at_least(:once)
expect(Yast::Mode).to receive(:mode).and_return("normal").at_least(:once)

expect(Yast::PackageSystem).to receive(:CheckAndInstallPackages).and_return(true, false)
Expand All @@ -70,7 +63,6 @@ def reset_FirewallDIsInstalled_cache

context "while in AutoYast config" do
it "returns whether FirewallD is installed" do
expect(Yast::Stage).to receive(:stage).and_return("normal").at_least(:once)
expect(Yast::Mode).to receive(:mode).and_return("autoinst_config").at_least(:once)

expect(Yast::PackageSystem).to receive(:Installed).and_return(false, true)
Expand Down
8 changes: 8 additions & 0 deletions library/network/testsuite/tests/NetworkInterfaces2.out
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Dir .network.value."eth0.3": ["BOOTPROTO", "ETHERDEVICE", "STARTMODE"]
Read .network.value."eth0.3".BOOTPROTO "dhcp"
Read .network.value."eth0.3".ETHERDEVICE "eth0"
Read .network.value."eth0.3".STARTMODE "manual"
Read .target.stat "/sys/class/net/eth0.3/type" nil
Read .target.string "/sys/class/net/eth0.3/type" nil
Dir .network.value."eth5": ["BOOTPROTO", "STARTMODE"]
Read .network.value."eth5".BOOTPROTO "dhcp"
Read .network.value."eth5".STARTMODE "manual"
Expand Down Expand Up @@ -112,6 +114,8 @@ Read .network.value."myvlantoo".BOOTPROTO "dhcp"
Read .network.value."myvlantoo".ETHERDEVICE "eth0"
Read .network.value."myvlantoo".STARTMODE "manual"
Read .network.value."myvlantoo".VLAN_ID "2"
Read .target.stat "/sys/class/net/myvlantoo/type" nil
Read .target.string "/sys/class/net/myvlantoo/type" nil
Dir .network.value."ppp5": ["BOOTPROTO", "STARTMODE"]
Read .network.value."ppp5".BOOTPROTO "dhcp"
Read .network.value."ppp5".STARTMODE "manual"
Expand All @@ -126,10 +130,14 @@ Dir .network.value."virtlan4": ["BOOTPROTO", "ETHERDEVICE", "STARTMODE"]
Read .network.value."virtlan4".BOOTPROTO "dhcp"
Read .network.value."virtlan4".ETHERDEVICE "eth0"
Read .network.value."virtlan4".STARTMODE "manual"
Read .target.stat "/sys/class/net/virtlan4/type" nil
Read .target.string "/sys/class/net/virtlan4/type" nil
Dir .network.value."vlan3": ["BOOTPROTO", "ETHERDEVICE", "STARTMODE"]
Read .network.value."vlan3".BOOTPROTO "dhcp"
Read .network.value."vlan3".ETHERDEVICE "eth0"
Read .network.value."vlan3".STARTMODE "manual"
Read .target.stat "/sys/class/net/vlan3/type" nil
Read .target.string "/sys/class/net/vlan3/type" nil
Return true
Dump all=$["arc":$["arc5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "atm":$["atm5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "ci":$["ci5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "ctc":$["ctc5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "dummy":$["dummy5":$["BOOTPROTO":"static", "IPADDR":"1.2.3.4", "NETMASK":"255.0.0.0", "PREFIXLEN":"8", "STARTMODE":"manual"]], "escon":$["escon5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "eth":$["eth5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"], "eth6":$["BOOTPROTO":"static", "IPADDR":"1.2.3.4", "NETMASK":"255.255.255.255", "PREFIXLEN":"32", "STARTMODE":"manual"], "eth7":$["STARTMODE":"manual"], "eth8":$["IPADDR":"1.2.3.4", "NETMASK":"255.0.0.0", "PREFIXLEN":"8", "STARTMODE":"manual"], "eth9":$["IPADDR":"1.2.3.4", "NETMASK":"255.0.0.0", "PREFIXLEN":"8", "STARTMODE":"manual"]], "fddi":$["fddi5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "hippi":$["hippi5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "hsi":$["hsi5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "ippp":$["ippp5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "iucv":$["iucv5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "lo":$["lo":$["BROADCAST":"127.255.255.255", "IPADDR":"127.0.0.1", "NETMASK":"255.0.0.0", "NETWORK":"127.0.0.0", "PREFIXLEN":"8", "STARTMODE":"auto"]], "mynet":$["mynet0":$["BOOTPROTO":"dhcp", "STARTMODE":"auto"]], "myri":$["myri5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "ppp":$["ppp5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "tr":$["tr5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]], "vlan":$["eth0.3":$["BOOTPROTO":"dhcp", "ETHERDEVICE":"eth0", "STARTMODE":"manual"], "myvlantoo":$["BOOTPROTO":"dhcp", "ETHERDEVICE":"eth0", "STARTMODE":"manual", "VLAN_ID":"2"], "virtlan4":$["BOOTPROTO":"dhcp", "ETHERDEVICE":"eth0", "STARTMODE":"manual"], "vlan3":$["BOOTPROTO":"dhcp", "ETHERDEVICE":"eth0", "STARTMODE":"manual"]]]
Dump NetworkInterfaces::Write
Expand Down
19 changes: 19 additions & 0 deletions package/yast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
-------------------------------------------------------------------
Tue Nov 28 09:50:05 UTC 2017 - mfilka@suse.com

- bnc#956755, bnc#1061306 (mfilka)
- fixed storing device information to avoid incorrect "not found"
states when querying NetworkInterfaces subsequently
- knut.anderssen@suse.com:
- Adapted SuSEFirewallIsInstalled() to return true only when the
package is already installed or checked and installed in normal
mode.
- Added SuSEFirewallIsSelectedOrInstalled() which behaves as the
old SuSEFirewallIsInstalled() method.
(bnc#1037214)
- Adapted calls to use SuSEFirewallIsSelectedOrInstalled() when
the methods can be called even with just Pkg selection.
- gsouza@suse.com:
- Warning messages shouldn't open UI in command-line mode
- 3.2.37.2

-------------------------------------------------------------------
Thu Jul 20 11:27:46 UTC 2017 - jreidinger@suse.com

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


Name: yast2
Version: 3.2.37.1
Version: 3.2.37.2
Release: 0
Summary: YaST2 - Main Package
License: GPL-2.0
Expand All @@ -39,6 +39,7 @@ BuildRequires: rubygem(%{rb_default_ruby_abi}:cheetah)
BuildRequires: update-desktop-files
# For running RSpec tests during build
BuildRequires: rubygem(%{rb_default_ruby_abi}:rspec)
BuildRequires: update-desktop-files
# Needed already in build time
BuildRequires: yast2-core >= 2.18.12
BuildRequires: yast2-devtools >= 3.1.10
Expand Down Expand Up @@ -69,6 +70,7 @@ Requires: rubygem(%{rb_default_ruby_abi}:cfa)
Requires: sysconfig >= 0.80.0
# for running scripts
Requires: rubygem(%{rb_default_ruby_abi}:cheetah)
Requires: sysconfig >= 0.80.0
# ag_ini section_private
# ag_ini with (un)quoting support
Requires: yast2-core >= 2.23.0
Expand Down

0 comments on commit e5fc811

Please sign in to comment.