commit yast2-network for openSUSE:Factory
Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2016-06-29 15:04:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-network (Old) and /work/SRC/openSUSE:Factory/.yast2-network.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-network" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes 2016-06-13 21:49:51.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-network.new/yast2-network.changes 2016-06-29 15:04:26.000000000 +0200 @@ -1,0 +2,34 @@ +Thu Jun 23 06:54:43 UTC 2016 - mfilka@suse.com + +- bnc#970320, bnc#865132, bnc#852604 + - do not overwrite Postfix MTA configuration when saving network + setup +- 3.1.158 + +------------------------------------------------------------------- +Tue Jun 21 05:37:31 UTC 2016 - igonzalezsosa@suse.com + +- bsc#984146 + - set AutoYaST keep_install_network parameter to 'true' by + default + - restore the default behavior present in SLE 12 SP1 and + openSUSE Leap 42.1 +- 3.1.157 + +------------------------------------------------------------------- +Tue Jun 14 05:43:26 UTC 2016 - mfilka@suse.com + +- bnc#983201 + - do not crash with internal error when configuring new device on + s390 +- 3.1.156 + +------------------------------------------------------------------- +Mon Jun 13 17:48:52 UTC 2016 - mfilka@suse.com + +- fate#318787 + - detect modifications when closing module, do not restart when + not needed. +- 3.1.155 + +------------------------------------------------------------------- Old: ---- yast2-network-3.1.154.tar.bz2 New: ---- yast2-network-3.1.158.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.FfLs6c/_old 2016-06-29 15:04:27.000000000 +0200 +++ /var/tmp/diff_new_pack.FfLs6c/_new 2016-06-29 15:04:27.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.154 +Version: 3.1.158 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-network-3.1.154.tar.bz2 -> yast2-network-3.1.158.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/package/yast2-network.changes new/yast2-network-3.1.158/package/yast2-network.changes --- old/yast2-network-3.1.154/package/yast2-network.changes 2016-06-09 15:23:31.000000000 +0200 +++ new/yast2-network-3.1.158/package/yast2-network.changes 2016-06-23 10:23:17.000000000 +0200 @@ -1,4 +1,38 @@ ------------------------------------------------------------------- +Thu Jun 23 06:54:43 UTC 2016 - mfilka@suse.com + +- bnc#970320, bnc#865132, bnc#852604 + - do not overwrite Postfix MTA configuration when saving network + setup +- 3.1.158 + +------------------------------------------------------------------- +Tue Jun 21 05:37:31 UTC 2016 - igonzalezsosa@suse.com + +- bsc#984146 + - set AutoYaST keep_install_network parameter to 'true' by + default + - restore the default behavior present in SLE 12 SP1 and + openSUSE Leap 42.1 +- 3.1.157 + +------------------------------------------------------------------- +Tue Jun 14 05:43:26 UTC 2016 - mfilka@suse.com + +- bnc#983201 + - do not crash with internal error when configuring new device on + s390 +- 3.1.156 + +------------------------------------------------------------------- +Mon Jun 13 17:48:52 UTC 2016 - mfilka@suse.com + +- fate#318787 + - detect modifications when closing module, do not restart when + not needed. +- 3.1.155 + +------------------------------------------------------------------- Wed Jun 1 14:16:08 UTC 2016 - igonzalezsosa@suse.com - Drop yast2-network-devel-doc package (fate#320356) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/package/yast2-network.spec new/yast2-network-3.1.158/package/yast2-network.spec --- old/yast2-network-3.1.154/package/yast2-network.spec 2016-06-09 15:23:31.000000000 +0200 +++ new/yast2-network-3.1.158/package/yast2-network.spec 2016-06-23 10:23:17.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.154 +Version: 3.1.158 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/src/clients/lan_auto.rb new/yast2-network-3.1.158/src/clients/lan_auto.rb --- old/yast2-network-3.1.154/src/clients/lan_auto.rb 2016-06-09 15:23:31.000000000 +0200 +++ new/yast2-network-3.1.158/src/clients/lan_auto.rb 2016-06-23 10:23:17.000000000 +0200 @@ -363,7 +363,7 @@ Ops.set( ret, "keep_install_network", - Ops.get_boolean(settings, "keep_install_network", false) + Ops.get_boolean(settings, "keep_install_network", true) ) if Ops.greater_than(Builtins.size(modules), 0) Ops.set(ret, "modules", modules) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/src/include/network/lan/complex.rb new/yast2-network-3.1.158/src/include/network/lan/complex.rb --- old/yast2-network-3.1.154/src/include/network/lan/complex.rb 2016-06-09 15:23:31.000000000 +0200 +++ new/yast2-network-3.1.158/src/include/network/lan/complex.rb 2016-06-23 10:23:17.000000000 +0200 @@ -171,7 +171,6 @@ def WriteDialog return :next if !Lan.Modified - LanItems.SetModified Wizard.RestoreHelp(Ops.get_string(@help, "write", "")) Lan.AbortFunction = -> { PollAbort() && ReallyAbort() } ret = Lan.Write @@ -508,7 +507,7 @@ if Stage.initial return Popup.ConfirmAbort(:painless) else - return ReallyAbort() if LanItems.modified + return ReallyAbort() if LanItems.GetModified return true end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/src/include/network/lan/hardware.rb new/yast2-network-3.1.158/src/include/network/lan/hardware.rb --- old/yast2-network-3.1.154/src/include/network/lan/hardware.rb 2016-06-09 15:23:31.000000000 +0200 +++ new/yast2-network-3.1.158/src/include/network/lan/hardware.rb 2016-06-23 10:23:17.000000000 +0200 @@ -787,7 +787,7 @@ end def devname_from_hw_dialog - UI.QueryWidget(Id(:ifcfg_name), :Value) + UI.QueryWidget(Id(:ifcfg_name), :Value) if UI.WidgetExists(Id(:ifcfg_name)) end def validate_hw(_key, _event) @@ -1157,11 +1157,6 @@ break elsif ret == :next if LanItems.type == "iucv" - # #176330, must be static - LanItems.nm_name = Ops.add( - "static-iucv-id-", - Convert.to_string(UI.QueryWidget(Id(:iucv_user), :Value)) - ) LanItems.device = Ops.add( "id-", Convert.to_string(UI.QueryWidget(Id(:iucv_user), :Value)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/src/include/network/runtime.rb new/yast2-network-3.1.158/src/include/network/runtime.rb --- old/yast2-network-3.1.154/src/include/network/runtime.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/src/include/network/runtime.rb 2016-06-23 10:23:17.000000000 +0200 @@ -43,7 +43,6 @@ path(".target.bash"), "/usr/lib/sendmail.d/update 2>/dev/null" ) - SCR.Execute(path(".target.bash"), "/usr/sbin/config.postfix 2>/dev/null") end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/src/lib/network/network_autoyast.rb new/yast2-network-3.1.158/src/lib/network/network_autoyast.rb --- old/yast2-network-3.1.154/src/lib/network/network_autoyast.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/src/lib/network/network_autoyast.rb 2016-06-23 10:23:17.000000000 +0200 @@ -128,7 +128,7 @@ # Checks if the profile asks for keeping installation network configuration def keep_net_config? - ret = ay_networking_section.fetch("keep_install_network", false) + ret = ay_networking_section.fetch("keep_install_network", true) log.info("NetworkAutoYast: keep installation network: #{ret}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/src/modules/Lan.rb new/yast2-network-3.1.158/src/modules/Lan.rb --- old/yast2-network-3.1.154/src/modules/Lan.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/src/modules/Lan.rb 2016-06-23 10:23:17.000000000 +0200 @@ -96,10 +96,14 @@ # Return a modification status # @return true if data was modified def Modified - ret = LanItems.GetModified || DNS.modified || Routing.Modified || - NetworkConfig.Modified || - NetworkService.Modified - ret + return true if LanItems.GetModified + return true if DNS.modified + return true if Routing.Modified + return true if NetworkConfig.Modified + return true if NetworkService.Modified + return true if SuSEFirewall.GetModified + + false end # function for use from autoinstallation (Fate #301032) @@ -412,7 +416,6 @@ Builtins.sleep(sl) return false if Abort() - LanItems.modified = false @initialized = true Progress.Finish if @gui @@ -709,7 +712,7 @@ "keep_install_network" => Ops.get_boolean( LanItems.autoinstall_settings, "keep_install_network", - false + true ) } Builtins.y2milestone("Exported map: %1", ay) @@ -988,7 +991,7 @@ configure_as_bridge_port(ifcfg) Ops.set(LanItems.Items, [current, "ifcfg"], new_ifcfg) - LanItems.modified = true + LanItems.SetModified LanItems.force_restart = true Builtins.y2internal("List %1", NetworkInterfaces.List("")) # re-read configuration to see new items in UI diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/src/modules/LanItems.rb new/yast2-network-3.1.158/src/modules/LanItems.rb --- old/yast2-network-3.1.154/src/modules/LanItems.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/src/modules/LanItems.rb 2016-06-23 10:23:17.000000000 +0200 @@ -200,12 +200,6 @@ "datagram" => _("datagram") } - # propose options - @proposal_valid = false - - # NetworkModules:: name - @nm_name = "" - Yast.include self, "network/hardware.rb" # Default values used when creating an emulated NIC for physical s390 hardware. @@ -380,7 +374,7 @@ if Ops.greater_than( Builtins.size(Ops.get_string(@driver_options, driver, "")), 0 - ) + ) " " else "" @@ -434,36 +428,43 @@ value end + # It replaces a tuple identified by replace_key in current item's udev rule + # + # Note that the tuple is identified by key only. However modification flag is + # set only if value was changed (in case when replace_key == new_key) + # + # @param replace_key [string] udev key which identifies tuple to be replaced + # @param new_key [string] new key to by used + # @param new_val [string] value for new key + # @return updated rule when replace_key is found, current rule otherwise def ReplaceItemUdev(replace_key, new_key, new_val) - new_rules = [] + new_rule = [] # udev syntax distinguishes among others: # = for assignment # == for equality checks operator = new_key == "NAME" ? "=" : "==" + current_rule = getUdevFallback - Builtins.foreach(getUdevFallback) do |row| - if Builtins.issubstring(row, replace_key) - row = Builtins.sformat("%1%2\"%3\"", new_key, operator, new_val) - end - new_rules = Builtins.add(new_rules, row) - end + return current_rule if !new_key || new_key.empty? + return current_rule if !new_val || new_val.empty? - Builtins.y2debug( - "LanItems::ReplaceItemUdev: udev rules %1", - Ops.get_list(@Items, [@current, "udev", "net"], []) - ) + i = current_rule.find_index { |tuple| tuple =~ /#{replace_key}/ } + if i + # deep_copy is most probably not neccessary because getUdevFallback does + # deep_copy on return value. However, getUdevFallback will be subect of refactoring + # so caution is must. Moreover new_rule is also return value so it should be + # copied anyway + new_rule = deep_copy(current_rule) + new_rule[i] = "#{new_key}#{operator}\"#{new_val}\"" + + SetModified() if current_rule != new_rule + end - Ops.set(@Items, [@current, "udev", "net"], new_rules) + log.info("LanItems#ReplaceItemUdev: #{current_rule} -> #{new_rule}") - Builtins.y2debug( - "LanItems::ReplaceItemUdev(%1, %2, %3) %4", - replace_key, - new_key, - new_val, - new_rules - ) + Items()[@current]["udev"]["net"] = new_rule - deep_copy(new_rules) + new_rule end # Updates device name. @@ -509,8 +510,9 @@ # Sets new device name for current item def rename(name) - if (GetCurrentName() != name) + if GetCurrentName() != name @Items[@current]["renamed_to"] = name + SetModified() else @Items[@current].delete("renamed_to") end @@ -676,6 +678,7 @@ def GetModified @modified end + # Function sets internal variable, which indicates, that any # settings were modified, to "true" def SetModified @@ -1012,6 +1015,8 @@ # It is full outer join in -> you can have hwinfo part with no coresponding # netconfig part (or vice versa) in @Items when the method is done. def Read + reset_cache + ReadHw() NetworkInterfaces.Read NetworkInterfaces.CleanHotplugSymlink @@ -1097,7 +1102,7 @@ autoinstall_settings["start_immediately"] = settings.fetch("start_immediately", false) autoinstall_settings["strict_IP_check_timeout"] = settings.fetch("strict_IP_check_timeout", -1) - autoinstall_settings["keep_install_network"] = settings.fetch("keep_install_network", false) + autoinstall_settings["keep_install_network"] = settings.fetch("keep_install_network", true) # FIXME: createS390Device does two things, it # - updates internal structures @@ -1133,12 +1138,12 @@ @Items, [key, "table_descr", "rich_descr"], "" -), + ), "table_descr" => Ops.get_list( @Items, [key, "table_descr", "table_descr"], [] -) + ) ) end end @@ -1151,7 +1156,7 @@ if Builtins.haskey( @request_firmware, Ops.get_string(@Items, [@current, "hwinfo", "driver"], "") - ) + ) need = true end else @@ -1161,7 +1166,7 @@ if Builtins.haskey( @request_firmware, Ops.get_string(driver, ["modules", 0, 0], "") - ) + ) Builtins.y2milestone( "driver %1 needs firmware", Ops.get_string(driver, ["modules", 0, 0], "") @@ -1180,7 +1185,7 @@ if Builtins.haskey( @request_firmware, Ops.get_string(@Items, [@current, "hwinfo", "driver"], "") - ) + ) kernel_module = Ops.get_string( @Items, [@current, "hwinfo", "driver"], @@ -1194,7 +1199,7 @@ if Builtins.haskey( @request_firmware, Ops.get_string(driver, ["modules", 0, 0], "") - ) + ) kernel_module = Ops.get_string(driver, ["modules", 0, 0], "") raise Break end @@ -1414,7 +1419,7 @@ rich << physical_port_id if physical_port_id?(ifcfg_name) # display it only if we need it, don't duplicate "ifcfg_name" above if IsNotEmpty(item_hwinfo["dev_name"]) && ifcfg_name.empty? - dev_name = _("Device Name: %s") % item_hwinfo["dev_name"] + dev_name = _("Device Name: %s") % item_hwinfo["dev_name"] rich << HTML.Bold(dev_name) << "<br>" end rich = HTML.Bold(descr) + rich @@ -1455,11 +1460,7 @@ # Is current device hotplug or not? I.e. is connected via usb/pcmci? def isCurrentHotplug hotplugtype = Ops.get_string(getCurrentItem, ["hwinfo", "hotplug"], "") - if hotplugtype == "usb" || hotplugtype == "pcmci" - return true - else - return false - end + hotplugtype == "usb" || hotplugtype == "pcmci" end # Check if currently edited device gets its IP address @@ -1554,17 +1555,17 @@ ), 4 ) - if DriverType(@type) == "ctc" || DriverType(@type) == "lcs" - @qeth_chanids = Builtins.sformat("%1%2 %1%3", devstr, devid0, devid1) - else - @qeth_chanids = Builtins.sformat( - "%1%2 %1%3 %1%4", - devstr, - devid0, - devid1, - devid2 - ) - end + @qeth_chanids = if DriverType(@type) == "ctc" || DriverType(@type) == "lcs" + Builtins.sformat("%1%2 %1%3", devstr, devid0, devid1) + else + Builtins.sformat( + "%1%2 %1%3 %1%4", + devstr, + devid0, + devid1, + devid2 + ) + end end nil @@ -1743,18 +1744,18 @@ Builtins.y2milestone("Startmode by product: #{product_startmode}") - case product_startmode - when "ifplugd" - if replace_ifplugd? - startmode = hotplug_usable? ? "hotplug" : "auto" - else - startmode = product_startmode - end - when "auto" - startmode = "auto" - else - startmode = hotplug_usable? ? "hotplug" : "auto" - end + startmode = case product_startmode + when "ifplugd" + if replace_ifplugd? + hotplug_usable? ? "hotplug" : "auto" + else + product_startmode + end + when "auto" + "auto" + else + hotplug_usable? ? "hotplug" : "auto" + end Builtins.y2milestone("New device startmode: #{startmode}") @@ -1817,7 +1818,8 @@ # Sets device map items related to dhclient def setup_dhclient_options(devmap) if isCurrentDHCP - devmap["DHCLIENT_SET_DEFAULT_ROUTE"] = TRISTATE_TO_S.fetch(@set_default_route) + val = TRISTATE_TO_S.fetch(@set_default_route) + devmap["DHCLIENT_SET_DEFAULT_ROUTE"] = val if val end devmap end @@ -1831,7 +1833,7 @@ devmap["STARTMODE"] = @startmode devmap["IFPLUGD_PRIORITY"] = @ifplugd_priority.to_i if @startmode == "ifplugd" devmap["BOOTPROTO"] = @bootproto - devmap["_aliases"] = @aliases + devmap["_aliases"] = @aliases if @aliases && !@aliases.empty? log.info("aliases #{@aliases}") @@ -1839,6 +1841,11 @@ end # Commit pending operation + # + # It commits *only* content of the corresponding ifcfg into NetworkInterfaces. + # All other stuff which is managed by LanItems (like udev's, ...) is handled + # elsewhere + # # @return true if success def Commit if @operation != :add && @operation != :edit @@ -2018,21 +2025,28 @@ newdev["INTERFACETYPE"] = @type end - NetworkInterfaces.Name = Ops.get_string(@Items, [@current, "ifcfg"], "") - NetworkInterfaces.Current = deep_copy(newdev) + current_map = (GetCurrentMap() || {}).select { |_, v| !v.nil? && !v.empty? } + new_map = newdev.select { |_, v| !v.nil? && !v.empty? } + + # CanonicalizeIP is called to get new device map into the same shape as + # NetworkInterfaces provides the current one. + if current_map != NetworkInterfaces.CanonicalizeIP(new_map) + keep_existing = false + ifcfg_name = Items()[@current]["ifcfg"] + ifcfg_name.replace("") if !NetworkInterfaces.Change2(ifcfg_name, newdev, keep_existing) + + # bnc#752464 - can leak wireless passwords + # useful only for debugging. Writes huge struct mostly filled by defaults. + Builtins.y2debug("%1", NetworkInterfaces.ConcealSecrets1(newdev)) + + # configure bridge ports + if @bridge_ports + @bridge_ports.split.each { |bp| configure_as_bridge_port(bp) } + end - # bnc#752464 - can leak wireless passwords - # useful only for debugging. Writes huge struct mostly filled by defaults. - Builtins.y2debug("%1", NetworkInterfaces.ConcealSecrets1(newdev)) - - Ops.set(@Items, [@current, "ifcfg"], "") if !NetworkInterfaces.Commit - - # configure bridge ports - if @bridge_ports - @bridge_ports.split.each { |bp| configure_as_bridge_port(bp) } + SetModified() end - @modified = true @operation = nil true end @@ -2044,11 +2058,9 @@ log.info "rollback item #{@current}" if getCurrentItem.fetch("hwinfo", {}).empty? LanItems.Items.delete(@current) - else - if IsCurrentConfigured() - if !getNetworkInterfaces.include?(getCurrentItem["ifcfg"]) - LanItems.Items[@current].delete("ifcfg") - end + elsif IsCurrentConfigured() + if !getNetworkInterfaces.include?(getCurrentItem["ifcfg"]) + LanItems.Items[@current].delete("ifcfg") end end end @@ -2203,17 +2215,26 @@ # Creates eth emulation for s390 devices # - # @param [Hash] an s390 device description as obtained from AY profile - def createS390Device(rule) - Builtins.y2milestone("creating device s390 network device, #{rule}") - - Select("") - @type = rule["type"] || "" - @qeth_chanids = rule["chanids"] || "" - @qeth_layer2 = rule.fetch("layer2", false) - @qeth_portname = rule["portname"] || "" - @chan_mode = rule["protocol"] || "" - @iucv_user = rule["router"] || "" + # @param [Hash] an s390 device description (e.g. as obtained from AY profile). + # If it contains s390 device attributes definition, then these definitions takes + # precendence over values assigned to corresponding LanItems' global variables + # before the method invocation. Hash keys are strings named after LanItems' + # s390 globals. + def createS390Device(dev_attrs = {}) + Builtins.y2milestone("creating device s390 network device, #{dev_attrs}") + + # FIXME: leftover from dropping LanUdevAuto module. This was its way how to + # configure s390 specific globals. When running in "normal" mode these attributes + # are initialized elsewhere (see S390Dialog in include/network/lan/hardware.rb) + if !dev_attrs.empty? + Select("") + @type = dev_attrs["type"] || "" + @qeth_chanids = dev_attrs["chanids"] || "" + @qeth_layer2 = dev_attrs.fetch("layer2", false) + @qeth_portname = dev_attrs["portname"] || "" + @chan_mode = dev_attrs["protocol"] || "" + @iucv_user = dev_attrs["router"] || "" + end result = true # command to create device @@ -2286,7 +2307,7 @@ SCR.Execute(path(".target.bash_output"), command1), from: "any", to: "map <string, any>" - ) + ) if Ops.get_integer(output1, "exit", -1) == 0 && Builtins.size(Ops.get_string(output1, "stderr", "")) == 0 Builtins.y2milestone("Success : %1", output1) @@ -2365,8 +2386,6 @@ udev_rules end - private - # This helper allows YARD to extract DSL-defined attributes. # Unfortunately YARD has problems with the Capitalized ones, # so those must be done manually. @@ -2377,6 +2396,8 @@ publish variable: name, type: type end + private + # Checks if given lladdr can be written into ifcfg # # @param lladdr [String] logical link address, usually MAC address in case @@ -2460,7 +2481,7 @@ if Ops.greater_than( Builtins.size(Ops.get_string(chan_ids, "stdout", "")), 0 - ) + ) chanids = String.CutBlanks(Ops.get_string(chan_ids, "stdout", "")) end port_name = Convert.convert( @@ -2477,7 +2498,7 @@ if Ops.greater_than( Builtins.size(Ops.get_string(port_name, "stdout", "")), 0 - ) + ) portname = String.CutBlanks(Ops.get_string(port_name, "stdout", "")) end proto = Convert.convert( @@ -2494,7 +2515,7 @@ if Ops.greater_than( Builtins.size(Ops.get_string(proto, "stdout", "")), 0 - ) + ) protocol = String.CutBlanks(Ops.get_string(proto, "stdout", "")) end layer2_ret = SCR.Execute( @@ -2502,8 +2523,8 @@ Builtins.sformat( "grep -q 1 /sys/class/net/%1/device/layer2", device + ) ) - ) layer2 = layer2_ret == 0 Ops.set(ay, ["s390-devices", device], "type" => device_type) if Ops.greater_than(Builtins.size(chanids), 0) @@ -2531,7 +2552,7 @@ if Ops.greater_than( Builtins.size(Ops.get_string(port0, "stdout", "")), 0 - ) + ) value = Ops.get_string(port0, "stdout", "") Ops.set( ay, @@ -2564,8 +2585,6 @@ deep_copy(ay) end - public - # @attribute Items # @return [Hash<Integer, Hash<String, Object> >] # Each item, indexed by an Integer in a Hash, aggregates several aspects @@ -2581,7 +2600,6 @@ publish_variable :udev_net_rules, "map <string, any>" publish_variable :driver_options, "map <string, any>" publish_variable :autoinstall_settings, "map" - publish_variable :modified, "boolean" publish_variable :operation, "symbol" publish_variable :force_restart, "boolean" publish_variable :description, "string" @@ -2642,7 +2660,6 @@ publish_variable :tunnel_set_owner, "string" publish_variable :tunnel_set_group, "string" publish_variable :proposal_valid, "boolean" - publish_variable :nm_name, "string" publish function: :GetLanItem, type: "map (integer)" publish function: :getCurrentItem, type: "map ()" publish function: :IsItemConfigured, type: "boolean (integer)" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/src/modules/SuSEFirewall4Network.rb new/yast2-network-3.1.158/src/modules/SuSEFirewall4Network.rb --- old/yast2-network-3.1.154/src/modules/SuSEFirewall4Network.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/src/modules/SuSEFirewall4Network.rb 2016-06-23 10:23:17.000000000 +0200 @@ -205,6 +205,23 @@ Ops.greater_than(Builtins.size(interfaces), 0) end + # Checks if interface of given name is assigned to given FW zone + def iface_in_zone?(interface, zone) + SuSEFirewall.GetInterfacesInZone(zone).include?(interface) + end + + # Enables and starts fw service + def start_fw_service + SuSEFirewall.SetEnableService(true) + SuSEFirewall.SetStartService(true) + end + + # Disables and stops fw service + def stop_fw_service + SuSEFirewall.SetEnableService(false) + SuSEFirewall.SetStartService(false) + end + # Functions sets protection of interface by the protect-status.<br> # protect==true -> add interface into selected firewall zone, sets firewall # to be started and enabled when booting.<br> @@ -218,28 +235,24 @@ # @return [Boolean] if successful def ProtectByFirewall(interface, zone, protect_status) # Adding protection - if protect_status == true - Builtins.y2milestone( - "Enabling firewall because of '%1' interface", - interface - ) - SuSEFirewall.AddInterfaceIntoZone(interface, zone) - SuSEFirewall.SetEnableService(true) - SuSEFirewall.SetStartService(true) - # Removing protection + if protect_status + log.info("Enabling firewall because of '#{interface}' interface") + + SuSEFirewall.AddInterfaceIntoZone(interface, zone) if !iface_in_zone?(interface, zone) + + start_fw_service + # Removing protection else # removing from all known zones - Builtins.foreach(SuSEFirewall.GetKnownFirewallZones) do |remove_from_zone| + zones = SuSEFirewall.GetKnownFirewallZones.select { |fw_zone| iface_in_zone?(interface, fw_zone) } + zones.each do |remove_from_zone| SuSEFirewall.RemoveInterfaceFromZone(interface, remove_from_zone) end # if there are no other interfaces in configuration, stop firewall # and remove it from boot process if !AnyInterfacesHandledByFirewall() - Builtins.y2milestone( - "Disabling firewall, no interfaces are protected." - ) - SuSEFirewall.SetEnableService(false) - SuSEFirewall.SetStartService(false) + log.info("Disabling firewall, no interfaces are protected.") + stop_fw_service end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/test/complex_test.rb new/yast2-network-3.1.158/test/complex_test.rb --- old/yast2-network-3.1.154/test/complex_test.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/test/complex_test.rb 2016-06-23 10:23:17.000000000 +0200 @@ -39,7 +39,7 @@ it "asks user for abort confirmation for input equal to :abort and user did modifications" do allow(Yast::LanItems) - .to receive(:modified) + .to receive(:GetModified) .and_return(true) expect(subject) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/test/lan_test.rb new/yast2-network-3.1.158/test/lan_test.rb --- old/yast2-network-3.1.154/test/lan_test.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/test/lan_test.rb 2016-06-23 10:23:17.000000000 +0200 @@ -148,7 +148,7 @@ } } } - } + }.freeze expect(Yast::Lan.Import(AY_PROFILE)).to be true expect(Yast::LanItems.GetModified).to be true @@ -159,3 +159,54 @@ expect(Yast::LanItems.Items).to be_empty end end + +describe "LanClass#Modified" do + def reset_modification_statuses + allow(Yast::LanItems).to receive(:GetModified).and_return false + allow(Yast::DNS).to receive(:modified).and_return false + allow(Yast::Routing).to receive(:Modified).and_return false + allow(Yast::NetworkConfig).to receive(:Modified).and_return false + allow(Yast::NetworkService).to receive(:Modified).and_return false + allow(Yast::SuSEFirewall).to receive(:GetModified).and_return false + end + + def expect_modification_succeedes(modname, method) + reset_modification_statuses + + allow(modname) + .to receive(method) + .and_return true + + expect(modname.send(method)).to be true + expect(Yast::Lan.Modified).to be true + end + + it "returns true when LanItems module was modified" do + expect_modification_succeedes(Yast::LanItems, :GetModified) + end + + it "returns true when DNS module was modified" do + expect_modification_succeedes(Yast::DNS, :modified) + end + + it "returns true when Routing module was modified" do + expect_modification_succeedes(Yast::Routing, :Modified) + end + + it "returns true when NetworkConfig module was modified" do + expect_modification_succeedes(Yast::NetworkConfig, :Modified) + end + + it "returns true when NetworkService module was modified" do + expect_modification_succeedes(Yast::NetworkService, :Modified) + end + + it "returns true when SuSEFirewall module was modified" do + expect_modification_succeedes(Yast::SuSEFirewall, :GetModified) + end + + it "returns false when no module was modified" do + reset_modification_statuses + expect(Yast::Lan.Modified).to be false + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/test/network_autoyast_test.rb new/yast2-network-3.1.158/test/network_autoyast_test.rb --- old/yast2-network-3.1.154/test/network_autoyast_test.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/test/network_autoyast_test.rb 2016-06-23 10:23:17.000000000 +0200 @@ -244,9 +244,9 @@ expect(network_autoyast.keep_net_config?).to be false end - it "fails when keep_install_network is not present in AY profile" do + it "succeedes when keep_install_network is not present in AY profile" do keep_install_network_value({}) - expect(network_autoyast.keep_net_config?).to be false + expect(network_autoyast.keep_net_config?).to be true end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/test/suse_firewall_4_network_test.rb new/yast2-network-3.1.158/test/suse_firewall_4_network_test.rb --- old/yast2-network-3.1.154/test/suse_firewall_4_network_test.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/test/suse_firewall_4_network_test.rb 2016-06-23 10:23:17.000000000 +0200 @@ -63,5 +63,41 @@ end end end + + describe "ProtectByFirewall" do + Yast.import "SuSEFirewall" + + context "when interface is not in fw zone" do + before(:each) do + allow(SuSEFirewall) + .to receive(:SetEnableService) + allow(SuSEFirewall) + .to receive(:SetStartService) + end + + it "doesn't cause modification flag to be set when protect status is true" do + allow(SuSEFirewall) + .to receive(:GetInterfacesInZone) + .and_return(["eth0"]) + + SuSEFirewall4Network.ProtectByFirewall("eth0", "INT", true) + + # interface is in the zone already => no adding / modification needed + expect(SuSEFirewall.GetModified).to be false + end + + it "doesn't cause modification flag to be set when protect status is false" do + allow(SuSEFirewall) + .to receive(:GetInterfacesInZone) + .and_return([]) + + # Note: zone is not important in this case + SuSEFirewall4Network.ProtectByFirewall("eth0", "INT", false) + + # every zone is empty => no removal / modification needed + expect(SuSEFirewall.GetModified).to be false + end + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.154/test/udev_test.rb new/yast2-network-3.1.158/test/udev_test.rb --- old/yast2-network-3.1.154/test/udev_test.rb 2016-06-09 15:23:32.000000000 +0200 +++ new/yast2-network-3.1.158/test/udev_test.rb 2016-06-23 10:23:17.000000000 +0200 @@ -78,17 +78,29 @@ describe "LanItems#ReplaceItemUdev" do Yast.import "LanItems" + before(:each) do + Yast::LanItems.current = 0 + + # LanItems should create "udev" and "net" subkeys for each item + # during Read + allow(Yast::LanItems) + .to receive(:Items) + .and_return(0 => { "udev" => { "net" => [] } }) + end + it "replaces triplet in the rule as requested" do allow(Yast::LanItems) .to receive(:getUdevFallback) .and_return( [ - "KERNELS=\"invalid\"", + "KERNELS==\"invalid\"", "KERNEL=\"eth*\"", "NAME=\"eth1\"" ] ) + expect(Yast::LanItems).to receive(:SetModified) + updated_rule = Yast::LanItems.ReplaceItemUdev( "KERNELS", "ATTR{address}", @@ -96,4 +108,24 @@ ) expect(updated_rule).to include "ATTR{address}==\"xx:01:02:03:04:05\"" end + + it "do not set modification flag in case of no change" do + allow(Yast::LanItems) + .to receive(:getUdevFallback) + .and_return( + [ + "ATTR{address}==\"xx:01:02:03:04:05\"", + "KERNEL=\"eth*\"", + "NAME=\"eth1\"" + ] + ) + + Yast::LanItems.ReplaceItemUdev( + "KERNELS", + "ATTR{address}", + "xx:01:02:03:04:05" + ) + + expect(Yast::LanItems).not_to receive(:SetModified) + end end
participants (1)
-
root@hilbert.suse.de