From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 111DE1FA18 for ; Mon, 25 Jan 2021 01:18:58 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/5] lei q: continue remote search if torsocks(1) is missing Date: Sun, 24 Jan 2021 17:18:57 -0800 Message-Id: <20210125011857.563-6-e@80x24.org> In-Reply-To: <20210125011857.563-1-e@80x24.org> References: <20210125011857.563-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: torsocks is just one of many ways to get curl to use Tor, so we'll continue if we can't find torsocks in our PATH and assume the user has a proxy configured via curlrc, the command-line, environment variable, or even firewall rules. --- lib/PublicInbox/LeiXSearch.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 369f6f89..b470c113 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -228,10 +228,16 @@ sub query_remote_mboxrd { my $cmd = [ @cmd, $uri->as_string ]; if ($tor eq 'auto' && substr($uri->host, -6) eq '.onion' && (($env->{LD_PRELOAD}//'') !~ /torsocks/)) { - unshift @$cmd, 'torsocks'; + unshift @$cmd, which('torsocks'); } elsif (PublicInbox::Config::git_bool($tor)) { - unshift @$cmd, 'torsocks'; + unshift @$cmd, which('torsocks'); } + + # continue anyways if torsocks is missing; a proxy may be + # specified via CLI, curlrc, environment variable, or even + # firewall rule + shift(@$cmd) if !$cmd->[0]; + $lei->err("# @$cmd") if $verbose; $? = 0; my $fh = popen_rd($cmd, $env, $rdr);