Project

General

Profile

Actions

Feature #17944

closed

Remove Socket.gethostbyaddr and Socket.gethostbyname

Feature #17944: Remove Socket.gethostbyaddr and Socket.gethostbyname

Added by pvalena (Pavel Valena) about 5 years ago. Updated 3 days ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:104229]

Description

It is marked as unsafe by our static analysis. Can it be removed now?

It was deprecated in:
https://bugs.ruby-lang.org/projects/ruby-master/repository/trunk/revisions/60266
https://bugs.ruby-lang.org/issues/13097


Related issues 1 (0 open1 closed)

Related to Ruby - Feature #13097: Deprecate Socket.gethostbyaddr and Socket.gethostbynameClosedActions

Updated by jaruga (Jun Aruga) about 2 years ago ยท Edited 1Actions #1 [ruby-core:117780]

The commit for the deprecated documents was added in 2017.

Deprecation document for gethostbyname,gethostbyaddr.
https://github.com/ruby/ruby/commit/b5c6fc856100b17b6f20e6e792a02ee7e33306bc
Date: Sat Oct 21 13:13:02 2017 +0000

The commit for printng warning messages was added in 2020.

Show deprecation warning on Socket.gethostbyname and Socket.gethostbyaddr
https://github.com/ruby/ruby/commit/6d946665bd79a93fb98b2d25400d1b6174472302
Date: Sat Aug 29 17:18:59 2020 +0900

If we are hesitate to drop the functions, we may be able to drop the functions conditionally with the configure option(s) like this.

$ ./configure --disable-socket-gethostbyname --disable-socket-gethostbyaddr

or

$ ./configure --disable-socket-gethostbyname-and-addr

Updated by Earlopain (Earlopain _) 10 days ago Actions #2

  • Related to Feature #13097: Deprecate Socket.gethostbyaddr and Socket.gethostbyname added

Updated by Earlopain (Earlopain _) 10 days ago Actions #3 [ruby-core:125620]

ruby/spec has the following test:

addr = IPAddr.new('::1').hton
it 'raises SocketError when the address is not supported by the family' do
  -> { suppress_warning { Socket.gethostbyaddr(addr, :INET) } }.should.raise(SocketError)
end

But it doesn't raise and instead returns the following result for me: ["pi.hole", [], 2, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"].
Given https://github.com/ruby/ruby/commit/41977ef59585d1ee42ffcb546aa80f071512b257, it doesn't look I am the only one this happened to.

They print warnings for ~6 years now, so it seems wasted time to investigate this. Can we simply remove them now?

Updated by matz (Yukihiro Matsumoto) 4 days ago Actions #4 [ruby-core:125698]

It didn't seem like anyone was using them, and since they weren't good API to begin with (they had Perl-like design), I felt it was okay to remove them.

Matz.

Updated by nobu (Nobuyoshi Nakada) 3 days ago Actions #5

  • Status changed from Open to Closed

Applied in changeset git|221c7c6644f61cf329f6cbaf5924e52917cdc2a7.


[Feature #17944] Remove deprecated socket methods

These methods have been deprecated since nine years ago.

Actions

Also available in: PDF Atom