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-ASN: 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 AD7311FA17 for ; Fri, 30 Apr 2021 09:24:38 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/8] lei_curl: improve correctness of LD_PRELOAD check Date: Fri, 30 Apr 2021 09:24:32 +0000 Message-Id: <20210430092438.20926-3-e@80x24.org> In-Reply-To: <20210430092438.20926-1-e@80x24.org> References: <20210430092438.20926-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: LD_PRELOAD sent by a client can't affect lei-daemon. --- lib/PublicInbox/Config.pm | 1 + lib/PublicInbox/LeiCurl.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 016f50ec..3f0f5a01 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -12,6 +12,7 @@ use strict; use v5.10.1; use PublicInbox::Inbox; use PublicInbox::Spawn qw(popen_rd); +our $LD_PRELOAD = $ENV{LD_PRELOAD}; # only valid at startup sub _array ($) { ref($_[0]) eq 'ARRAY' ? $_[0] : [ $_[0] ] } diff --git a/lib/PublicInbox/LeiCurl.pm b/lib/PublicInbox/LeiCurl.pm index 69c64cdf..ce57e796 100644 --- a/lib/PublicInbox/LeiCurl.pm +++ b/lib/PublicInbox/LeiCurl.pm @@ -55,7 +55,7 @@ sub torsocks { # useful for "git clone" and "git fetch", too $opt->{torsocks} = 'false' if $opt->{'no-torsocks'}; my $torsocks = $opt->{torsocks} //= 'auto'; if ($torsocks eq 'auto' && substr($uri->host, -6) eq '.onion' && - (($lei->{env}->{LD_PRELOAD}//'') !~ /torsocks/)) { + ($PublicInbox::Config::LD_PRELOAD//'') !~ m!/libtorsocks\b!) { # "auto" continues anyways if torsocks is missing; # a proxy may be specified via CLI, curlrc, # environment variable, or even firewall rule