Skip to content

Commit

Permalink
Drop handling of 127.0.0.2 address
Browse files Browse the repository at this point in the history
* The feature was already dropped.
  • Loading branch information
imobachgs committed Oct 1, 2019
1 parent 46cfaf5 commit 29da11e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 98 deletions.
30 changes: 0 additions & 30 deletions src/modules/DNS.rb
Expand Up @@ -162,16 +162,6 @@ def ResolveIP(ip)
GetHostnameFromGetent(Ops.get_string(getent, "stdout", ""))
end

def DefaultWriteHostname
# FaTe#303875: Introduce a switch regarding 127.0.0.2 entry in /etc/hosts
whth = ProductFeatures.GetBooleanFeature(
"globals",
"write_hostname_to_hosts"
)
Builtins.y2milestone("write_hostname_to_hosts default value: %1", whth)
whth
end

# Default value for #dhcp_hostname based on ProductFeatures and Arch
#
# @return [Boolean] value set in features or, if none is set, false just
Expand All @@ -190,17 +180,6 @@ def default_dhcp_hostname
end
end

# Determines whether the hostname should be written to /etc/hosts
#
# This method stays just for compatibility reasons and it always returns `false`.
# It should be removed when `WRITE_HOSTNAME_TO_HOSTS` related stuff is dropped.
#
# @return [false]
# @see https://features.opensuse.org/308824
def write_hostname
false
end

# Reads DNS settings
#
# @note It reads all network settings, including DNS ones.
Expand Down Expand Up @@ -308,14 +287,6 @@ def dhclient_set_hostname
SYSCFG_TO_BOOL[SCR.Read(path(".sysconfig.network.dhcp.DHCLIENT_SET_HOSTNAME"))]
end

# Reads value of WRITE_HOSTNAME_TO_HOSTS and translates it to boolean
#
# return {true, false, nil} "yes" => true, "no" => false, otherwise or not
# present => nil
def get_write_hostname_to_hosts
SYSCFG_TO_BOOL[SCR.Read(path(".sysconfig.network.dhcp.WRITE_HOSTNAME_TO_HOSTS"))]
end

# Returns the YaST configuration
#
# @return [Y2Network::Config] LAN configuration
Expand All @@ -331,7 +302,6 @@ def system_dns_config

publish variable: :domain, type: "string"
publish function: :ReadNameserver, type: "boolean (string)"
publish function: :DefaultWriteHostname, type: "boolean ()"
publish function: :ReadHostname, type: "void ()"
publish function: :ProposeHostname, type: "void ()"
publish function: :Read, type: "boolean ()"
Expand Down
1 change: 0 additions & 1 deletion src/modules/Lan.rb
Expand Up @@ -539,7 +539,6 @@ def Write(gui: true)
# write resolv.conf after change from dhcp to static (#327074)
# reload/restart network before this to put correct resolv.conf from dhcp-backup
orig = Progress.set(false)
Host.EnsureHostnameResolvable
Host.Write(gui: gui)
Progress.set(orig)

Expand Down
67 changes: 0 additions & 67 deletions test/host_test.rb
Expand Up @@ -371,73 +371,6 @@
end
end

describe ".EnsureHostnameResolvable" do
context "need dummy ip" do
before do
allow(Yast::DNS).to receive(:write_hostname).and_return(true)
allow(Yast::DNS).to receive(:hostname).and_return("localmachine")
allow(Yast::DNS).to receive(:domain).and_return("domain.local")
Yast::Host.Read
end

it "sets entry for 127.0.0.2 to hostname and hostname with domain" do
Yast::Host.EnsureHostnameResolvable
Yast::Host.Write

content = file.content

expect(content.lines).to include("127.0.0.2\tlocalmachine.domain.local localmachine\n")
end

it "sets Host as modified" do
expect { Yast::Host.EnsureHostnameResolvable }
.to change { Yast::Host.GetModified }
.from(false).to(true)
end
end

context "do not need dummy ip" do
before do
allow(Yast::DNS).to receive(:write_hostname).and_return(false)
Yast::Host.Read
end

context "and 127.0.0.2 is present in /etc/hosts" do
it "deletes entry for 127.0.0.2" do
Yast::Host.EnsureHostnameResolvable
Yast::Host.Write

content = file.content

expect(content.lines.grep(/^127.0.0.2/)).to be_empty
end

it "sets Host as modified" do
expect { Yast::Host.EnsureHostnameResolvable }
.to change { Yast::Host.GetModified }
.from(false).to(true)
end
end
end

context "and /etc/hosts does not contains 127.0.0.2 entry" do
let(:file) do
file_path = File.join(DATA_PATH, "default_hosts")
CFA::MemoryFile.new(File.read(file_path))
end

before do
allow(Yast::DNS).to receive(:write_hostname).and_return(false)
Yast::Host.Read
end

it "does not set Host as modified" do
expect { Yast::Host.EnsureHostnameResolvable }
.not_to change { Yast::Host.GetModified }.from(false)
end
end
end

describe ".ResolveHostnameToStaticIPs" do
let(:static_ips) { ["1.1.1.1", "2.2.2.2"] }
let(:fqhostname) { "sles.suse.de" }
Expand Down

0 comments on commit 29da11e

Please sign in to comment.