[tor-bugs] #5762 [Tor Client]: SOCK_CLOEXEC should get ENOSYS, not EINVAL, on accept()
Tor Bug Tracker & Wiki
torproject-admin at torproject.org
Thu May 3 22:18:35 UTC 2012
#5762: SOCK_CLOEXEC should get ENOSYS, not EINVAL, on accept()
------------------------+---------------------------------------------------
Reporter: arma | Owner:
Type: defect | Status: new
Priority: normal | Milestone: Tor: 0.2.3.x-final
Component: Tor Client | Version:
Keywords: | Parent:
Points: | Actualpoints:
------------------------+---------------------------------------------------
In #5112 we added a bunch of checks to ignore open(), accept4(), etc
failures if errno is EINVAL.
But it would appear the accept4() sets errno to ENOSYS, not EINVAL, if the
system lacks O_CLOEXEC support.
A quick google led me to
https://projects.honeynet.org/svn/sebek/virtualization/qebek/trunk/osdep.c
which handles EINVAL in most cases but ENOSYS in the accept4() case.
Here's the simple patch, but it probably wants a changes stanza and a much
better explanation in the comment if we like it:
{{{
diff --git a/src/common/compat.c b/src/common/compat.c
index fbb37ce..490deea 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1016,7 +1016,7 @@ tor_accept_socket(tor_socket_t sockfd, struct
sockaddr *
/* If we got an error, see if it is EINVAL. EINVAL might indicate that,
* event though we were built on a system with accept4 support, we
* are running on one without. */
- if (errno != EINVAL)
+ if (errno != ENOSYS)
return s;
#endif
}}}
See also http://osdir.com/ml/ruby-talk/2012-03/msg00082.html
Reported by murb.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/5762>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list