From 1fc012b42bd2268db2bb764845b861bf7ec4e69c Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Tue, 13 Apr 2021 13:31:46 +0100 Subject: [PATCH 1/3] Do not crash when there is no interface associated --- src/include/network/lan/address.rb | 44 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/include/network/lan/address.rb b/src/include/network/lan/address.rb index 95c5f1173..cb3bf5cf9 100644 --- a/src/include/network/lan/address.rb +++ b/src/include/network/lan/address.rb @@ -57,31 +57,33 @@ def initialize_network_lan_address(include_target) def AddressDialog(builder:) ret = Y2Network::Dialogs::EditInterface.run(builder) - if ret != :back && ret != :abort - 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( - _( - "A static default route is defined.\n" \ - "It is suggested to remove the static default route definition \n" \ - "if one can be obtained also via DHCP.\n" \ - "Do you want to remove the static default route?" - ) + log.info "AddressDialog res: #{ret.inspect}" + + return ret if [:back, :abort].include?(ret) + return ret if builder.interface&.hotplug? + + if builder.boot_protocol.dhcp? + # 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( + _( + "A static default route is defined.\n" \ + "It is suggested to remove the static default route definition \n" \ + "if one can be obtained also via DHCP.\n" \ + "Do you want to remove the static default route?" ) - yast_config.routing.remove_default_routes if remove_gw - end + ) + yast_config.routing.remove_default_routes if remove_gw end end - log.info "AddressDialog res: #{ret.inspect}" ret end end From fa6ddba3c6c77472db316e2df2cabdce3b8cfd63 Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Tue, 13 Apr 2021 13:34:51 +0100 Subject: [PATCH 2/3] Bump version & changelog --- package/yast2-network.changes | 7 +++++++ package/yast2-network.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/yast2-network.changes b/package/yast2-network.changes index 52123ab6d..2a7eed78c 100644 --- a/package/yast2-network.changes +++ b/package/yast2-network.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Apr 13 12:32:16 UTC 2021 - Knut Anderssen + +- Do not crash when checking if an interface is a hotplug one and + it is not present (bsc#1184623) +- 4.4.3 + ------------------------------------------------------------------- Fri Apr 9 11:22:42 UTC 2021 - Knut Anderssen diff --git a/package/yast2-network.spec b/package/yast2-network.spec index e17c1dd68..1e49c6355 100644 --- a/package/yast2-network.spec +++ b/package/yast2-network.spec @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.4.2 +Version: 4.4.3 Release: 0 Summary: YaST2 - Network Configuration License: GPL-2.0-only From 4b9c385085633ed392ededd0cff137dec9035be7 Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Tue, 13 Apr 2021 13:48:43 +0100 Subject: [PATCH 3/3] Changes based on CR. --- src/include/network/lan/address.rb | 38 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/include/network/lan/address.rb b/src/include/network/lan/address.rb index cb3bf5cf9..b9de37599 100644 --- a/src/include/network/lan/address.rb +++ b/src/include/network/lan/address.rb @@ -60,28 +60,26 @@ def AddressDialog(builder:) log.info "AddressDialog res: #{ret.inspect}" return ret if [:back, :abort].include?(ret) - return ret if builder.interface&.hotplug? + return ret if builder.interface&.hotplug? || !builder.boot_protocol.dhcp? - if builder.boot_protocol.dhcp? - # 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( - _( - "A static default route is defined.\n" \ - "It is suggested to remove the static default route definition \n" \ - "if one can be obtained also via DHCP.\n" \ - "Do you want to remove the static default route?" - ) + # 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( + _( + "A static default route is defined.\n" \ + "It is suggested to remove the static default route definition \n" \ + "if one can be obtained also via DHCP.\n" \ + "Do you want to remove the static default route?" ) - yast_config.routing.remove_default_routes if remove_gw - end + ) + yast_config.routing.remove_default_routes if remove_gw end ret