Skip to content

Commit

Permalink
Do not crash when writing changes if old configuration is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Sep 17, 2019
1 parent 98be85f commit aa5e2c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/lib/y2network/sysconfig/config_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class ConfigWriter
# @param config [Y2Network::Config] Configuration to write
# @param old_config [Y2Network::Config] Old configuration
def write(config, old_config = nil)
return unless config.routing

write_ip_forwarding(config.routing)
write_ip_forwarding(config.routing) if config.routing
write_interface_changes(config, old_config)

# update /etc/sysconfig/network/routes file
Expand Down
10 changes: 6 additions & 4 deletions src/lib/y2network/sysconfig/dns_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,23 @@ def write(dns, old_dns)
# @return [String] Sendmail update script (included in "sendmail" package)
SENDMAIL_UPDATE_PATH = "/usr/lib/sendmail.d/update".freeze

def update_sysconfig_dhcp(config, old_config)
if old_config.dhcp_hostname == config.dhcp_hostname
# @param dns [Y2Network::DNS] DNS configuration
# @param old_dns [Y2Network::DNS] Old DNS configuration
def update_sysconfig_dhcp(dns, old_dns)
if old_dns.nil? || old_dns.dhcp_hostname == dns.dhcp_hostname
log.info("No update for /etc/sysconfig/network/dhcp")
return
end

Yast::SCR.Write(
Yast::Path.new(".sysconfig.network.dhcp.DHCLIENT_SET_HOSTNAME"),
config.dhcp_hostname == :any ? "yes" : "no"
dns.dhcp_hostname == :any ? "yes" : "no"
)
Yast::SCR.Write(Yast::Path.new(".sysconfig.network.dhcp"), nil)

# Clean-up values from ifcfg-* values
Y2Network::Sysconfig::InterfaceFile.all.each do |file|
value = file.interface == config.dhcp_hostname ? "yes" : nil
value = file.interface == dns.dhcp_hostname ? "yes" : nil
file.load
next if file.dhclient_set_hostname == value
file.dhclient_set_hostname = value
Expand Down

0 comments on commit aa5e2c3

Please sign in to comment.