Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2021-04-10 15:26:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-network (Old) and /work/SRC/openSUSE:Factory/.yast2-network.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-network" Sat Apr 10 15:26:08 2021 rev:448 rq:884190 version:4.4.2 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes 2021-03-30 20:51:50.796146379 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-network.new.2401/yast2-network.changes 2021-04-10 15:26:24.482310043 +0200 @@ -1,0 +2,35 @@ +Fri Apr 9 11:22:42 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- bsc#1181956 + - Omit empty values or the '0.0.0.0' IPADDR when writing ifcfg + files. + - Do not write empty ifroute files. +- 4.4.2 + +------------------------------------------------------------------- +Thu Apr 8 09:27:47 UTC 2021 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Display the network configuration in the installation summary + screen even if NetworkManager is the selected backend + (bsc#1181354). +- 4.4.1 + +------------------------------------------------------------------- +Wed Apr 7 11:27:26 UTC 2021 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Write DNS servers to NetworkManager connection files when using + a static configuration (bsc#1181701). +- 4.4.0 + +------------------------------------------------------------------- +Tue Apr 6 08:54:07 UTC 2021 - Michal Filka <mfi...@suse.com> + +- Drop isCurrentDHCP and isCurrentHotplug methods from LanItems. + +------------------------------------------------------------------- +Mon Apr 5 15:21:47 UTC 2021 - David Diaz <dgonza...@suse.com> + +- Do not show the "Abort" button when the inst_lan client is called + from another installation step (bsc#1183586). + +------------------------------------------------------------------- Old: ---- yast2-network-4.3.63.tar.bz2 New: ---- yast2-network-4.4.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.Dad0t2/_old 2021-04-10 15:26:25.042310702 +0200 +++ /var/tmp/diff_new_pack.Dad0t2/_new 2021-04-10 15:26:25.046310707 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.3.63 +Version: 4.4.2 Release: 0 Summary: YaST2 - Network Configuration License: GPL-2.0-only ++++++ yast2-network-4.3.63.tar.bz2 -> yast2-network-4.4.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/package/yast2-network.changes new/yast2-network-4.4.2/package/yast2-network.changes --- old/yast2-network-4.3.63/package/yast2-network.changes 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/package/yast2-network.changes 2021-04-10 10:37:01.000000000 +0200 @@ -1,4 +1,39 @@ ------------------------------------------------------------------- +Fri Apr 9 11:22:42 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- bsc#1181956 + - Omit empty values or the '0.0.0.0' IPADDR when writing ifcfg + files. + - Do not write empty ifroute files. +- 4.4.2 + +------------------------------------------------------------------- +Thu Apr 8 09:27:47 UTC 2021 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Display the network configuration in the installation summary + screen even if NetworkManager is the selected backend + (bsc#1181354). +- 4.4.1 + +------------------------------------------------------------------- +Wed Apr 7 11:27:26 UTC 2021 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Write DNS servers to NetworkManager connection files when using + a static configuration (bsc#1181701). +- 4.4.0 + +------------------------------------------------------------------- +Tue Apr 6 08:54:07 UTC 2021 - Michal Filka <mfi...@suse.com> + +- Drop isCurrentDHCP and isCurrentHotplug methods from LanItems. + +------------------------------------------------------------------- +Mon Apr 5 15:21:47 UTC 2021 - David Diaz <dgonza...@suse.com> + +- Do not show the "Abort" button when the inst_lan client is called + from another installation step (bsc#1183586). + +------------------------------------------------------------------- Mon Mar 29 11:52:08 UTC 2021 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> - Use the ESSID to name the NetworkManager configuration files diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/package/yast2-network.spec new/yast2-network-4.4.2/package/yast2-network.spec --- old/yast2-network-4.3.63/package/yast2-network.spec 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/package/yast2-network.spec 2021-04-10 10:37:01.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.3.63 +Version: 4.4.2 Release: 0 Summary: YaST2 - Network Configuration License: GPL-2.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/include/network/lan/address.rb new/yast2-network-4.4.2/src/include/network/lan/address.rb --- old/yast2-network-4.3.63/src/include/network/lan/address.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/include/network/lan/address.rb 2021-04-10 10:37:01.000000000 +0200 @@ -55,16 +55,17 @@ # Dialog for setting up IP address # @return dialog result def AddressDialog(builder:) - @builder = builder - ret = Y2Network::Dialogs::EditInterface.run(builder) if ret != :back && ret != :abort - if LanItems.isCurrentDHCP && !LanItems.isCurrentHotplug + if builder.boot_protocol.dhcp? && !builder.interface.hotplug? # fixed bug #73739 - if dhcp is used, dont set default gw statically # but also: reset default gw only if DHCP* is used, this branch covers # "No IP address" case, then default gw must stay (#460262) # and also: don't delete default GW for usb/pcmcia devices (#307102) + # + # Is check for hotplug really needed? It contained a typo up to SLE-15-SP4 and + # nobody complained - something to think of during next refactoring. yast_config = Y2Network::Config.find(:yast) if yast_config&.routing&.default_route remove_gw = Popup.YesNo( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/include/network/lan/complex.rb new/yast2-network-4.4.2/src/include/network/lan/complex.rb --- old/yast2-network-4.3.63/src/include/network/lan/complex.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/include/network/lan/complex.rb 2021-04-10 10:37:01.000000000 +0200 @@ -55,6 +55,7 @@ Yast.import "CWMTab" Yast.import "Stage" Yast.import "Systemd" + Yast.import "GetInstArgs" Yast.include include_target, "network/routines.rb" Yast.include include_target, "network/lan/help.rb" @@ -242,24 +243,21 @@ help = CWM.MergeHelps(w) contents = CWM.PrepareDialog(contents, w) - running_installer = Mode.installation || Mode.update Wizard.SetContentsButtons( caption, contents, help, Label.BackButton, - running_installer ? Label.NextButton : Label.OKButton + next_button_label ) - if running_installer - Wizard.SetAbortButton(:abort, Label.AbortButton) - else - Wizard.SetAbortButton(:abort, Label.CancelButton) - Wizard.HideBackButton - end + Wizard.SetAbortButton(:abort, abort_button_label) + Wizard.HideAbortButton if hide_abort_button? + Wizard.HideBackButton unless running_installer? ret = nil + loop do ret = CWM.Run(w, {}) break if input_done?(ret) @@ -267,5 +265,36 @@ ret end + + # The label for the next/ok button + # + # @return [String] + def next_button_label + running_installer? ? Label.NextButton : Label.OKButton + end + + # The label for the abort/quit button + # + # @return [String] + def abort_button_label + running_installer? ? Label.AbortButton : Label.CancelButton + end + + # Whether abort button should be hide + # + # @return [Boolean] true if running during installation and disable_abort_button inst argument + # is present and true; false otherwise + def hide_abort_button? + return false unless running_installer? + + GetInstArgs.argmap["hide_abort_button"] == true + end + + # Whether running during installation + # + # @return [Boolean] true when running during installation, false otherwise + def running_installer? + Mode.installation || Mode.update + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/cfa/nm_connection.rb new/yast2-network-4.4.2/src/lib/cfa/nm_connection.rb --- old/yast2-network-4.3.63/src/lib/cfa/nm_connection.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/cfa/nm_connection.rb 2021-04-10 10:37:01.000000000 +0200 @@ -18,6 +18,10 @@ # find current contact information at www.suse.com. require "cfa/base_model" +require "pathname" +require "y2network/connection_config/wireless" + +Yast.import "WFM" module CFA # Class to handle NetworkManager connection configuration files @@ -32,6 +36,35 @@ "bond", "bridge", "connection", "ethernet", "ipv4", "ipv6", "vlan", "wifi", "wifi_security" ].freeze + # @return [String] File path + attr_reader :file_path + + class << self + # Returns the file corresponding to a connection + # + # @param conn [ConnectionConfig::Base] Connection configuration + # @return [NmConnection] + def for(conn) + path = SYSTEM_CONNECTIONS_PATH.join(file_basename_for(conn)).sub_ext(FILE_EXT) + new(path) + end + + private + + SYSTEM_CONNECTIONS_PATH = Pathname.new("/etc/NetworkManager/system-connections").freeze + FILE_EXT = ".nmconnection".freeze + + # Returns the file base name for the given connection + # + # @param conn [ConnectionConfig::Base] + # @return [String] + def file_basename_for(conn) + return conn.essid.to_s if conn.is_a?(Y2Network::ConnectionConfig::Wireless) && conn.essid + + conn.name + end + end + # Constructor # # @param path [String] File path @@ -39,7 +72,7 @@ def initialize(path, file_handler: nil) # FIXME: The Networkmanager lense writes the values surrounded by double # quotes which is not valid - super(AugeasParser.new("Puppet.lns"), path, file_handler: file_handler) + super(AugeasParser.new("Desktop.lns"), path, file_handler: file_handler) end # Returns the augeas tree for the given section @@ -80,6 +113,13 @@ end end + # Determines whether the file exist + # + # @return [Boolean] true if the file exist, false otherwise + def exist? + ::File.exist?(::File.join(Yast::WFM.scr_root, file_path)) + end + KNOWN_SECTIONS.each { |s| define_method(s) { section_for(s) } } end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/installation/console/plugins/network_button.rb new/yast2-network-4.4.2/src/lib/installation/console/plugins/network_button.rb --- old/yast2-network-4.3.63/src/lib/installation/console/plugins/network_button.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/installation/console/plugins/network_button.rb 2021-04-10 10:37:01.000000000 +0200 @@ -41,7 +41,8 @@ end def handle - Yast::WFM.call("inst_lan", [{ "skip_detection" => true }]) + Yast::WFM.call("inst_lan", [{ "skip_detection" => true, "hide_abort_button" => true }]) + nil end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/network/clients/inst_lan.rb new/yast2-network-4.4.2/src/lib/network/clients/inst_lan.rb --- old/yast2-network-4.3.63/src/lib/network/clients/inst_lan.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/network/clients/inst_lan.rb 2021-04-10 10:37:01.000000000 +0200 @@ -32,10 +32,15 @@ # sequence. # # The configuration sequence can be forced passing the 'skip_detection' - # argument. + # argument. Additionally, the abort button could be hide passing the + # 'hide_abort_button' argument # - # @example calling the client forcing the configuration sequence - # Yast::WFM.CallFunction("inst_lan", [args.merge("skip_detection" => true)]) + # @example calling the client forcing the configuration sequence and hiding + # the abort button + # Yast::WFM.CallFunction( + # "inst_lan", + # [args.merge("skip_detection" => true, "hide_abort_button" => true)] + # ) # # @example firsboot xml forcing the configuration sequence # <module> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/network/clients/network_proposal.rb new/yast2-network-4.4.2/src/lib/network/clients/network_proposal.rb --- old/yast2-network-4.3.63/src/lib/network/clients/network_proposal.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/network/clients/network_proposal.rb 2021-04-10 10:37:01.000000000 +0200 @@ -96,7 +96,7 @@ proposal_text = switch_backend_link proposal_text << toggle_virt_proposal_link if settings.virtual_proposal_required? - proposal_text.prepend(proposal_summary.text) if wicked_backend? + proposal_text.prepend(proposal_summary.text) proposal_text end @@ -120,7 +120,7 @@ # TRANSLATORS: information about the network backend in use. %s is the name of backend, # example "wicked" or "NetworkManager" backend_in_use = _("Using <b>%s</b>") - # TRANSLATORS: text of link for switch to another network backend. %s is the name of backend, + # TRANSLATORS: text of link to switch to another network backend. %s is the name of backend, # example "wicked" or "NetworkManager" switch_to = _("switch to %s") @@ -138,7 +138,10 @@ def launch_network_configuration(args) log.info "Launching network configuration" Yast::Wizard.OpenAcceptDialog - result = Yast::WFM.CallFunction("inst_lan", [args.merge("skip_detection" => true)]) + result = Yast::WFM.CallFunction( + "inst_lan", + [args.merge("skip_detection" => true, "hide_abort_button" => true)] + ) log.info "Returning from the network configuration with: #{result}" result ensure diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/y2network/boot_protocol.rb new/yast2-network-4.4.2/src/lib/y2network/boot_protocol.rb --- old/yast2-network-4.3.63/src/lib/y2network/boot_protocol.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/y2network/boot_protocol.rb 2021-04-10 10:37:01.000000000 +0200 @@ -43,6 +43,7 @@ # @return [String] Returns protocol name attr_reader :name + alias_method :to_s, :name # Constructor # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/y2network/connection_configs_collection.rb new/yast2-network-4.4.2/src/lib/y2network/connection_configs_collection.rb --- old/yast2-network-4.3.63/src/lib/y2network/connection_configs_collection.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/y2network/connection_configs_collection.rb 2021-04-10 10:37:01.000000000 +0200 @@ -72,6 +72,14 @@ select { |c| ids.include?(c.id) } end + # Returns connections with a given bootproto + # + # @param bootprotos [Array<BootProtocol>] Boot protocols + # @return [Array<ConnectionConfig::Base>] Connection configs with the given boot protocol + def by_bootproto(*bootprotos) + select { |c| bootprotos.include?(c.bootproto) } + end + # Adds or updates a connection configuration # # @note It uses the name to do the matching. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/y2network/hwinfo.rb new/yast2-network-4.4.2/src/lib/y2network/hwinfo.rb --- old/yast2-network-4.3.63/src/lib/y2network/hwinfo.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/y2network/hwinfo.rb 2021-04-10 10:37:01.000000000 +0200 @@ -161,7 +161,7 @@ # @!method requires read value of hwinfo["requires"] # @return [Array<String>] # @!method hotplug read value of hwinfo["hotplug"] - # @return [Boolean] + # @return [String] # @!method module read value of hwinfo["module"] # @return [String] # @!method wl_auth_modes read value of hwinfo["wl_auth_modes"] @@ -180,7 +180,7 @@ { name: "driver", default: "" }, { name: "module", default: nil }, { name: "requires", default: [] }, - { name: "hotplug", default: false }, + { name: "hotplug", default: "" }, { name: "wl_auth_modes", default: "" }, { name: "wl_enc_modes", default: nil }, { name: "wl_channels", default: nil }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/y2network/interface.rb new/yast2-network-4.4.2/src/lib/y2network/interface.rb --- old/yast2-network-4.3.63/src/lib/y2network/interface.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/y2network/interface.rb 2021-04-10 10:37:01.000000000 +0200 @@ -132,5 +132,10 @@ Y2Network::UdevRule.new_bus_id_based_rename(name, hardware.busid, hardware.dev_port) end end + + # @return [Boolean] true if the interface is hotplug + def hotplug? + ["usb", "pcmcia"].include?(hardware.hotplug) + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/y2network/interface_config_builders/bonding.rb new/yast2-network-4.4.2/src/lib/y2network/interface_config_builders/bonding.rb --- old/yast2-network-4.3.63/src/lib/y2network/interface_config_builders/bonding.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/y2network/interface_config_builders/bonding.rb 2021-04-10 10:37:01.000000000 +0200 @@ -60,7 +60,7 @@ devices.any? do |device| next false unless yast_config.configured_interface?(device) - yast_config.connections.by_name(device).bootproto.name != "none" + !valid_slave_config?(device) end end @@ -68,12 +68,13 @@ def save slaves.each do |slave| interface = yast_config.interfaces.by_name(slave) - connection = yast_config.connections.by_name(slave) - next if connection && connection.bootproto.name == "none" + next if valid_slave_config?(slave) + connection = yast_config.connections.by_name(slave) builder = InterfaceConfigBuilder.for(interface.type, config: connection) builder.name = interface.name builder.configure_as_slave + builder.startmode = "hotplug" builder.save end @@ -118,6 +119,16 @@ true end + + # Convenience method to check whether the config of an enslaved interface + # is valid or not + # + # @param iface [String] slave name to be validated + def valid_slave_config?(iface) + conn = yast_config.connections.by_name(iface) + + conn&.bootproto&.name == "none" && conn&.startmode&.name == "hotplug" + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/y2network/network_manager/config_writer.rb new/yast2-network-4.4.2/src/lib/y2network/network_manager/config_writer.rb --- old/yast2-network-4.3.63/src/lib/y2network/network_manager/config_writer.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/y2network/network_manager/config_writer.rb 2021-04-10 10:37:01.000000000 +0200 @@ -43,6 +43,25 @@ end end + # Updates the DNS configuration + # + # In case a connection has a static configuration, the DNS nameservers are added + # to the configuration file (see bsc#1181701). + # + # @param config [Y2Network::Config] Current config object + # @param old_config [Y2Network::Config,nil] Config object with original configuration + def write_dns(config, old_config) + static = config.connections.by_bootproto(Y2Network::BootProtocol::STATIC) + return super if static.empty? || config.dns.nameservers.empty? + + ipv4_ns, ipv6_ns = config.dns.nameservers.partition(&:ipv4?) + ipv4_dns = ipv4_ns.map(&:to_s).join(";") + ipv6_dns = ipv6_ns.map(&:to_s).join(";") + static.each do |conn| + add_dns_to_conn(conn, ipv4_dns, ipv6_dns) + end + end + # Finds routes for a given connection # # @param conn [ConnectionConfig::Base] Connection configuration @@ -51,6 +70,21 @@ def routes_for(conn, routes) routes.select { |r| r.interface&.name == conn.name } end + + # Add the DNS settings to the nmconnection file corresponding to the give conn + # + # @param conn [Connectionconfig::Base] Connection configuration + # @param ipv4_dns [String] Value for the 'dns' key in the ipv4 section + # @param ipv6_dns [String] Value for the 'dns' key in the ipv6 section + def add_dns_to_conn(conn, ipv4_dns, ipv6_dns) + file = CFA::NmConnection.for(conn) + return unless file.exist? + + file.load + file.ipv4["dns"] = ipv4_dns unless ipv4_dns.empty? + file.ipv6["dns"] = ipv6_dns unless ipv6_dns.empty? + file.save + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/y2network/network_manager/connection_config_writer.rb new/yast2-network-4.4.2/src/lib/y2network/network_manager/connection_config_writer.rb --- old/yast2-network-4.3.63/src/lib/y2network/network_manager/connection_config_writer.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/y2network/network_manager/connection_config_writer.rb 2021-04-10 10:37:01.000000000 +0200 @@ -28,9 +28,6 @@ class ConnectionConfigWriter include Yast::Logger - SYSTEM_CONNECTIONS_PATH = Pathname.new("/etc/NetworkManager/system-connections").freeze - FILE_EXT = ".nmconnection".freeze - # @param conn [ConnectionConfig::Base] Connection configuration to be # written # @param old_conn [ConnectionConfig::Base] Original connection @@ -39,12 +36,15 @@ def write(conn, old_conn = nil, opts = {}) return if conn == old_conn - path = SYSTEM_CONNECTIONS_PATH.join(file_basename_for(conn)).sub_ext(FILE_EXT) - file = CFA::NmConnection.new(path) + file = CFA::NmConnection.for(conn) handler_class = find_handler_class(conn.type) return nil if handler_class.nil? - ensure_permissions(path) unless ::File.exist?(path) + if file.exist? + file.load + else + ensure_permissions(file.file_path) + end handler_class.new(file).write(conn, opts) file.save @@ -74,16 +74,6 @@ "Connection handler could not be loaded: #{e.message}" nil end - - # Returns the file base name for the given connection - # - # @param conn [ConnectionConfig::Base] - # @return [String] - def file_basename_for(conn) - return conn.essid.to_s if conn.is_a?(ConnectionConfig::Wireless) - - conn.name - end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/y2network/wicked/config_writer.rb new/yast2-network-4.4.2/src/lib/y2network/wicked/config_writer.rb --- old/yast2-network-4.3.63/src/lib/y2network/wicked/config_writer.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/y2network/wicked/config_writer.rb 2021-04-10 10:37:01.000000000 +0200 @@ -64,10 +64,12 @@ file = routes_file_for(dev) # Remove ifroutes-* if empty or interface is not configured - file.remove if routes.empty? || !config.configured_interface?(dev.name) - - file.routes = routes - file.save + if routes.empty? || !config.configured_interface?(dev.name) + file.remove + else + file.routes = routes + file.save + end end # Actions needed for removed interfaces diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/lib/y2network/wicked/connection_config_writers/base.rb new/yast2-network-4.4.2/src/lib/y2network/wicked/connection_config_writers/base.rb --- old/yast2-network-4.3.63/src/lib/y2network/wicked/connection_config_writers/base.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/lib/y2network/wicked/connection_config_writers/base.rb 2021-04-10 10:37:01.000000000 +0200 @@ -26,9 +26,12 @@ # # The derived classes should implement {#update_file} method. class Base + extend Forwardable # @return [CFA::InterfaceFile] Interface's configuration file attr_reader :file + def_delegators :@file, :value_as_string + # Constructor # # @param file [CFA::InterfaceFile] Interface's configuration file @@ -40,17 +43,15 @@ # # @param conn [Y2Network::ConnectionConfig::Base] Connection to take settings from def write(conn) - file.bootproto = conn.bootproto&.name - file.name = conn.description - file.lladdr = conn.lladdress - file.startmode = conn.startmode.to_s - file.dhclient_set_hostname = dhclient_set_hostname(conn) - file.ifplugd_priority = conn.startmode.priority if conn.startmode&.name == "ifplugd" - if conn.ethtool_options && !conn.ethtool_options.empty? - file.ethtool_options = conn.ethtool_options - end - file.zone = conn.firewall_zone - file.mtu = conn.mtu + file.bootproto = value_as_string(conn.bootproto.to_s) + file.name = value_as_string(conn.description) + file.lladdr = value_as_string(conn.lladdress) + file.startmode = value_as_string(conn.startmode.to_s) + file.dhclient_set_hostname = value_as_string(dhclient_set_hostname(conn)) + file.ifplugd_priority = conn.startmode.priority if conn.startmode.to_s == "ifplugd" + file.ethtool_options = value_as_string(conn.ethtool_options) + file.zone = value_as_string(conn.firewall_zone) + file.mtu = value_as_string(conn.mtu) add_ips(conn) update_file(conn) @@ -82,7 +83,7 @@ def add_ips(conn) file.ipaddrs.clear ips_to_add = conn.ip_aliases.clone - ips_to_add << conn.ip if conn.ip && !conn.bootproto.dhcp? + ips_to_add << conn.ip if static_valid_ip?(conn) ips_to_add.each { |i| add_ip(i) } end @@ -91,7 +92,7 @@ # @param ip [Y2Network::IPAddress] IP address to add def add_ip(ip) file.ipaddrs[ip.id] = ip.address - file.labels[ip.id] = ip.label + file.labels[ip.id] = value_as_string(ip.label) file.remote_ipaddrs[ip.id] = ip.remote_address file.broadcasts[ip.id] = ip.broadcast end @@ -105,6 +106,18 @@ Yast::Host.Update("", conn.hostname, conn.ip.address.address.to_s) end + + # Convenience method to check whether a connection is configured using + # the static bootproto and a valid IP address. + # + # @param conn [Y2Network::ConnectionConfig::Base] Connection to take settings from + # @return [Boolean] whether the connection is configured with a valid + # static IP address or not + def static_valid_ip?(conn) + return false unless conn.bootproto.static? + + conn.ip && conn.ip.address.address.to_s != "0.0.0.0" + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/src/modules/LanItems.rb new/yast2-network-4.4.2/src/modules/LanItems.rb --- old/yast2-network-4.3.63/src/modules/LanItems.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/src/modules/LanItems.rb 2021-04-10 10:37:01.000000000 +0200 @@ -263,21 +263,6 @@ true end - # Is current device hotplug or not? I.e. is connected via usb/pcmci? - def isCurrentHotplug - hotplugtype = Ops.get_string(getCurrentItem, ["hwinfo", "hotplug"], "") - ["usb", "pcmci"].include?(hotplugtype) - end - - # Check if currently edited device gets its IP address - # from DHCP (v4, v6 or both) - # @return true if it is - def isCurrentDHCP - return false unless @bootproto - - Y2Network::BootProtocol.from_name(@bootproto).dhcp? - end - # Checks whether given device configuration is set to use a dhcp bootproto # # ideally should replace @see isCurrentDHCP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/test/cfa/nm_connection_test.rb new/yast2-network-4.4.2/test/cfa/nm_connection_test.rb --- old/yast2-network-4.3.63/test/cfa/nm_connection_test.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/test/cfa/nm_connection_test.rb 2021-04-10 10:37:01.000000000 +0200 @@ -20,6 +20,7 @@ require_relative "../test_helper" require "cfa/nm_connection" require "cfa/memory_file" +require "y2network/connection_config/ethernet" describe CFA::NmConnection do def file_path(filename) @@ -29,6 +30,46 @@ subject { described_class.new(conn_file) } let(:conn_file) { file_path("some_wifi.nmconnection") } + describe ".for" do + let(:conn) do + Y2Network::ConnectionConfig::Ethernet.new.tap do |eth0| + eth0.name = "eth0" + eth0.interface = "eth0" + end + end + + it "uses the interface as path basename" do + file = described_class.for(conn) + expect(file.file_path.basename.to_s).to eq("eth0.nmconnection") + end + + context "when a wireless connection is given" do + let(:essid) { "MY_WIRELESS" } + + let(:conn) do + Y2Network::ConnectionConfig::Wireless.new.tap do |wlo1| + wlo1.name = "wlo1" + wlo1.interface = "wlo1" + wlo1.essid = essid + end + end + + it "uses the ESSID as path basename" do + file = described_class.for(conn) + expect(file.file_path.basename.to_s).to eq("MY_WIRELESS.nmconnection") + end + + context "and the ESSID is not set" do + let(:essid) { nil } + + it "uses the interface as path basename" do + file = described_class.for(conn) + expect(file.file_path.basename.to_s).to eq("wlo1.nmconnection") + end + end + end + end + describe "#connection" do before { subject.load } @@ -44,4 +85,22 @@ end end end + + describe "#exist?" do + context "when the file exists" do + let(:conn_file) { file_path("some_wifi.nmconnection") } + + it "returns true" do + expect(subject.exist?).to eq(true) + end + end + + context "when the file does not exist" do + let(:conn_file) { file_path("missing.nmconnection") } + + it "returns false" do + expect(subject.exist?).to eq(false) + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/test/cmdline_test.rb new/yast2-network-4.4.2/test/cmdline_test.rb --- old/yast2-network-4.3.63/test/cmdline_test.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/test/cmdline_test.rb 2021-04-10 10:37:01.000000000 +0200 @@ -19,9 +19,8 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require "y2network/interface_config_builder" - require_relative "test_helper" +require "y2network/interface_config_builder" class DummyClass < Yast::Module def initialize diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/test/network_proposal_test.rb new/yast2-network-4.4.2/test/network_proposal_test.rb --- old/yast2-network-4.3.63/test/network_proposal_test.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/test/network_proposal_test.rb 2021-04-10 10:37:01.000000000 +0200 @@ -79,11 +79,11 @@ expect(proposal["preformatted_proposal"]).to include("rich_text_summary") end - it "includes a link for switch to NetworkManager" do + it "includes a link to switch to NetworkManager" do expect(proposal["preformatted_proposal"]).to match(/.*href.*NetworkManager.*/) end - it "does not include a link for switch to wicked" do + it "does not include a link to switch to wicked" do expect(proposal["preformatted_proposal"]).to_not match(/.*href.*wicked.*/) end @@ -99,15 +99,11 @@ context "when using the NetworkManager backend" do let(:current_backend) { :network_manager } - it "does not include the Yast::Lan proposal summary" do - expect(proposal["preformatted_proposal"]).to_not include("rich_text_summary") - end - - it "does not include a link for switch to NetworkManager" do + it "does not include a link to switch to NetworkManager" do expect(proposal["preformatted_proposal"]).to_not match(/.*href.*NetworkManager.*/) end - it "includes a link for switch to wicked" do + it "includes a link to switch to wicked" do expect(proposal["preformatted_proposal"]).to match(/.*href.*wicked.*/) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/test/support/config_writer_examples.rb new/yast2-network-4.4.2/test/support/config_writer_examples.rb --- old/yast2-network-4.3.63/test/support/config_writer_examples.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/test/support/config_writer_examples.rb 2021-04-10 10:37:01.000000000 +0200 @@ -24,6 +24,7 @@ require "y2network/connection_configs_collection" require "y2network/interfaces_collection" require "y2network/hostname" +require "y2network/boot_protocol" RSpec.shared_examples "ConfigWriter" do subject(:writer) { described_class.new } @@ -50,6 +51,7 @@ Y2Network::ConnectionConfig::Ethernet.new.tap do |conn| conn.interface = "eth0" conn.name = "eth0" + conn.bootproto = Y2Network::BootProtocol::DHCP end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/test/y2network/interface_config_builders/bonding_test.rb new/yast2-network-4.4.2/test/y2network/interface_config_builders/bonding_test.rb --- old/yast2-network-4.3.63/test/y2network/interface_config_builders/bonding_test.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/test/y2network/interface_config_builders/bonding_test.rb 2021-04-10 10:37:01.000000000 +0200 @@ -26,6 +26,10 @@ describe Y2Network::InterfaceConfigBuilders::Bonding do let(:config) { Y2Network::Config.new(source: :test) } + let(:dhcp) { Y2Network::BootProtocol::DHCP } + let(:none) { Y2Network::BootProtocol::NONE } + let(:hotplug) { Y2Network::Startmode.create("hotplug") } + let(:auto) { Y2Network::Startmode.create("auto") } before do allow(config).to receive(:interfaces).and_return(interfaces_collection) @@ -154,20 +158,20 @@ end context "when all the slaves are properly configure do" do - it "return false" do + it "returns false" do subject.save expect(subject.require_adaptation?(connection_config.slaves)).to eql(false) end end + context "when at least one configured slave need to be adapted" do - it "return true" do + it "returns true" do subject.save iface1_conn = connection_configs_collection.by_name("iface1") - iface1_conn.bootproto = Y2Network::BootProtocol::DHCP + iface1_conn.bootproto = dhcp expect(subject.require_adaptation?(connection_config.slaves)).to eql(true) end end - end describe "#save" do @@ -181,12 +185,22 @@ subject.save iface1_conn = connection_configs_collection.by_name("iface1") iface2_conn = connection_configs_collection.by_name("iface2") - iface2_conn.bootproto = Y2Network::BootProtocol::DHCP + iface2_conn.bootproto = dhcp expect(Y2Network::InterfaceConfigBuilder) .to receive(:for).with(anything, config: iface2_conn).once.and_call_original expect(Y2Network::InterfaceConfigBuilder) .to_not receive(:for).with(anything, config: iface1_conn) subject.save end + + it "sets the BOOTPROTO to 'none' and STARTMODE to 'hotplug' in the adapted configs" do + connection_config.slaves = ["iface1", "iface2"] + subject.save + iface2_conn = connection_configs_collection.by_name("iface2") + iface2_conn.bootproto = dhcp + expect { subject.save }.to change { iface2_conn.bootproto }.from(dhcp).to(none) + iface2_conn.startmode = auto + expect { subject.save }.to change { iface2_conn.startmode }.from(auto).to(hotplug) + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/test/y2network/network_manager/config_writer_test.rb new/yast2-network-4.4.2/test/y2network/network_manager/config_writer_test.rb --- old/yast2-network-4.3.63/test/y2network/network_manager/config_writer_test.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/test/y2network/network_manager/config_writer_test.rb 2021-04-10 10:37:01.000000000 +0200 @@ -24,6 +24,8 @@ require "y2network/connection_configs_collection" require "y2network/interface" require "y2network/interfaces_collection" +require "y2network/boot_protocol" +require "cfa/nm_connection" describe Y2Network::NetworkManager::ConfigWriter do subject(:writer) { described_class.new } @@ -42,6 +44,7 @@ let(:config) do old_config.copy.tap do |cfg| cfg.add_or_update_connection_config(eth0_conn) + cfg.dns = dns end end @@ -49,11 +52,24 @@ Y2Network::ConnectionConfig::Ethernet.new.tap do |conn| conn.interface = "eth0" conn.name = "eth0" - conn.bootproto = :static + conn.bootproto = Y2Network::BootProtocol::DHCP conn.ip = ip end end + let(:nameserver1) { IPAddr.new("192.168.1.1") } + let(:nameserver2) { IPAddr.new("10.0.0.1") } + let(:nameserver3) { IPAddr.new("2000:e1dd:f002:0120:0000:0000:0000:0001") } + let(:nameserver4) { IPAddr.new("2000:e1dd:f002:0120:0000:0000:0000:0002") } + + let(:dns) do + Y2Network::DNS.new( + nameservers: [ + nameserver1, nameserver2, nameserver3, nameserver4 + ] + ) + end + let(:ip) { Y2Network::ConnectionConfig::IPConfig.new(address: IPAddr.new("192.168.122.2")) } let(:eth0) { Y2Network::Interface.new("eth0") } @@ -64,7 +80,6 @@ before do allow(Y2Network::NetworkManager::ConnectionConfigWriter).to receive(:new) .and_return(conn_config_writer) - allow(writer).to receive(:write_dns) allow(writer).to receive(:write_drivers) allow(writer).to receive(:write_hostname) allow(writer).to receive(:write_routing) @@ -74,5 +89,34 @@ expect(conn_config_writer).to receive(:write).with(eth0_conn, nil, routes: [], parent: nil) writer.write(config) end + + context "writes DNS configuration" do + context "when a connection has static configuration" do + let(:eth0_conn) do + Y2Network::ConnectionConfig::Ethernet.new.tap do |conn| + conn.interface = "eth0" + conn.name = "eth0" + conn.bootproto = Y2Network::BootProtocol::STATIC + conn.ip = ip + end + end + + let(:file) do + CFA::NmConnection.new(File.join(DATA_PATH, "some_wifi.nmconnection")) + end + + before do + allow(CFA::NmConnection).to receive(:for).and_return(file) + allow(file).to receive(:save) + end + + it "includes DNS configuration in the configuration file" do + writer.write(config) + expect(file.ipv4["dns"]).to eq("#{nameserver1};#{nameserver2}") + expect(file.ipv6["dns"]).to eq("#{nameserver3};#{nameserver4}") + end + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/test/y2network/network_manager/connection_config_writer_test.rb new/yast2-network-4.4.2/test/y2network/network_manager/connection_config_writer_test.rb --- old/yast2-network-4.3.63/test/y2network/network_manager/connection_config_writer_test.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/test/y2network/network_manager/connection_config_writer_test.rb 2021-04-10 10:37:01.000000000 +0200 @@ -52,12 +52,14 @@ Y2Network::ConnectionConfig::IPConfig.new(Y2Network::IPAddress.from_string("10.100.0.1/24")) end - let(:path) { "/etc/NetworkManager/system-connections/eth0.nmconnection" } + let(:path) { Pathname.new("/etc/NetworkManager/system-connections/eth0.nmconnection") } let(:file) do - instance_double(CFA::NmConnection, save: nil) + instance_double(CFA::NmConnection, save: nil, load: nil, file_path: path, exist?: file_exist?) end + let(:file_exist?) { true } + describe "#write" do let(:handler) do instance_double( @@ -69,10 +71,8 @@ allow(writer).to receive(:require).and_call_original allow(Y2Network::NetworkManager::ConnectionConfigWriters::Ethernet).to receive(:new) .and_return(handler) - allow(CFA::NmConnection).to receive(:new).and_return(file) + allow(CFA::NmConnection).to receive(:for).with(conn).and_return(file) allow(writer).to receive(:ensure_permissions) - allow(::File).to receive(:exist?).with(Pathname.new(path)).and_return(true) - allow(::File).to receive(:exist?).and_call_original end it "uses the appropiate handler" do @@ -81,48 +81,10 @@ end context "when the file does not exist" do - before do - allow(::File).to receive(:exist?).with(Pathname.new(path)).and_return(false) - end + let(:file_exist?) { false } it "ensures the file is created with the the correct permissions" do - expect(writer).to receive(:ensure_permissions).with(Pathname.new(path)) - writer.write(conn) - end - end - - it "uses the connection name as base file name" do - expect(CFA::NmConnection).to receive(:new) do |path| - expect(path.basename).to eq(Pathname.new("eth0.nmconnection")) - end.and_return(file) - writer.write(conn) - end - - context "when writing a wireless connection" do - let(:conn) do - Y2Network::ConnectionConfig::Wireless.new.tap do |wlo1| - wlo1.name = "wlo1" - wlo1.interface = "wlo1" - wlo1.ip = ip_config - wlo1.essid = "MY_WIRELESS" - end - end - - let(:handler) do - instance_double( - Y2Network::NetworkManager::ConnectionConfigWriters::Wireless, write: nil - ) - end - - before do - allow(Y2Network::NetworkManager::ConnectionConfigWriters::Wireless).to receive(:new) - .and_return(handler) - end - - it "uses the ESSID as the base file name" do - expect(CFA::NmConnection).to receive(:new) do |path| - expect(path.basename).to eq(Pathname.new("MY_WIRELESS.nmconnection")) - end.and_return(file) + expect(writer).to receive(:ensure_permissions).with(path) writer.write(conn) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.3.63/test/y2network/wicked/connection_config_writers/bridge_test.rb new/yast2-network-4.4.2/test/y2network/wicked/connection_config_writers/bridge_test.rb --- old/yast2-network-4.3.63/test/y2network/wicked/connection_config_writers/bridge_test.rb 2021-03-30 13:11:41.000000000 +0200 +++ new/yast2-network-4.4.2/test/y2network/wicked/connection_config_writers/bridge_test.rb 2021-04-10 10:37:01.000000000 +0200 @@ -47,7 +47,7 @@ it "writes common properties" do handler.write(conn) expect(file).to have_attributes( - name: conn.description, + name: nil, startmode: "auto", bootproto: "dhcp" )