Connection through torsocks(1) impossible
After installing the recent Ubuntu 14.04 AMD64 desktop release (LTS) I went about testing tor(1) and torsocks(1) and saw this:
WITHOUT TOR
$svn co http://svn.apache.org/repos/asf/subversion/trunk subversion A subversion/notes A subversion/notes/commit-access-templates A subversion/notes/api-errata A subversion/notes/api-errata/1.7 A subversion/notes/api-errata/1.8 [...]
WITH TOR
$torsocks svn co http://svn.apache.org/repos/asf/subversion/trunk subversion svn: E120108: Unable to connect to a repository at URL 'http://svn.apache.org/repos/asf/subversion/trunk' svn: E120108: Error running context: The server unexpectedly closed the connection.
Since the OS installation is brand new and plain vanilla (no network bridges, VPNs, custom routing, or even a single service configured except for Tor) it seems a problem lies in the Tor software (either the service itself or the Socks wrapper.)
IMPORTANT CLUE
The svn(1) symptom above does not appear when replacing with git(1).
DIAGNOSIS
Running commands through torsocks(1) showing the symptom while inspecting with strace(1) reveals typical socket(2), fcntl(2), fstat(2), setsockopt(2), getpeername(2), and connect(2) to a tor(1) service running on localhost:9050 as usual. What might be atypical is that ENOTCONN and EINPROGRESS are returned in the way indicated by bug #8066 (moved) [1]. A late comment in #8066 (moved) refers in turn to #3711 (moved) [2], which are both leads.
[1] https://trac.torproject.org/projects/tor/ticket/8066/ [2] https://trac.torproject.org/projects/tor/ticket/3711/
LINUX DISTROS
Due to time constraints, I wasn't able to build tor(1) and torsocks(1) from source (at git.torproject.org) so there's a small chance that the bug has been fixed although no bug report exists to support this theory. It doesn't solve the problem of integrating whichever solution exists into leading Linux distributions however, which are still bundling the flawed version.
Trac:
Username: michael