Regression in Torsocks 2.2.0 breaks wget, among others
Various applications no longer work due to a regression in the latest Torsocks update, such as tlsdate and wget, whereas curl and youtube-dl work. I've tested this by compiling both 2.1.0 and 2.2.0 and exporting the library with LD_PRELOAD, and trying wget with both.
The problem is not with name resolution, as would be suggested in the wget error, or with the TLS handshake, as tlsdate suggests, because the strace output does not even get to socket() and connect(). However, when an IP address is passed directly to wget rather than a hostname, 2.2.0 works. It appears to me like the problem, at least in wget's case, is with the hostname resolution code being hooked incorrectly by Torsocks. That's just a guess though.
With wget and curl:
$ LD_PRELOAD=libtorsocks-2.1.0.so curl https://www.torproject.org/ >/dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 15868 100 15868 0 0 6158 0 0:00:02 0:00:02 --:--:-- 8369
$ LD_PRELOAD=libtorsocks-2.1.0.so wget --spider https://www.torproject.org/
Spider mode enabled. Check if remote file exists.
--2016-12-03 10:08:57-- https://www.torproject.org/
Resolving www.torproject.org... 38.229.72.16
Connecting to www.torproject.org|38.229.72.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15868 (15K) [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.
$ LD_PRELOAD=libtorsocks-2.2.0.so curl https://www.torproject.org/ >/dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 15868 100 15868 0 0 7227 0 0:00:02 0:00:02 --:--:-- 10494
$ LD_PRELOAD=libtorsocks-2.2.0.so wget --spider https://www.torproject.org/
Spider mode enabled. Check if remote file exists.
--2016-12-03 10:09:20-- https://www.torproject.org/
Resolving www.torproject.org... failed: Unknown error.
wget: unable to resolve host address www.torproject.org
$ LD_PRELOAD=libtorsocks-2.2.0.so wget --spider $(tor-resolve torproject.org)
Spider mode enabled. Check if remote file exists.
--2016-12-03 10:11:12-- http://138.201.14.197/
Connecting to 138.201.14.197:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 496 [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.
And with tlsdate:
$ LD_PRELOAD=libtorsocks-2.1.0.so tlsdate -n -V
Sat Dec 3 10:11:57 UTC 2016
$ LD_PRELOAD=libtorsocks-2.2.0.so tlsdate -n -V
SSL connection failed
child process failed in SSL handshake