RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1132704 - Ruby DNS Resolv broken when resolv.conf has option ndots > 1
Summary: Ruby DNS Resolv broken when resolv.conf has option ndots > 1
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ruby
Version: 6.5
Hardware: All
OS: All
urgent
high
Target Milestone: rc
: ---
Assignee: Vít Ondruch
QA Contact: Iveta Wiedermann
URL:
Whiteboard:
Depends On:
Blocks: 1075802 1193067
TreeView+ depends on / blocked
 
Reported: 2014-08-21 20:46 UTC by Frank Hirtz
Modified: 2019-09-12 07:58 UTC (History)
7 users (show)

Fixed In Version: ruby-1.8.7.374-4.el6
Doc Type: Bug Fix
Doc Text:
Due to a bug in its name canonicalization mechanism, the Resolv DNS resolver was not able to perform simple lookup operations when the value of the "ndots" option in the resolv.conf file was greater than 1. This could lead to a variety of failures in users' configuration management system, such as the Puppet management tool, and in their provisioning system. This update fixes the canonicalization, which allows Resolv to perform lookups correctly and prevents the described problems.
Clone Of:
: 1193067 1200419 1255362 (view as bug list)
Environment:
Last Closed: 2015-10-22 09:28:52 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Ruby 10412 0 None None None Never

Description Frank Hirtz 2014-08-21 20:46:26 UTC
Description of problem:
Rubys resolver (/usr/lib/ruby/1.8/resolv.rb) attempts to implement name canonicalization similar to the system resolver.

It's implementation prevents simple lookups when ndots is set greater than 1 (the default).

For example, with this resolv.conf:

    nameserver 192.168.1.1
    nameserver 192.168.1.2
    options ndots:2
    search a.example.com b.example.com example.com

This script raises an Resolv::ResolvError exception:

    #!/usr/bin/ruby
    require 'resolv'
    p Resolv.getaddress('google.com')


Ruby's resolver parses /etc/resolv.conf extracting nameservers, search domains, and the ndots option.

When you attempt to resolv a name (which does not include a trailing "." indicating it is already fully qualified) it determines the number of dots in the name, and if there number of dots in the name is less than the ndots option, it attempts canonicalization.

This is correct behavior, but the canonicalization mechanism is where the problem lies. In the above example, it performs three lookups: google.com.a.example.com, google.com.b.example.com, and google.com.example.com. 

The linux resolver would do the same, and then fail back to google.com. if canonicalization fails. The issue is in /usr/lib/ruby/1.8/resolv.rb. The following patch makes ruby's resolver behave the same way as the system resolver:

    --- /usr/lib/ruby/1.8/resolv.rb 2010-12-22 22:22:57.000000000 -0500
    +++ resolv.rb   2014-08-20 18:50:05.653882000 -0400
    @@ -945,6 +945,10 @@
                 candidates = []
               end
               candidates.concat(@search.map {|domain| Name.new(name.to_a + domain)})
    +          fname = Name.create("#{name}.")
    +          if !candidates.include?(fname)
    +              candidates << fname
    +          end
             end
             return candidates
           end

It looks like the same bug exists in the upstream stable ruby 2.1.2.

This issue causes the client see failures in their configuration management system (puppet) and home-grown host provisioning system.

Version-Release number of selected component (if applicable):
All (RHEL versions as well as upstream). Tested on ruby and ruby200 in RHEL6 and Ruby 2.x in fedora.

Comment 3 Vít Ondruch 2014-10-22 07:39:52 UTC
Hi Frank,

Thank you for the bug report and attached patch. However, I am afraid I can't accept your patch unless it is upstreamed first, since it would result in different behavior of Ruby resolver on Fedora/RHEL then on other platforms. Therefore I opened upstream ticket:

https://bugs.ruby-lang.org/issues/10412

Lets see what upstream thinks about your patch.

Comment 6 Vít Ondruch 2014-12-02 09:01:57 UTC
The patch was accepted upstream:

https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/48534

So it should be possible to backport it.


Note You need to log in before you can comment on or make changes to this bug.