Bug 1298282 - Fix IPv6 addresses in URIs with Net::HTTP
Fix IPv6 addresses in URIs with Net::HTTP
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ruby (Show other bugs)
7.2
Unspecified Unspecified
high Severity high
: rc
: ---
Assigned To: Pavel Valena
Iveta Wiedermann
:
Depends On:
Blocks: 1313485 1289025 1295829
  Show dependency treegraph
 
Reported: 2016-01-13 11:18 EST by Tomas Jelinek
Modified: 2016-11-04 02:16 EDT (History)
6 users (show)

See Also:
Fixed In Version: ruby-2.0.0.648-26.el7
Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-11-04 02:16:24 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Ruby 9129 None None None 2016-05-19 07:05 EDT

  None (edit)
Description Tomas Jelinek 2016-01-13 11:18:04 EST
Description of problem:
There is a bug in ruby stdlib Net::HTTP class which prevents connecting to hosts using IPv6.


Version-Release number of selected component (if applicable):
[root@rh72-node1:~]# ruby -v
ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
[root@rh72-node1:~]# rpm -q ruby
ruby-2.0.0.598-25.el7_1.x86_64


How reproducible:
easily, always


Steps to Reproduce:
[root@rh72-node1:~]# irb
irb(main):001:0> require 'net/http'
=> true
irb(main):002:0> myhttp = Net::HTTP.new("::1")
=> #<Net::HTTP ::1:80 open=false>
irb(main):003:0> myhttp.start
URI::InvalidURIError: the scheme http does not accept registry part: ::1:80 (or bad hostname?)
        from /usr/share/ruby/uri/generic.rb:214:in `initialize'
        from /usr/share/ruby/uri/http.rb:84:in `initialize'
        from /usr/share/ruby/uri/common.rb:214:in `new'
        from /usr/share/ruby/uri/common.rb:214:in `parse'
        from /usr/share/ruby/uri/common.rb:747:in `parse'
        from /usr/share/ruby/uri/common.rb:996:in `URI'
        from /usr/share/ruby/net/http.rb:1027:in `proxy_uri'
        from /usr/share/ruby/net/http.rb:1014:in `proxy?'
        from /usr/share/ruby/net/http.rb:868:in `connect'
        from /usr/share/ruby/net/http.rb:862:in `do_start'
        from /usr/share/ruby/net/http.rb:857:in `start'
        from (irb):3
        from /usr/bin/irb:12:in `<main>'
irb(main):004:0> myhttp = Net::HTTP.new("[::1]")
=> #<Net::HTTP [::1]:80 open=false>
irb(main):005:0> myhttp.start
SocketError: getaddrinfo: Name or service not known
        from /usr/share/ruby/net/http.rb:878:in `initialize'
        from /usr/share/ruby/net/http.rb:878:in `open'
        from /usr/share/ruby/net/http.rb:878:in `block in connect'
        from /usr/share/ruby/timeout.rb:52:in `timeout'
        from /usr/share/ruby/net/http.rb:877:in `connect'
        from /usr/share/ruby/net/http.rb:862:in `do_start'
        from /usr/share/ruby/net/http.rb:857:in `start'
        from (irb):5
        from /usr/bin/irb:12:in `<main>'
irb(main):006:0>


Actual results:
Ruby does not even try to connect to localhost no matter if the address is enclosed in [] (which is wrong anyways) or not.


Expected results:
irb(main):001:0> require 'net/http'
=> true
irb(main):002:0> myhttp = Net::HTTP.new("::1")
=> #<Net::HTTP ::1:80 open=false>
irb(main):003:0> myhttp.start
Errno::ECONNREFUSED: Connection refused - connect(2) for "::1" port 80
        from /usr/share/ruby/net/http.rb:879:in `initialize'
        from /usr/share/ruby/net/http.rb:879:in `open'
        from /usr/share/ruby/net/http.rb:879:in `block in connect'
        from /usr/share/ruby/timeout.rb:73:in `timeout'
        from /usr/share/ruby/net/http.rb:878:in `connect'
        from /usr/share/ruby/net/http.rb:863:in `do_start'
        from /usr/share/ruby/net/http.rb:858:in `start'
        from (irb):3
        from /usr/bin/irb:11:in `<main>'
irb(main):004:0>

Ruby tries to connect to localhost. Since there is no HTTP server running, it gets Errno::ECONNREFUSED, that is not an issue.


Additional info:
This has been reported in upstream https://bugs.ruby-lang.org/issues/9129
and fixed as well https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47079
Comment 2 Vít Ondruch 2016-01-14 06:23:13 EST
This could be resolved by rebase of Ruby 2.0.0 I am proposing in bug 1197720.
Comment 7 errata-xmlrpc 2016-11-04 02:16:24 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHEA-2016-2422.html

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