Bug #7183
closedResolv::DNS::getresources throws Errno::EACCES: Permission denied - bind(2) on solaris
Description
we have ruby running on Solaris. sometimes one of our tools fails with exception Errno::EACCES while calling Resolv::DNS::getresources. This only happens one out of thousands of times the tool is used.
After looking into lib/resolv.rb I saw, there is an optimistic loop in bind_random_port(), which looks to me it is thought of the possibility that a unusable port is selected (one that is used by another process), and if that happens it is tried again. Unfortunately it is only done when the exception is Errno::EADDRINUSE, what might be correct in Linux, but not Solaris (Sol10u6).
I propose to add Errno::EACCESS to the raise statement. Maybe a retry count limit as well:
def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
begin
count += 1
port = rangerand(1024..65535)
udpsock.bind(bind_host, port)
rescue Errno::EADDRINUSE, Errno::EACCESS => e
if count < 10
retry
else
raise e
end
end
end
Updated by mame (Yusuke Endoh) about 12 years ago
- Status changed from Open to Assigned
- Assignee set to akr (Akira Tanaka)
- Target version changed from 1.9.3 to 2.0.0
Akr-san, could you check this?
--
Yusuke Endoh mame@tsg.ne.jp
Updated by mame (Yusuke Endoh) over 11 years ago
- Target version changed from 2.0.0 to 2.6
Updated by akr (Akira Tanaka) over 11 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r40112.
Frank, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- lib/resolv.rb (bind_random_port): Rescue EACCES for SunOS.
bind() on SunOS for port 2049 (nfs) and 4045 (lockd) causes
EACCES with unprivileged process. cf. PRIV_SYS_NFS in privileges(5)
[ruby-core:48064] [Bug #7183] reported by Frank Meier.