Project

General

Profile

Bug #10747

DNS resolution should fall back to TCP on Errno::EACCES

Added by a13m (Andy Grimm) almost 5 years ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:67636]

Description

On some platforms, users may be restricted from global binding to a UDP port, which is necessary for UDP-based DNS lookups. In this case, an exception like the following is currently raised:

ruby -r resolv -e 'puts Resolv.getaddress "'
resolv.rb:655:in bind': Permission denied - bind(2) (Errno::EACCES)
resolv.rb:655:in
bind_random_port'
resolv.rb:791:in initialize'
resolv.rb:560:in
new'
resolv.rb:560:in make_udp_requester'
resolv.rb:513:in
each_resource'
resolv.rb:406:in each_address'
resolv.rb:115:in
block in each_address'
resolv.rb:114:in each'
resolv.rb:114:in
each_address'
resolv.rb:92:in getaddress'
resolv.rb:43:in
getaddress'

This error should be caught, and the resolver should fall back to TCP, as it does in other cases where this is necessary. A possible patch for this (written against 2.0.0p353 in RHEL) is attached.

Ideally, it would also be nice to be able to specify tcp by default when initializing a DNS object on such platforms, to avoid repeated bind attempts which are known to fail, but I am not sure of the best way to introduce such an option.


Files

resolver-force-tcp.patch (830 Bytes) resolver-force-tcp.patch patch to fall back to TCP when Errno::EACCES is caught a13m (Andy Grimm), 01/16/2015 07:26 PM
resolv-tcp-fallback-eacces.patch (1.19 KB) resolv-tcp-fallback-eacces.patch jeremyevans0 (Jeremy Evans), 07/08/2019 01:54 AM

Associated revisions

Revision f37cc1c7
Added by jeremyevans (Jeremy Evans) about 2 months ago

Fallback to TCP in resolv if UDP bind raises EACCES

Original patch from Andy Grimm.

Fixes [Bug #10747]

History

Updated by jeremyevans0 (Jeremy Evans) 5 months ago

I'm not sure I would consider this a bug, but it seems like a reasonable change. Attached is an updated patch that applies against master.

#2

Updated by jeremyevans (Jeremy Evans) about 2 months ago

  • Status changed from Assigned to Closed

Applied in changeset git|f37cc1c719f12d2cad6032aa4e6f4236f0604992.


Fallback to TCP in resolv if UDP bind raises EACCES

Original patch from Andy Grimm.

Fixes [Bug #10747]

Also available in: Atom PDF