Skip to content

Commit

Permalink
Fixes #37621 - Correctly resolve the IPv4 address
Browse files Browse the repository at this point in the history
In 3f079df the lookup code was changed
to explicitly query IPv4, but it assumed a string was returned instead
of a Resolv::DNS::Resource::IN::A instance.

Fixes: 3f079df ("Fixes #37355 - Explicitly query for IPv4 address in omapi code")
  • Loading branch information
ekohl committed Jul 2, 2024
1 parent 7df1868 commit 28b6324
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/dhcp_common/isc/omapi_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def bootServer(server)
rescue
begin
logger.info "Next-server option not IPv4, trying to resolve '#{server}'"
ip2hex(dns_resolv.getresource(server, Resolv::DNS::Resource::IN::A))
ip2hex(dns_resolv.getresource(server, Resolv::DNS::Resource::IN::A).address.to_s)
rescue Resolv::ResolvError => e
logger.warn "Unable to resolve DNS A query for '#{server}', will use the hostname"
logger.debug "Reason: #{e}"
Expand Down
2 changes: 1 addition & 1 deletion test/dhcp/isc_omapi_provider_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_boot_server_ip
end

def test_boot_server_hostname
::Proxy::LoggingResolv.any_instance.expects(:getresource).with("ptr-doesnotexist.example.com", Resolv::DNS::Resource::IN::A).returns("127.0.0.2")
::Proxy::LoggingResolv.any_instance.expects(:getresource).with("ptr-doesnotexist.example.com", Resolv::DNS::Resource::IN::A).returns(Resolv::DNS::Resource::IN::A.new("127.0.0.2"))
assert_equal "7f:00:00:02", @dhcp.bootServer("ptr-doesnotexist.example.com")
end

Expand Down

0 comments on commit 28b6324

Please sign in to comment.